Develop a streamlit app to explore GPT-3 Codex capability (https://beta.openai.com/docs/guides/code/introduction) in terms of SQL generation
- Experiment with and validate GPT-3 capability;
- Target SQLite database;
- Use sample dataset from https://www.sqlitetutorial.net/sqlite-sample-database/;
Get your own API Key at https://beta.openai.com/, save it into a new file at app/cfg/api_key.yaml
(make sure this file is gitignored):
OPENAI_API_KEY: <ENTER-Your-Own-API-Key>
Run the following commands a shell terminal:
$ pip install -r requirements.txt
$ cd app
$ streamlit run app.py
Prompt submitted at Playground
"""
Table customers, columns = [CustomerId, FirstName, LastName, Company, Address, City, State, Country, PostalCode, Phone, Fax, Email, SupportRepId]
Create a SQLite query for all customers in Texas named Jane
"""
The Python code:
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
# POST /v1/completions
response = openai.Completion.create(
model="davinci-instruct-beta",
prompt="\"\"\"\nTable customers, columns = [CustomerId, FirstName, LastName, State]\nCreate a SQLite query for all customers in Texas named Jane\n\"\"\"\n\n\n",
temperature=0,
max_tokens=256,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)
Response:
print(response["choices"][0]["text"])
SELECT * FROM customers WHERE State='TX' AND FirstName='Jane'
- OpenAI Community Forum
- GPT-3: All you need to know about the AI language model
- New Version of GPT-3 Is Much Better
- gpt3-sandbox repo
- Streamlit Community Forum
- GPT-3 Demo Showcase
- https://streamlit-example-app-streamlit-codex-streamlit-app-wfi4of.streamlitapp.com/