Spaces:
Build error
Build error
Update script.py
Browse files
script.py
CHANGED
|
@@ -25,8 +25,10 @@ for table in tables:
|
|
| 25 |
|
| 26 |
con.close()
|
| 27 |
|
| 28 |
-
|
|
|
|
| 29 |
|
|
|
|
| 30 |
db_chain = SQLDatabaseChain.from_llm(llm, db, verbose=True, use_query_checker=True)
|
| 31 |
|
| 32 |
queries = ("How many albums are there?"
|
|
@@ -35,10 +37,10 @@ queries = ("How many albums are there?"
|
|
| 35 |
)
|
| 36 |
|
| 37 |
for query in queries:
|
|
|
|
| 38 |
result = db_chain.run(query)
|
| 39 |
print(result)
|
|
|
|
| 40 |
st.text(query)
|
| 41 |
st.text(result)
|
| 42 |
|
| 43 |
-
st.subheader("table metadata")
|
| 44 |
-
st.dataframe(pd.DataFrame(metadata), columns=['table', 'columns'])
|
|
|
|
| 25 |
|
| 26 |
con.close()
|
| 27 |
|
| 28 |
+
st.subheader("table metadata")
|
| 29 |
+
st.dataframe(pd.DataFrame(metadata, columns=['table', 'columns']))
|
| 30 |
|
| 31 |
+
llm = OpenAI(temperature=0.0, openai_api_key=API_KEY)
|
| 32 |
db_chain = SQLDatabaseChain.from_llm(llm, db, verbose=True, use_query_checker=True)
|
| 33 |
|
| 34 |
queries = ("How many albums are there?"
|
|
|
|
| 37 |
)
|
| 38 |
|
| 39 |
for query in queries:
|
| 40 |
+
|
| 41 |
result = db_chain.run(query)
|
| 42 |
print(result)
|
| 43 |
+
|
| 44 |
st.text(query)
|
| 45 |
st.text(result)
|
| 46 |
|
|
|
|
|
|