CCockrum commited on
Commit
d0d2726
·
verified ·
1 Parent(s): ba5700e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -148,14 +148,16 @@ if st.sidebar.button("Reset Chat"):
148
  user_input = st.chat_input("Type your message here...")
149
 
150
  if user_input:
 
151
  response, follow_up, st.session_state.chat_history, image_url = get_response(
152
  system_message="You are a helpful AI assistant.",
153
  user_text=user_input,
154
  chat_history=st.session_state.chat_history
155
  )
156
 
157
- # ✅ Replace st.write() with st.markdown() to ensure multi-line responses are fully displayed
158
- st.markdown(f"<div class='assistant-msg'><strong>HAL:</strong> {response}</div>", unsafe_allow_html=True)
 
159
 
160
  if image_url:
161
  st.image(image_url, caption="NASA Image of the Day")
@@ -163,7 +165,7 @@ if user_input:
163
  st.session_state.follow_up = follow_up
164
  st.session_state.response_ready = True
165
 
166
- # Display follow-up question if available
167
  if st.session_state.response_ready and st.session_state.follow_up:
168
  st.markdown(f"<div class='assistant-msg'><strong>HAL:</strong> {st.session_state.follow_up}</div>", unsafe_allow_html=True)
169
  st.session_state.response_ready = False
 
148
  user_input = st.chat_input("Type your message here...")
149
 
150
  if user_input:
151
+ # ✅ Ensure get_response() returns a response
152
  response, follow_up, st.session_state.chat_history, image_url = get_response(
153
  system_message="You are a helpful AI assistant.",
154
  user_text=user_input,
155
  chat_history=st.session_state.chat_history
156
  )
157
 
158
+ # ✅ Ensure response is not empty before calling st.markdown()
159
+ if response:
160
+ st.markdown(f"<div class='assistant-msg'><strong>HAL:</strong> {response}</div>", unsafe_allow_html=True)
161
 
162
  if image_url:
163
  st.image(image_url, caption="NASA Image of the Day")
 
165
  st.session_state.follow_up = follow_up
166
  st.session_state.response_ready = True
167
 
168
+ # Check before displaying follow-up message
169
  if st.session_state.response_ready and st.session_state.follow_up:
170
  st.markdown(f"<div class='assistant-msg'><strong>HAL:</strong> {st.session_state.follow_up}</div>", unsafe_allow_html=True)
171
  st.session_state.response_ready = False