Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] Migrate OpenAI's json_struct mode to use prompt template #9382

Merged
merged 3 commits into from
Jun 21, 2024

Conversation

paxcema
Copy link
Member

@paxcema paxcema commented Jun 20, 2024

Description

Deprecate input_text keyword argument in favor of prompt_template when using json_struct mode, both for UX streamlining and also to enable multi-column support.

Example queries change from this:

CREATE MODEL mindsdb.nlp_model
PREDICT json
USING
    engine = 'openai_engine',
    json_struct = {
        'rental_price': 'rental price',
        'location': 'location',
        'nob': 'number of bathrooms'
    },
    input_text = 'sentence';

SELECT json
FROM mindsdb.nlp_model
WHERE sentence = 'Amazing 3 bedroom apartment located at the heart of Manhattan, has one full bathrooms and one toilet room for just 3000 a month.';

To this:

CREATE MODEL mindsdb.nlp_model
PREDICT json
USING
    engine = 'openai_engine',
    json_struct = {
        'rental_price': 'rental price',
        'location': 'location',
        'nob': 'number of bathrooms'
    },
    prompt_template = '{{sentence}}';

SELECT json
FROM mindsdb.nlp_model
WHERE sentence = 'Amazing 3 bedroom apartment located at the heart of Manhattan, has one full bathrooms and one toilet room for just 3000 a month.';

image

Type of change

  • ⚡ New feature (non-breaking change which adds functionality)
  • 📢 Breaking change (fix or feature that would cause existing functionality not to work as expected)
  • 📄 This change requires a documentation update

@martyna-mindsdb feel free to directly change docs on this PR if that's helpful.

Tagging @torrmal for visibility at his request.

Verification Process

To ensure the changes are working as expected:

  • Test Location: manual test.
  • Verification Steps: follow this example from our docs.

Checklist:

  • My code follows the style guidelines(PEP 8) of MindsDB.
  • I have appropriately commented on my code, especially in complex areas.
  • Necessary documentation updates are either made or tracked in issues.
  • Relevant unit and integration tests are updated or added.

@paxcema paxcema requested review from StpMax and ea-rus June 20, 2024 19:57
@martyna-mindsdb
Copy link
Contributor

@paxcema
Thanks. I have pushed the docs updates.

@paxcema paxcema merged commit 3f5fadc into main Jun 21, 2024
13 checks passed
@paxcema paxcema deleted the feat/openai/json-struct-supports-prompt-template branch June 21, 2024 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants