Spaces:
Running
Running
Commit
·
4689af3
1
Parent(s):
251e913
Update page1.py
Browse files
page1.py
CHANGED
@@ -157,9 +157,9 @@ def text():
|
|
157 |
)
|
158 |
|
159 |
with st.chat_message("assistant"):
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
[
|
164 |
"Hello there! How can I assist you today?",
|
165 |
"Hi, human! Is there anything I can help you with?",
|
@@ -167,11 +167,11 @@ def text():
|
|
167 |
]
|
168 |
)
|
169 |
# Simulate stream of response with milliseconds delay
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
# Add a blinking cursor to simulate typing
|
174 |
-
|
175 |
-
|
176 |
# Add assistant response to chat history
|
177 |
-
|
|
|
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?",
|
|
|
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})
|