This program uses Pandas to convert a tabular source of data into a SQL database. Then takes the user prompt and combines the prompt with the SQL data base info, and sends the prompt to OpenAI API using a Completion model to generate the SQL query.
Note: The Text Completion model is also very good at completing actual code.
-
Text Completion: Optimized for completing with natural language.
-
Code Completion: Optimized for completing with actual executable code.
At this time we're using the "gtp-3.5-turbo" model.
Link: https://platform.openai.com/docs/model-index-for-reserchers
Previous Models: - text-davinci-002 - code-davinci-002 - text-davinci-003
- Model: The OpenAI Model
- Prompt:
- Temperature:
- Max Tokens:
- Top P:
- N:
- Frequency Penalty:
- Presence Penalty:
- Setup OpenAI API Key.
- Read CSV file.
- Create an in-memory SQL database and load the csv data.
- Work on the Prompt Engineering using the user prompt.
- Pass the created prompt to the OpenAI API and the configuration.
- Handle the response from OpenAI API, to just get the actual SQL query.
- Run the final SQL Query on the database