Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -42,7 +42,6 @@ db = SQLDatabase.from_uri(f"sqlite:///{db_loc}")
|
|
| 42 |
# Retrieve the schema information of the database tables
|
| 43 |
database_schema = db.get_table_info()
|
| 44 |
|
| 45 |
-
st.write(database_schema)
|
| 46 |
|
| 47 |
#=================================Logging=====================================#
|
| 48 |
|
|
@@ -395,21 +394,16 @@ def chat_with_agent():
|
|
| 395 |
if 'conversation_history' not in st.session_state:
|
| 396 |
st.session_state.conversation_history = [{"role": "assistant", "content": "Hey, how can I help you?"}]
|
| 397 |
|
| 398 |
-
# Display
|
| 399 |
for message in st.session_state.conversation_history:
|
| 400 |
-
|
| 401 |
-
st.
|
| 402 |
-
|
| 403 |
-
|
| 404 |
-
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
if user_input.lower() == "exit":
|
| 409 |
-
st.write("Chatbot: Thank you for chatting. Goodbye!")
|
| 410 |
-
return
|
| 411 |
-
|
| 412 |
-
# Add user input to conversation history
|
| 413 |
st.session_state.conversation_history.append({"role": "user", "content": user_input})
|
| 414 |
|
| 415 |
conversation_input = "\n".join(
|
|
@@ -423,7 +417,11 @@ def chat_with_agent():
|
|
| 423 |
st.session_state.conversation_history.append({"role": "assistant", "content": chatbot_response})
|
| 424 |
|
| 425 |
# Display the chatbot's response
|
| 426 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 427 |
|
| 428 |
if __name__ == "__main__":
|
| 429 |
chat_with_agent()
|
|
|
|
| 42 |
# Retrieve the schema information of the database tables
|
| 43 |
database_schema = db.get_table_info()
|
| 44 |
|
|
|
|
| 45 |
|
| 46 |
#=================================Logging=====================================#
|
| 47 |
|
|
|
|
| 394 |
if 'conversation_history' not in st.session_state:
|
| 395 |
st.session_state.conversation_history = [{"role": "assistant", "content": "Hey, how can I help you?"}]
|
| 396 |
|
| 397 |
+
# Display chat messages from history on app rerun
|
| 398 |
for message in st.session_state.conversation_history:
|
| 399 |
+
with st.chat_message(message["role"]):
|
| 400 |
+
st.markdown(message["content"])
|
| 401 |
+
|
| 402 |
+
# React to user input
|
| 403 |
+
if user_input := st.chat_input("You: "):
|
| 404 |
+
# Display user message in chat message container
|
| 405 |
+
st.chat_message("user").markdown(user_input)
|
| 406 |
+
# Add user message to conversation history
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 407 |
st.session_state.conversation_history.append({"role": "user", "content": user_input})
|
| 408 |
|
| 409 |
conversation_input = "\n".join(
|
|
|
|
| 417 |
st.session_state.conversation_history.append({"role": "assistant", "content": chatbot_response})
|
| 418 |
|
| 419 |
# Display the chatbot's response
|
| 420 |
+
with st.chat_message("assistant"):
|
| 421 |
+
st.markdown(chatbot_response)
|
| 422 |
+
|
| 423 |
+
if __name__ == "__main__":
|
| 424 |
+
chat_with_agent()
|
| 425 |
|
| 426 |
if __name__ == "__main__":
|
| 427 |
chat_with_agent()
|