OpenAI
This documentation describes the integration of MindsDB with OpenAI, an AI research organization known for developing AI models like GPT-3 and GPT-4. The integration allows for the deployment of OpenAI models within MindsDB, providing the models with access to data from various data sources.
Prerequisites
Before proceeding, ensure the following prerequisites are met:
- Install MindsDB locally via Docker or Docker Desktop.
- To use OpenAI within MindsDB, install the required dependencies following this instruction.
- Obtain the OpenAI API key required to deploy and use OpenAI models within MindsDB. Follow the instructions for obtaining the API key.
Setup
Create an AI engine from the OpenAI handler.
Create a model using openai_engine as an engine.
If you want to update the prompt_template parameter, you do not have to recreate the model. Instead, you can override the prompt_template parameter at prediction time like this:
The following parameters are available to use when creating an OpenAI model:
Usage
Here are the combination of parameters for creating a model:
- Provide a
prompt_templatealone. - Provide a
question_columnand optionally acontext_column. - Provide a
prompt,user_column, andassistant_columnto create a model in the conversational mode.
The following usage examples utilize openai_engine to create a model with the CREATE MODEL statement.
Next Steps
Follow this tutorial on sentiment analysis and this tutorial on finetuning OpenAI models to see more use case examples.
Troubleshooting Guide
Authentication Error
- Symptoms: Failure to authenticate to the OpenAI API.
- Checklist:
- Make sure that your OpenAI account is active.
- Confirm that your API key is correct.
- Ensure that your API key has not been revoked.
- Ensure that you have not exceeded the API usage or rate limit.
SQL statement cannot be parsed by mindsdb_sql
- Symptoms: SQL queries failing or not recognizing table and model names containing spaces or special characters.
- Checklist:
- Ensure table names with spaces or special characters are enclosed in backticks.
Examples:
- Incorrect:
- Incorrect:
- Correct:
- Incorrect:
- Ensure table names with spaces or special characters are enclosed in backticks.
Examples: