Spaces:
Running
Running
Commit
·
cbbbe04
1
Parent(s):
a51e165
Update page1.py
Browse files
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 |
-
|
| 28 |
-
|
| 29 |
# Add assistant response to chat history
|
| 30 |
-
|
| 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 |
|