Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,9 +2,6 @@ import streamlit as st
|
|
2 |
import os
|
3 |
import time
|
4 |
import re
|
5 |
-
import requests
|
6 |
-
from PIL import Image
|
7 |
-
from io import BytesIO
|
8 |
from openai import OpenAI
|
9 |
|
10 |
# ------------------ Authentication ------------------
|
@@ -141,12 +138,14 @@ with chat_col:
|
|
141 |
else:
|
142 |
st.session_state.messages.append({"role": "assistant", "content": reply})
|
143 |
|
144 |
-
# Extract GitHub image URLs
|
145 |
image_matches = re.findall(
|
146 |
-
r'https://
|
147 |
reply
|
148 |
)
|
149 |
-
|
|
|
|
|
150 |
break
|
151 |
else:
|
152 |
st.error("❌ Assistant failed to respond.")
|
@@ -164,8 +163,6 @@ with image_col:
|
|
164 |
st.markdown("### 🖼️ Slide Previews")
|
165 |
for i, raw_url in enumerate(st.session_state.image_urls):
|
166 |
try:
|
167 |
-
# Optional: Log image URLs for debugging
|
168 |
-
# st.write(f"Image URL {i+1}: {raw_url}")
|
169 |
st.image(raw_url, caption=f"Slide {i + 1}", use_container_width=True)
|
170 |
except Exception as e:
|
171 |
st.error(f"❌ Failed to load image: {e}")
|
|
|
2 |
import os
|
3 |
import time
|
4 |
import re
|
|
|
|
|
|
|
5 |
from openai import OpenAI
|
6 |
|
7 |
# ------------------ Authentication ------------------
|
|
|
138 |
else:
|
139 |
st.session_state.messages.append({"role": "assistant", "content": reply})
|
140 |
|
141 |
+
# Extract GitHub image URLs
|
142 |
image_matches = re.findall(
|
143 |
+
r'https://github\.com/AndrewLORTech/witspathologai/blob/main/[^\s\n]+\.png',
|
144 |
reply
|
145 |
)
|
146 |
+
# Transform to raw.githubusercontent.com URLs
|
147 |
+
raw_urls = [url.replace("github.com", "raw.githubusercontent.com").replace("/blob/", "/") for url in image_matches]
|
148 |
+
st.session_state.image_urls = raw_urls
|
149 |
break
|
150 |
else:
|
151 |
st.error("❌ Assistant failed to respond.")
|
|
|
163 |
st.markdown("### 🖼️ Slide Previews")
|
164 |
for i, raw_url in enumerate(st.session_state.image_urls):
|
165 |
try:
|
|
|
|
|
166 |
st.image(raw_url, caption=f"Slide {i + 1}", use_container_width=True)
|
167 |
except Exception as e:
|
168 |
st.error(f"❌ Failed to load image: {e}")
|