moazzamdev commited on
Commit
251e913
·
1 Parent(s): 146e2e7

Update page1.py

Browse files
Files changed (1) hide show
  1. page1.py +22 -2
page1.py CHANGED
@@ -16,13 +16,13 @@ def text():
16
  [
17
  "Hello👋 there! How can I assist you today?",
18
  "Hi , human! Is there anything I can help you with?",
19
- "Do you need help?"
20
  ]
21
  )
22
  # Simulate stream of response with milliseconds delay
23
  for chunk in assistant_response.split():
24
  full_response += chunk + " "
25
- time.sleep(0.1)
26
  # Add a blinking cursor to simulate typing
27
  message_placeholder.markdown(full_response + "▌")
28
  message_placeholder.markdown(full_response)
@@ -155,3 +155,23 @@ def text():
155
  "content": text_output
156
  }
157
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  [
17
  "Hello👋 there! How can I assist you today?",
18
  "Hi , human! Is there anything I can help you with?",
19
+
20
  ]
21
  )
22
  # Simulate stream of response with milliseconds delay
23
  for chunk in assistant_response.split():
24
  full_response += chunk + " "
25
+ time.sleep(0.5)
26
  # Add a blinking cursor to simulate typing
27
  message_placeholder.markdown(full_response + "▌")
28
  message_placeholder.markdown(full_response)
 
155
  "content": text_output
156
  }
157
  )
158
+
159
+ with st.chat_message("assistant"):
160
+ message_placeholder = st.empty()
161
+ full_response = ""
162
+ assistant_response = random.choice(
163
+ [
164
+ "Hello there! How can I assist you today?",
165
+ "Hi, human! Is there anything I can help you with?",
166
+ "Do you need help?",
167
+ ]
168
+ )
169
+ # Simulate stream of response with milliseconds delay
170
+ for chunk in text_output.split():
171
+ full_response += chunk + " "
172
+ time.sleep(0.05)
173
+ # Add a blinking cursor to simulate typing
174
+ message_placeholder.markdown(full_response + "▌")
175
+ message_placeholder.markdown(full_response)
176
+ # Add assistant response to chat history
177
+ st.session_state.messages.append({"role": "assistant", "content": full_response})