Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -206,9 +206,8 @@ with tab2:
|
|
206 |
response_text = msg.content[0].text.value.strip()
|
207 |
st.session_state.image_response = response_text
|
208 |
|
209 |
-
# โ
|
210 |
-
|
211 |
-
blocks = re.split(r"(?:###\s)?๐ผ๏ธ", response_text)[1:]
|
212 |
results = []
|
213 |
for b in blocks:
|
214 |
lines = b.strip().splitlines()
|
@@ -233,28 +232,22 @@ with tab2:
|
|
233 |
except Exception as e:
|
234 |
st.error(f"โ Assistant Error: {e}")
|
235 |
|
236 |
-
# ๐ผ๏ธ Display
|
237 |
if st.session_state.image_results:
|
238 |
st.markdown("### ๐ผ๏ธ Image Results")
|
239 |
-
for
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
st.markdown(f"**{item.get('title', 'No Title')}**", unsafe_allow_html=True)
|
253 |
-
st.caption(item.get("desc", "")[:160] + "..." if item.get("desc") else "")
|
254 |
-
if st.button("๐ View", key=f"img_{idx}"):
|
255 |
-
st.session_state.image_lightbox = item["url"]
|
256 |
-
|
257 |
-
# ๐ฌ Full Image Lightbox Viewer
|
258 |
if st.session_state.image_lightbox:
|
259 |
st.markdown("### ๐ฌ Full Image View")
|
260 |
try:
|
|
|
206 |
response_text = msg.content[0].text.value.strip()
|
207 |
st.session_state.image_response = response_text
|
208 |
|
209 |
+
# โ
Reliable parser for markdown blocks
|
210 |
+
blocks = response_text.split("### ๐ผ๏ธ")[1:]
|
|
|
211 |
results = []
|
212 |
for b in blocks:
|
213 |
lines = b.strip().splitlines()
|
|
|
232 |
except Exception as e:
|
233 |
st.error(f"โ Assistant Error: {e}")
|
234 |
|
235 |
+
# ๐ผ๏ธ Display images in vertical stack
|
236 |
if st.session_state.image_results:
|
237 |
st.markdown("### ๐ผ๏ธ Image Results")
|
238 |
+
for idx, item in enumerate(st.session_state.image_results):
|
239 |
+
try:
|
240 |
+
img = Image.open(BytesIO(requests.get(item["url"], timeout=10).content))
|
241 |
+
st.image(img, use_container_width=True)
|
242 |
+
except:
|
243 |
+
st.image("https://via.placeholder.com/150?text=Image+Error", use_container_width=True)
|
244 |
+
|
245 |
+
st.markdown(f"**{item.get('title', 'No Title')}**", unsafe_allow_html=True)
|
246 |
+
st.caption(item.get("desc", "")[:200] + "..." if item.get("desc") else "")
|
247 |
+
if st.button("๐ View", key=f"img_{idx}"):
|
248 |
+
st.session_state.image_lightbox = item["url"]
|
249 |
+
|
250 |
+
# ๐ฌ Full image lightbox
|
|
|
|
|
|
|
|
|
|
|
|
|
251 |
if st.session_state.image_lightbox:
|
252 |
st.markdown("### ๐ฌ Full Image View")
|
253 |
try:
|