Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,35 +1,35 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
-
from chatbot.conversation import chat_bot
|
| 3 |
-
from chatbot.database import get_chat_history, save_chat
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
# Generate or retrieve session ID
|
| 7 |
-
from config import generate_session_id
|
| 8 |
-
|
| 9 |
-
if "session_id" not in st.session_state:
|
| 10 |
-
st.session_state.session_id = generate_session_id()
|
| 11 |
-
|
| 12 |
-
st.title("AI
|
| 13 |
-
st.write("Ask me anything!")
|
| 14 |
-
|
| 15 |
-
# Display chat history
|
| 16 |
-
history = get_chat_history(st.session_state.session_id)
|
| 17 |
-
for user_msg, bot_resp in history:
|
| 18 |
-
with st.chat_message("user"):
|
| 19 |
-
st.write(user_msg)
|
| 20 |
-
with st.chat_message("assistant"):
|
| 21 |
-
st.write(bot_resp)
|
| 22 |
-
|
| 23 |
-
# User input
|
| 24 |
-
user_input = st.chat_input("Type your message...")
|
| 25 |
-
if user_input:
|
| 26 |
-
response, session_id = chat_bot(user_input, st.session_state.session_id)
|
| 27 |
-
|
| 28 |
-
# Display messages in chat
|
| 29 |
-
with st.chat_message("user"):
|
| 30 |
-
st.write(user_input)
|
| 31 |
-
with st.chat_message("assistant"):
|
| 32 |
-
st.write(response)
|
| 33 |
-
|
| 34 |
-
# Save chat history
|
| 35 |
-
save_chat(session_id, user_input, response)
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from chatbot.conversation import chat_bot
|
| 3 |
+
from chatbot.database import get_chat_history, save_chat
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
# Generate or retrieve session ID
|
| 7 |
+
from config import generate_session_id
|
| 8 |
+
|
| 9 |
+
if "session_id" not in st.session_state:
|
| 10 |
+
st.session_state.session_id = generate_session_id()
|
| 11 |
+
|
| 12 |
+
st.title("DataScience-AI-Mentor")
|
| 13 |
+
st.write("Your AI-powered Data Science Tutor. Ask me anything related to Data Science!")
|
| 14 |
+
|
| 15 |
+
# Display chat history
|
| 16 |
+
history = get_chat_history(st.session_state.session_id)
|
| 17 |
+
for user_msg, bot_resp in history:
|
| 18 |
+
with st.chat_message("user"):
|
| 19 |
+
st.write(user_msg)
|
| 20 |
+
with st.chat_message("assistant"):
|
| 21 |
+
st.write(bot_resp)
|
| 22 |
+
|
| 23 |
+
# User input
|
| 24 |
+
user_input = st.chat_input("Type your message...")
|
| 25 |
+
if user_input:
|
| 26 |
+
response, session_id = chat_bot(user_input, st.session_state.session_id)
|
| 27 |
+
|
| 28 |
+
# Display messages in chat
|
| 29 |
+
with st.chat_message("user"):
|
| 30 |
+
st.write(user_input)
|
| 31 |
+
with st.chat_message("assistant"):
|
| 32 |
+
st.write(response)
|
| 33 |
+
|
| 34 |
+
# Save chat history
|
| 35 |
+
save_chat(session_id, user_input, response)
|