moazzamdev commited on
Commit
cbbbe04
·
1 Parent(s): a51e165

Update page1.py

Browse files
Files changed (1) hide show
  1. page1.py +5 -3
page1.py CHANGED
@@ -9,6 +9,8 @@ from streamlit_chat import message
9
  import time
10
  import random
11
  def text():
 
 
12
  with st.chat_message("assistant"):
13
  message_placeholder = st.empty()
14
  full_response = ""
@@ -24,10 +26,10 @@ def text():
24
  full_response += chunk + " "
25
  time.sleep(0.5)
26
  # Add a blinking cursor to simulate typing
27
- st.markdown(full_response + "▌")
28
- st.markdown(full_response)
29
  # Add assistant response to chat history
30
- #st.session_state.messages.append({"role": "assistant", "content": full_response})
31
  apiKey = "AIzaSyAXkkcrrUBjPEgj93tZ9azy7zcS1wI1jUA"
32
  msgs = StreamlitChatMessageHistory(key="special_app_key")
33
 
 
9
  import time
10
  import random
11
  def text():
12
+ if 'messages' not in st.session_state:
13
+ st.session_state['messages'] = []
14
  with st.chat_message("assistant"):
15
  message_placeholder = st.empty()
16
  full_response = ""
 
26
  full_response += chunk + " "
27
  time.sleep(0.5)
28
  # Add a blinking cursor to simulate typing
29
+ message_placeholder.markdown(full_response + "▌")
30
+ message_placeholder.markdown(full_response)
31
  # Add assistant response to chat history
32
+ st.session_state.messages.append({"role": "assistant", "content": full_response})
33
  apiKey = "AIzaSyAXkkcrrUBjPEgj93tZ9azy7zcS1wI1jUA"
34
  msgs = StreamlitChatMessageHistory(key="special_app_key")
35