beryamosta commited on
Commit
759ea9b
·
verified ·
1 Parent(s): ecbcf04

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py CHANGED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ st.title("Metropole ChatBot pour les Signataire !!")
2
+
3
+ # Initialize chat history
4
+ if "messages" not in st.session_state:
5
+ st.session_state.messages = []
6
+
7
+ # Display chat messages from history on app rerun
8
+ for message in st.session_state.messages:
9
+ with st.chat_message(message["role"]):
10
+ st.markdown(message["content"])
11
+
12
+ # Accept user input
13
+ if prompt := st.chat_input("Que pouis-je vous aider"):
14
+ # Add user message to chat history
15
+ st.session_state.messages.append({"role": "user", "content": prompt})
16
+ # Display user message in chat message container
17
+ with st.chat_message("user"):
18
+ st.markdown(prompt)
19
+
20
+ # Display assistant response in chat message container
21
+ with st.chat_message("assistant"):
22
+ response = st.write_stream(response_generator())
23
+ # Add assistant response to chat history
24
+ st.session_state.messages.append({"role": "assistant", "content": response})