Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -82,25 +82,41 @@ with col1:
|
|
| 82 |
|
| 83 |
parsed_response = output_parser.parse(response)
|
| 84 |
save_chat(st.session_state.user_id, user_input, parsed_response)
|
| 85 |
-
chat_history.append(
|
|
|
|
| 86 |
|
| 87 |
# Display Chat History in WhatsApp-style Chat Format
|
| 88 |
st.subheader("Chat")
|
| 89 |
chat_container = st.container()
|
| 90 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
with chat_container:
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
<div style='
|
| 95 |
-
<
|
|
|
|
|
|
|
| 96 |
</div>
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
</div>
|
| 102 |
-
|
| 103 |
-
""", unsafe_allow_html=True)
|
| 104 |
|
| 105 |
with col2:
|
| 106 |
# Clear Chat History Option
|
|
|
|
| 82 |
|
| 83 |
parsed_response = output_parser.parse(response)
|
| 84 |
save_chat(st.session_state.user_id, user_input, parsed_response)
|
| 85 |
+
chat_history.append(HumanMessage(content=user_input))
|
| 86 |
+
chat_history.append(AIMessage(content=parsed_response))
|
| 87 |
|
| 88 |
# Display Chat History in WhatsApp-style Chat Format
|
| 89 |
st.subheader("Chat")
|
| 90 |
chat_container = st.container()
|
| 91 |
+
|
| 92 |
+
for msg in chat_history:
|
| 93 |
+
if isinstance(msg, HumanMessage):
|
| 94 |
+
message = msg.content
|
| 95 |
+
response = ""
|
| 96 |
+
elif isinstance(msg, AIMessage):
|
| 97 |
+
response = msg.content
|
| 98 |
+
message = ""
|
| 99 |
+
else:
|
| 100 |
+
continue
|
| 101 |
+
|
| 102 |
with chat_container:
|
| 103 |
+
if message:
|
| 104 |
+
st.markdown(f"""
|
| 105 |
+
<div style='display: flex; justify-content: flex-end; margin: 5px;'>
|
| 106 |
+
<div style='border-radius: 15px; padding: 10px; background-color: #DCF8C6; max-width: 70%;'>
|
| 107 |
+
<b>You:</b> {message}
|
| 108 |
+
</div>
|
| 109 |
</div>
|
| 110 |
+
""", unsafe_allow_html=True)
|
| 111 |
+
|
| 112 |
+
if response:
|
| 113 |
+
st.markdown(f"""
|
| 114 |
+
<div style='display: flex; justify-content: flex-start; margin: 5px;'>
|
| 115 |
+
<div style='border-radius: 15px; padding: 10px; background-color: #EAEAEA; max-width: 70%;'>
|
| 116 |
+
<b>AI:</b> {response}
|
| 117 |
+
</div>
|
| 118 |
</div>
|
| 119 |
+
""", unsafe_allow_html=True)
|
|
|
|
| 120 |
|
| 121 |
with col2:
|
| 122 |
# Clear Chat History Option
|