Grandediw commited on
Commit
53dbe56
·
1 Parent(s): eb251d5

Add application file

Browse files
Files changed (1) hide show
  1. app.py +24 -2
app.py CHANGED
@@ -1,4 +1,26 @@
1
  import streamlit as st
2
 
3
- x = st.slider('Select a value')
4
- st.write(x, 'squared is', x * x)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
 
3
+ st.title("Echo Bot")
4
+
5
+ # Initialize chat history
6
+ if "messages" not in st.session_state:
7
+ st.session_state.messages = []
8
+
9
+ # Display chat messages from history on app rerun
10
+ for message in st.session_state.messages:
11
+ with st.chat_message(message["role"]):
12
+ st.markdown(message["content"])
13
+
14
+ # React to user input
15
+ if prompt := st.chat_input("What is up?"):
16
+ # Display user message in chat message container
17
+ st.chat_message("user").markdown(prompt)
18
+ # Add user message to chat history
19
+ st.session_state.messages.append({"role": "user", "content": prompt})
20
+
21
+ response = f"Echo: {prompt}"
22
+ # Display assistant response in chat message container
23
+ with st.chat_message("assistant"):
24
+ st.markdown(response)
25
+ # Add assistant response to chat history
26
+ st.session_state.messages.append({"role": "assistant", "content": response})