Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -213,23 +213,17 @@ with tab2:
|
|
213 |
except Exception as e:
|
214 |
st.error(f"Error: {e}")
|
215 |
|
216 |
-
# Render assistant response and
|
217 |
if st.session_state.image_response:
|
218 |
st.markdown("### 🧠 Assistant Response")
|
219 |
st.markdown(st.session_state.image_response, unsafe_allow_html=True)
|
220 |
|
221 |
-
# Extract
|
222 |
url_matches = re.findall(r'Image URL:\s*(https?://[^\s]+)', st.session_state.image_response)
|
223 |
|
224 |
for url in url_matches:
|
225 |
-
st.markdown(f"🔗 [View image directly]({url})")
|
226 |
-
|
227 |
try:
|
228 |
-
|
229 |
-
r.raise_for_status()
|
230 |
-
img = Image.open(BytesIO(r.content))
|
231 |
-
st.image(img, caption=url.split("/")[-1], use_container_width=True)
|
232 |
except Exception as e:
|
233 |
-
st.warning(f"⚠️
|
234 |
st.error(f"🛑 Error: {str(e)}")
|
235 |
-
|
|
|
213 |
except Exception as e:
|
214 |
st.error(f"Error: {e}")
|
215 |
|
216 |
+
# Render assistant response and load each image using the actual URL
|
217 |
if st.session_state.image_response:
|
218 |
st.markdown("### 🧠 Assistant Response")
|
219 |
st.markdown(st.session_state.image_response, unsafe_allow_html=True)
|
220 |
|
221 |
+
# Extract valid GitHub URLs from assistant response
|
222 |
url_matches = re.findall(r'Image URL:\s*(https?://[^\s]+)', st.session_state.image_response)
|
223 |
|
224 |
for url in url_matches:
|
|
|
|
|
225 |
try:
|
226 |
+
st.image(url, caption=url.split("/")[-1], use_container_width=True)
|
|
|
|
|
|
|
227 |
except Exception as e:
|
228 |
+
st.warning(f"⚠️ Could not load image: {url}")
|
229 |
st.error(f"🛑 Error: {str(e)}")
|
|