Spaces:
Sleeping
Sleeping
Commit
·
e6bdc26
1
Parent(s):
5728361
Update app.py
Browse files
app.py
CHANGED
|
@@ -120,22 +120,21 @@ if submit:
|
|
| 120 |
|
| 121 |
# Display loading message while processing
|
| 122 |
with st.spinner("Analyzing..."):
|
| 123 |
-
st.
|
| 124 |
-
st.caption(input_question)
|
| 125 |
|
| 126 |
st.header("Doctor AI", divider=True)
|
| 127 |
response = get_chatmodel_response(input_question)
|
| 128 |
|
| 129 |
if response is not None:
|
| 130 |
-
#
|
| 131 |
-
st.
|
| 132 |
-
|
|
|
|
| 133 |
# Display assistant response in chat message container
|
| 134 |
st.chat_message("assistant: " + response)
|
| 135 |
-
|
| 136 |
# Add both user input and assistant response to chat history
|
| 137 |
st.session_state.messages.append({"role": "user", "content": input_question})
|
| 138 |
st.session_state.messages.append({"role": "assistant", "content": response})
|
| 139 |
-
|
| 140 |
else:
|
| 141 |
-
st.subheader("Error: Unable to get response. Please try again later.")
|
|
|
|
| 120 |
|
| 121 |
# Display loading message while processing
|
| 122 |
with st.spinner("Analyzing..."):
|
| 123 |
+
st.chat_message(":blue[You]: " + input_question)
|
|
|
|
| 124 |
|
| 125 |
st.header("Doctor AI", divider=True)
|
| 126 |
response = get_chatmodel_response(input_question)
|
| 127 |
|
| 128 |
if response is not None:
|
| 129 |
+
# Initialize messages in session state if not already initialized
|
| 130 |
+
if 'messages' not in st.session_state:
|
| 131 |
+
st.session_state['messages'] = []
|
| 132 |
+
|
| 133 |
# Display assistant response in chat message container
|
| 134 |
st.chat_message("assistant: " + response)
|
| 135 |
+
|
| 136 |
# Add both user input and assistant response to chat history
|
| 137 |
st.session_state.messages.append({"role": "user", "content": input_question})
|
| 138 |
st.session_state.messages.append({"role": "assistant", "content": response})
|
|
|
|
| 139 |
else:
|
| 140 |
+
st.subheader("Error: Unable to get response. Please try again later.")
|