Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -190,29 +190,33 @@ if not st.session_state.response_ready:
|
|
190 |
st.session_state.response_ready = True
|
191 |
|
192 |
# Show follow-up questions & continue button **only if HAL has responded**
|
193 |
-
if st.
|
194 |
-
|
195 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
|
197 |
-
# Placeholder for the Continue button so it can be refreshed dynamically
|
198 |
-
continue_button_placeholder = st.empty()
|
199 |
-
|
200 |
-
if continue_button_placeholder.button("Continue"):
|
201 |
-
if selected_option:
|
202 |
-
response, _, st.session_state.chat_history, _ = get_response(
|
203 |
-
system_message="You are a helpful AI assistant.",
|
204 |
-
user_text=selected_option,
|
205 |
-
chat_history=st.session_state.chat_history
|
206 |
-
)
|
207 |
-
st.markdown(f"<div class='assistant-msg'><strong>HAL:</strong> {response}</div>", unsafe_allow_html=True)
|
208 |
-
|
209 |
-
# Reset response tracking so "Send" button appears for new input
|
210 |
-
st.session_state.response_ready = False
|
211 |
-
|
212 |
-
# Reset chat and buttons
|
213 |
-
if st.sidebar.button("Reset Chat"):
|
214 |
-
st.session_state.chat_history = [{"role": "assistant", "content": "Hello! How can I assist you today?"}]
|
215 |
-
st.session_state.response_ready = False # Reset so the Send button reappears
|
216 |
-
st.experimental_rerun()
|
217 |
|
218 |
|
|
|
190 |
st.session_state.response_ready = True
|
191 |
|
192 |
# Show follow-up questions & continue button **only if HAL has responded**
|
193 |
+
if st.button("Send"):
|
194 |
+
if user_input:
|
195 |
+
response, follow_up, st.session_state.chat_history, image_url = get_response(
|
196 |
+
system_message="You are a helpful AI assistant.",
|
197 |
+
user_text=user_input,
|
198 |
+
chat_history=st.session_state.chat_history
|
199 |
+
)
|
200 |
+
|
201 |
+
# Display response
|
202 |
+
st.markdown(f"<div class='assistant-msg'><strong>HAL:</strong> {response}</div>", unsafe_allow_html=True)
|
203 |
+
|
204 |
+
# Display NASA image if available
|
205 |
+
if image_url:
|
206 |
+
st.image(image_url, caption="NASA Image of the Day")
|
207 |
+
|
208 |
+
# Follow-up question suggestions
|
209 |
+
follow_up_options = [follow_up, "Explain differently", "Give me an example"]
|
210 |
+
selected_option = st.radio("What would you like to do next?", follow_up_options)
|
211 |
+
|
212 |
+
if st.button("Continue"):
|
213 |
+
if selected_option:
|
214 |
+
response, _, st.session_state.chat_history, _ = get_response(
|
215 |
+
system_message="You are a helpful AI assistant.",
|
216 |
+
user_text=selected_option,
|
217 |
+
chat_history=st.session_state.chat_history
|
218 |
+
)
|
219 |
+
st.markdown(f"<div class='assistant-msg'><strong>HAL:</strong> {response}</div>", unsafe_allow_html=True)
|
220 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
221 |
|
222 |
|