Spaces:
Build error
Build error
Update script.py
Browse files
script.py
CHANGED
|
@@ -5,7 +5,7 @@ import pandas as pd
|
|
| 5 |
import sqlite3
|
| 6 |
import streamlit as st
|
| 7 |
|
| 8 |
-
|
| 9 |
|
| 10 |
TABLES = ['Album', 'Artist', 'Track']
|
| 11 |
|
|
@@ -20,7 +20,7 @@ def _get_metadata():
|
|
| 20 |
cur = con.cursor()
|
| 21 |
|
| 22 |
ts, cs = list(), list()
|
| 23 |
-
for table in
|
| 24 |
|
| 25 |
rows = cur.execute("select * from %s limit 1" % table)
|
| 26 |
cols = [k[0] for k in rows.description]
|
|
@@ -35,7 +35,7 @@ st.title("English to SQL via LangChain")
|
|
| 35 |
st.subheader("table metadata")
|
| 36 |
st.dataframe(_get_metadata())
|
| 37 |
|
| 38 |
-
llm = OpenAI(temperature=0.0, openai_api_key=
|
| 39 |
db = SQLDatabase.from_uri("sqlite:///Chinook.db", include_tables=TABLES)
|
| 40 |
db_chain = SQLDatabaseChain.from_llm(llm, db, use_query_checker=True, return_intermediate_steps=True)
|
| 41 |
|
|
|
|
| 5 |
import sqlite3
|
| 6 |
import streamlit as st
|
| 7 |
|
| 8 |
+
OPENAI_API_KEY = os.getenv('OPENAI_API_KEY')
|
| 9 |
|
| 10 |
TABLES = ['Album', 'Artist', 'Track']
|
| 11 |
|
|
|
|
| 20 |
cur = con.cursor()
|
| 21 |
|
| 22 |
ts, cs = list(), list()
|
| 23 |
+
for table in TABLES:
|
| 24 |
|
| 25 |
rows = cur.execute("select * from %s limit 1" % table)
|
| 26 |
cols = [k[0] for k in rows.description]
|
|
|
|
| 35 |
st.subheader("table metadata")
|
| 36 |
st.dataframe(_get_metadata())
|
| 37 |
|
| 38 |
+
llm = OpenAI(temperature=0.0, openai_api_key=OPENAI_API_KEY)
|
| 39 |
db = SQLDatabase.from_uri("sqlite:///Chinook.db", include_tables=TABLES)
|
| 40 |
db_chain = SQLDatabaseChain.from_llm(llm, db, use_query_checker=True, return_intermediate_steps=True)
|
| 41 |
|