CCockrum commited on
Commit
6b6006e
·
verified ·
1 Parent(s): 72d8888

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -48
app.py CHANGED
@@ -147,10 +147,7 @@ for message in st.session_state.chat_history:
147
  st.markdown("</div>", unsafe_allow_html=True)
148
 
149
  # --- Single Input Box for Both Initial and Follow-Up Messages ---
150
- user_input = st.chat_input("Type your message here...") # Single input box
151
-
152
- # --- Single Input Box for Both Initial and Follow-Up Messages ---
153
- user_input = st.chat_input("Type your message here...") # Single input box
154
 
155
  if user_input:
156
  response, follow_up, st.session_state.chat_history, image_url = get_response(
@@ -159,22 +156,16 @@ if user_input:
159
  chat_history=st.session_state.chat_history
160
  )
161
 
 
162
  st.markdown(f"<div class='assistant-msg'><strong>HAL:</strong> {response}</div>", unsafe_allow_html=True)
163
 
 
164
  if image_url:
165
  st.image(image_url, caption="NASA Image of the Day")
166
 
167
  # Store follow-up question in session state
168
  st.session_state.follow_up = follow_up
169
- st.session_state.response_ready = True # Ensures response cycle continues
170
-
171
- # Display follow-up question inside chat if available
172
- if st.session_state.response_ready and st.session_state.follow_up:
173
- st.markdown(f"<div class='assistant-msg'><strong>HAL:</strong> {st.session_state.follow_up}</div>", unsafe_allow_html=True)
174
-
175
- # Reset response state so user can type next input
176
- st.session_state.response_ready = False
177
-
178
 
179
  # Display follow-up question inside chat if available
180
  if st.session_state.response_ready and st.session_state.follow_up:
@@ -182,38 +173,3 @@ if st.session_state.response_ready and st.session_state.follow_up:
182
 
183
  # Reset response state so user can type next input
184
  st.session_state.response_ready = False
185
-
186
-
187
- # Conversational Follow-up with "Enter to Send"
188
- if st.session_state.response_ready and st.session_state.follow_up:
189
- st.markdown(f"<div class='assistant-msg'><strong>HAL:</strong> {st.session_state.follow_up}</div>", unsafe_allow_html=True)
190
-
191
- next_input = st.chat_input("HAL is waiting for your response...") # Uses Enter to send
192
-
193
- if next_input:
194
- response, _, st.session_state.chat_history, _ = get_response(
195
- system_message="You are a helpful AI assistant.",
196
- user_text=next_input,
197
- chat_history=st.session_state.chat_history
198
- )
199
- st.markdown(f"<div class='assistant-msg'><strong>HAL:</strong> {response}</div>", unsafe_allow_html=True)
200
-
201
- st.session_state.response_ready = False
202
- st.session_state.follow_up = ""
203
-
204
- # Conversational Follow-up
205
- if st.session_state.response_ready and st.session_state.follow_up:
206
- st.markdown(f"<div class='assistant-msg'><strong>HAL:</strong> {st.session_state.follow_up}</div>", unsafe_allow_html=True)
207
-
208
- next_input = st.text_input("HAL is waiting for your response...")
209
-
210
- if next_input:
211
- response, _, st.session_state.chat_history, _ = get_response(
212
- system_message="You are a helpful AI assistant.",
213
- user_text=next_input,
214
- chat_history=st.session_state.chat_history
215
- )
216
- st.markdown(f"<div class='assistant-msg'><strong>HAL:</strong> {response}</div>", unsafe_allow_html=True)
217
-
218
- st.session_state.response_ready = False
219
- st.session_state.follow_up = ""
 
147
  st.markdown("</div>", unsafe_allow_html=True)
148
 
149
  # --- Single Input Box for Both Initial and Follow-Up Messages ---
150
+ user_input = st.chat_input("Type your message here...") # Only ONE chat_input()
 
 
 
151
 
152
  if user_input:
153
  response, follow_up, st.session_state.chat_history, image_url = get_response(
 
156
  chat_history=st.session_state.chat_history
157
  )
158
 
159
+ # Display HAL's response
160
  st.markdown(f"<div class='assistant-msg'><strong>HAL:</strong> {response}</div>", unsafe_allow_html=True)
161
 
162
+ # Display NASA image if available
163
  if image_url:
164
  st.image(image_url, caption="NASA Image of the Day")
165
 
166
  # Store follow-up question in session state
167
  st.session_state.follow_up = follow_up
168
+ st.session_state.response_ready = True # Enables follow-up response cycle
 
 
 
 
 
 
 
 
169
 
170
  # Display follow-up question inside chat if available
171
  if st.session_state.response_ready and st.session_state.follow_up:
 
173
 
174
  # Reset response state so user can type next input
175
  st.session_state.response_ready = False