Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -17,6 +17,9 @@ if "chat_history" not in st.session_state:
|
|
17 |
if "response_ready" not in st.session_state:
|
18 |
st.session_state.response_ready = False # Tracks whether HAL has responded
|
19 |
|
|
|
|
|
|
|
20 |
# --- Set Up Model & API Functions ---
|
21 |
model_id = "mistralai/Mistral-7B-Instruct-v0.3"
|
22 |
|
@@ -99,6 +102,7 @@ st.markdown("🌌 *Ask me about space, NASA, and beyond!*")
|
|
99 |
if st.sidebar.button("Reset Chat"):
|
100 |
st.session_state.chat_history = [{"role": "assistant", "content": "Hello! How can I assist you today?"}]
|
101 |
st.session_state.response_ready = False
|
|
|
102 |
st.experimental_rerun()
|
103 |
|
104 |
# Custom Chat Styling
|
@@ -161,11 +165,13 @@ if not st.session_state.response_ready:
|
|
161 |
if image_url:
|
162 |
st.image(image_url, caption="NASA Image of the Day")
|
163 |
|
|
|
|
|
164 |
st.session_state.response_ready = True # Hide Send button after response
|
165 |
|
166 |
# Conversational Follow-up
|
167 |
-
if st.session_state.response_ready:
|
168 |
-
st.markdown(f"<div class='assistant-msg'><strong>HAL:</strong> {follow_up}</div>", unsafe_allow_html=True)
|
169 |
|
170 |
next_input = st.text_input("HAL is waiting for your response...")
|
171 |
|
@@ -176,4 +182,6 @@ if st.session_state.response_ready:
|
|
176 |
chat_history=st.session_state.chat_history
|
177 |
)
|
178 |
st.markdown(f"<div class='assistant-msg'><strong>HAL:</strong> {response}</div>", unsafe_allow_html=True)
|
179 |
-
|
|
|
|
|
|
17 |
if "response_ready" not in st.session_state:
|
18 |
st.session_state.response_ready = False # Tracks whether HAL has responded
|
19 |
|
20 |
+
if "follow_up" not in st.session_state:
|
21 |
+
st.session_state.follow_up = "" # Stores follow-up question
|
22 |
+
|
23 |
# --- Set Up Model & API Functions ---
|
24 |
model_id = "mistralai/Mistral-7B-Instruct-v0.3"
|
25 |
|
|
|
102 |
if st.sidebar.button("Reset Chat"):
|
103 |
st.session_state.chat_history = [{"role": "assistant", "content": "Hello! How can I assist you today?"}]
|
104 |
st.session_state.response_ready = False
|
105 |
+
st.session_state.follow_up = ""
|
106 |
st.experimental_rerun()
|
107 |
|
108 |
# Custom Chat Styling
|
|
|
165 |
if image_url:
|
166 |
st.image(image_url, caption="NASA Image of the Day")
|
167 |
|
168 |
+
# Store follow-up question
|
169 |
+
st.session_state.follow_up = follow_up
|
170 |
st.session_state.response_ready = True # Hide Send button after response
|
171 |
|
172 |
# Conversational Follow-up
|
173 |
+
if st.session_state.response_ready and st.session_state.follow_up:
|
174 |
+
st.markdown(f"<div class='assistant-msg'><strong>HAL:</strong> {st.session_state.follow_up}</div>", unsafe_allow_html=True)
|
175 |
|
176 |
next_input = st.text_input("HAL is waiting for your response...")
|
177 |
|
|
|
182 |
chat_history=st.session_state.chat_history
|
183 |
)
|
184 |
st.markdown(f"<div class='assistant-msg'><strong>HAL:</strong> {response}</div>", unsafe_allow_html=True)
|
185 |
+
|
186 |
+
st.session_state.response_ready = False
|
187 |
+
st.session_state.follow_up = ""
|