Spaces:
Sleeping
Sleeping
HassanSaado commited on
Commit ·
f140af3
1
Parent(s): ad6be74
Improved UI
Browse files
app.py
CHANGED
|
@@ -25,14 +25,21 @@ llm = ChatOpenAI(model="gpt-3.5-turbo-0125", temperature=0)
|
|
| 25 |
agent_executor = create_sql_agent(llm, db=db, agent_type="openai-tools", verbose=False)
|
| 26 |
|
| 27 |
#sidebar
|
| 28 |
-
st.sidebar.title("
|
| 29 |
-
st.sidebar.write("
|
|
|
|
| 30 |
#list of the tables in database
|
| 31 |
tables = db.get_table_names()
|
| 32 |
-
st.sidebar.write("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
st.sidebar.write(tables)
|
| 34 |
|
| 35 |
yes_list = ["yes","Yes", "yes", "YES", "Y", "y","yues", "yeah", "sure", "yea", "ok", "okay", "fine", "cool", "alright", "yup", "yep", "ya", "ye"]
|
|
|
|
| 36 |
def add_spaces_before_newline(input_string):
|
| 37 |
modified_chars = []
|
| 38 |
for char in input_string:
|
|
@@ -51,8 +58,8 @@ def run_query(query):
|
|
| 51 |
answer = agent_executor.invoke(query)
|
| 52 |
return answer["output"]
|
| 53 |
else:
|
| 54 |
-
return """Welcome, I am a SQL chatbot
|
| 55 |
-
|
| 56 |
|
| 57 |
st.title("SQL Chatbot")
|
| 58 |
|
|
|
|
| 25 |
agent_executor = create_sql_agent(llm, db=db, agent_type="openai-tools", verbose=False)
|
| 26 |
|
| 27 |
#sidebar
|
| 28 |
+
st.sidebar.title("Chinook Database Chatbot")
|
| 29 |
+
st.sidebar.write("""Use the chatbox to get information about the Chinook Database. Klick link to view the
|
| 30 |
+
[Database Schema](https://blog.xojo.com/2016/04/13/the-chinook-sample-database/)""")
|
| 31 |
#list of the tables in database
|
| 32 |
tables = db.get_table_names()
|
| 33 |
+
st.sidebar.write("""**Example queries**:
|
| 34 |
+
\n- Get the employees who have the most customers
|
| 35 |
+
\n- Get the artist with the most albums \n- Show me the first 5 rows in the table 'Artist'
|
| 36 |
+
\n- Get the most popular genre based on the number of tracks\n""")
|
| 37 |
+
|
| 38 |
+
st.sidebar.write("**Tables in the database**:")
|
| 39 |
st.sidebar.write(tables)
|
| 40 |
|
| 41 |
yes_list = ["yes","Yes", "yes", "YES", "Y", "y","yues", "yeah", "sure", "yea", "ok", "okay", "fine", "cool", "alright", "yup", "yep", "ya", "ye"]
|
| 42 |
+
|
| 43 |
def add_spaces_before_newline(input_string):
|
| 44 |
modified_chars = []
|
| 45 |
for char in input_string:
|
|
|
|
| 58 |
answer = agent_executor.invoke(query)
|
| 59 |
return answer["output"]
|
| 60 |
else:
|
| 61 |
+
return """Welcome, I am a SQL chatbot that converts natural language into SQL queries.
|
| 62 |
+
If you want the tables and column in the database, answer me with **yes** 😊"""
|
| 63 |
|
| 64 |
st.title("SQL Chatbot")
|
| 65 |
|