Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,29 +2,30 @@ import streamlit as st
|
|
2 |
import random
|
3 |
import time
|
4 |
|
5 |
-
#_______________________________________________________________________________________________________________________________________________
|
6 |
-
|
7 |
st.title("Metropole ChatBot pour les Signataire !!")
|
|
|
|
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
st.session_state
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
st.
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
st.
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
|
2 |
import random
|
3 |
import time
|
4 |
|
|
|
|
|
5 |
st.title("Metropole ChatBot pour les Signataire !!")
|
6 |
+
#_______________________________________________________________________________________________________________________________________________
|
7 |
+
with st.form("my_form"):
|
8 |
|
9 |
+
|
10 |
+
# Initialize chat history
|
11 |
+
if "messages" not in st.session_state:
|
12 |
+
st.session_state.messages = []
|
13 |
+
|
14 |
+
# Display chat messages from history on app rerun
|
15 |
+
for message in st.session_state.messages:
|
16 |
+
with st.chat_message(message["role"]):
|
17 |
+
st.markdown(message["content"])
|
18 |
+
|
19 |
+
# Accept user input
|
20 |
+
if prompt := st.chat_input("Que pouis-je vous aider"):
|
21 |
+
# Add user message to chat history
|
22 |
+
st.session_state.messages.append({"role": "user", "content": prompt})
|
23 |
+
# Display user message in chat message container
|
24 |
+
with st.chat_message("user"):
|
25 |
+
st.markdown(prompt)
|
26 |
+
|
27 |
+
# Display assistant response in chat message container
|
28 |
+
with st.chat_message("assistant"):
|
29 |
+
response = st.write_stream(prompt_objectif(prompt))
|
30 |
+
# Add assistant response to chat history
|
31 |
+
st.session_state.messages.append({"role": "assistant", "content": response})
|