Spaces:
Runtime error
Runtime error
Commit
·
ef05528
1
Parent(s):
0195449
Update app.py
Browse files
app.py
CHANGED
@@ -43,8 +43,8 @@ chat_container = st.container()
|
|
43 |
# Loop over chat history and display messages
|
44 |
for message in chat_history:
|
45 |
# Get message role and text
|
46 |
-
role = message
|
47 |
-
text = message
|
48 |
|
49 |
# Display message with markdown
|
50 |
chat_container.markdown(f"**{role}:** {text}")
|
@@ -55,20 +55,20 @@ user_input = st.text_input("You")
|
|
55 |
# Check if user input is not empty
|
56 |
if user_input:
|
57 |
# Add user message to chat history
|
58 |
-
chat_history.append(user_input)
|
59 |
|
60 |
# Display user message with markdown
|
61 |
chat_container.markdown(f"**user:** {user_input}")
|
62 |
|
63 |
# Get model response with start_chat method
|
64 |
with st.spinner("Thinking..."):
|
65 |
-
response = model.start_chat(user_input)
|
66 |
|
67 |
# Get response text from response object
|
68 |
-
response_text = response
|
69 |
|
70 |
# Add response message to chat history
|
71 |
-
chat_history.append(response_text)
|
72 |
|
73 |
# Display response message with markdown
|
74 |
chat_container.markdown(f"**assistant:** {response_text}")
|
|
|
43 |
# Loop over chat history and display messages
|
44 |
for message in chat_history:
|
45 |
# Get message role and text
|
46 |
+
role = message['role']
|
47 |
+
text = message['text']
|
48 |
|
49 |
# Display message with markdown
|
50 |
chat_container.markdown(f"**{role}:** {text}")
|
|
|
55 |
# Check if user input is not empty
|
56 |
if user_input:
|
57 |
# Add user message to chat history
|
58 |
+
chat_history.append({'role': 'user', 'text': user_input})
|
59 |
|
60 |
# Display user message with markdown
|
61 |
chat_container.markdown(f"**user:** {user_input}")
|
62 |
|
63 |
# Get model response with start_chat method
|
64 |
with st.spinner("Thinking..."):
|
65 |
+
response = model.start_chat({'user_input': user_input})
|
66 |
|
67 |
# Get response text from response object
|
68 |
+
response_text = response['text']
|
69 |
|
70 |
# Add response message to chat history
|
71 |
+
chat_history.append({'role': 'assistant', 'text': response_text})
|
72 |
|
73 |
# Display response message with markdown
|
74 |
chat_container.markdown(f"**assistant:** {response_text}")
|