Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -219,13 +219,15 @@ with tab2:
|
|
219 |
response_text = msg.content[0].text.value
|
220 |
st.session_state.image_response = response_text
|
221 |
|
|
|
222 |
lines = response_text.splitlines()
|
223 |
image_urls = []
|
224 |
for i, line in enumerate(lines):
|
225 |
-
|
226 |
-
|
|
|
227 |
if not url.startswith("http") and i + 1 < len(lines):
|
228 |
-
next_line = lines[i + 1].strip()
|
229 |
if next_line.startswith("http"):
|
230 |
url = next_line
|
231 |
if url.startswith("http"):
|
@@ -276,4 +278,3 @@ with tab2:
|
|
276 |
if st.button("❌ Close Preview"):
|
277 |
st.session_state.image_lightbox = None
|
278 |
st.rerun()
|
279 |
-
|
|
|
219 |
response_text = msg.content[0].text.value
|
220 |
st.session_state.image_response = response_text
|
221 |
|
222 |
+
# ✅ FIXED: Robustly parse "Image URL" from markdown-formatted response
|
223 |
lines = response_text.splitlines()
|
224 |
image_urls = []
|
225 |
for i, line in enumerate(lines):
|
226 |
+
clean_line = re.sub(r"\*\*", "", line).strip()
|
227 |
+
if "Image URL:" in clean_line:
|
228 |
+
url = clean_line.split("Image URL:")[-1].strip()
|
229 |
if not url.startswith("http") and i + 1 < len(lines):
|
230 |
+
next_line = re.sub(r"\*\*", "", lines[i + 1].strip())
|
231 |
if next_line.startswith("http"):
|
232 |
url = next_line
|
233 |
if url.startswith("http"):
|
|
|
278 |
if st.button("❌ Close Preview"):
|
279 |
st.session_state.image_lightbox = None
|
280 |
st.rerun()
|
|