Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -210,7 +210,7 @@ with tab2:
|
|
210 |
response_text = msg.content[0].text.value
|
211 |
st.session_state.image_response = response_text
|
212 |
|
213 |
-
# ✅
|
214 |
lines = response_text.splitlines()
|
215 |
image_urls = []
|
216 |
expecting_url = False
|
@@ -222,7 +222,7 @@ with tab2:
|
|
222 |
if len(parts) > 1 and parts[1].strip().startswith("http"):
|
223 |
image_urls.append(parts[1].strip())
|
224 |
else:
|
225 |
-
expecting_url = True
|
226 |
elif expecting_url:
|
227 |
if line_clean.startswith("http"):
|
228 |
image_urls.append(line_clean)
|
@@ -242,8 +242,6 @@ with tab2:
|
|
242 |
if st.session_state.image_response:
|
243 |
st.markdown("### 🧠 Assistant Response")
|
244 |
st.markdown(st.session_state.image_response, unsafe_allow_html=True)
|
245 |
-
# Optional: Debug
|
246 |
-
# st.code(st.session_state.image_response, language="markdown")
|
247 |
|
248 |
with image_col:
|
249 |
if st.session_state.image_results:
|
@@ -252,13 +250,12 @@ with tab2:
|
|
252 |
image_url = item.get("image")
|
253 |
if image_url:
|
254 |
try:
|
255 |
-
|
256 |
-
r = requests.get(encoded_url, timeout=10)
|
257 |
r.raise_for_status()
|
258 |
img = Image.open(BytesIO(r.content))
|
259 |
-
st.image(img, caption=
|
260 |
if st.button("🔍 View Full Image", key=f"full_img_{i}"):
|
261 |
-
st.session_state.image_lightbox =
|
262 |
except Exception as e:
|
263 |
st.warning(f"⚠️ Could not load: {image_url}")
|
264 |
st.error(f"{e}")
|
|
|
210 |
response_text = msg.content[0].text.value
|
211 |
st.session_state.image_response = response_text
|
212 |
|
213 |
+
# ✅ Extract Image URLs from assistant markdown
|
214 |
lines = response_text.splitlines()
|
215 |
image_urls = []
|
216 |
expecting_url = False
|
|
|
222 |
if len(parts) > 1 and parts[1].strip().startswith("http"):
|
223 |
image_urls.append(parts[1].strip())
|
224 |
else:
|
225 |
+
expecting_url = True
|
226 |
elif expecting_url:
|
227 |
if line_clean.startswith("http"):
|
228 |
image_urls.append(line_clean)
|
|
|
242 |
if st.session_state.image_response:
|
243 |
st.markdown("### 🧠 Assistant Response")
|
244 |
st.markdown(st.session_state.image_response, unsafe_allow_html=True)
|
|
|
|
|
245 |
|
246 |
with image_col:
|
247 |
if st.session_state.image_results:
|
|
|
250 |
image_url = item.get("image")
|
251 |
if image_url:
|
252 |
try:
|
253 |
+
r = requests.get(image_url, timeout=10) # ✅ Use as-is
|
|
|
254 |
r.raise_for_status()
|
255 |
img = Image.open(BytesIO(r.content))
|
256 |
+
st.image(img, caption=image_url.split("/")[-1], use_container_width=True)
|
257 |
if st.button("🔍 View Full Image", key=f"full_img_{i}"):
|
258 |
+
st.session_state.image_lightbox = image_url
|
259 |
except Exception as e:
|
260 |
st.warning(f"⚠️ Could not load: {image_url}")
|
261 |
st.error(f"{e}")
|