Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -227,10 +227,19 @@ with tab2:
|
|
227 |
if msg.role == "assistant":
|
228 |
content = msg.content[0].text.value
|
229 |
st.session_state.tech_messages.append({"role": "assistant", "content": content})
|
|
|
|
|
|
|
|
|
230 |
try:
|
231 |
-
|
232 |
-
|
233 |
-
|
|
|
|
|
|
|
|
|
|
|
234 |
break
|
235 |
except Exception as e:
|
236 |
st.error(f"❌ Technical Assistant Error: {e}")
|
@@ -266,3 +275,4 @@ with tab2:
|
|
266 |
for msg in st.session_state.tech_messages:
|
267 |
with st.chat_message(msg["role"]):
|
268 |
st.markdown(msg["content"], unsafe_allow_html=True)
|
|
|
|
227 |
if msg.role == "assistant":
|
228 |
content = msg.content[0].text.value
|
229 |
st.session_state.tech_messages.append({"role": "assistant", "content": content})
|
230 |
+
|
231 |
+
# Always clear previous results
|
232 |
+
st.session_state.tech_results = []
|
233 |
+
|
234 |
try:
|
235 |
+
parsed = json.loads(content.strip("`json ").strip())
|
236 |
+
if isinstance(parsed, list):
|
237 |
+
st.session_state.tech_results = parsed
|
238 |
+
else:
|
239 |
+
st.warning("Assistant response was not a valid list of results.")
|
240 |
+
except Exception as parse_error:
|
241 |
+
st.warning("⚠️ Failed to parse assistant response as JSON.")
|
242 |
+
st.code(content, language="markdown")
|
243 |
break
|
244 |
except Exception as e:
|
245 |
st.error(f"❌ Technical Assistant Error: {e}")
|
|
|
275 |
for msg in st.session_state.tech_messages:
|
276 |
with st.chat_message(msg["role"]):
|
277 |
st.markdown(msg["content"], unsafe_allow_html=True)
|
278 |
+
st.info("No drawing results found for the last query. Try rephrasing or narrowing the search.")
|