Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -136,13 +136,13 @@ st.caption("Using GPT-4.1, IntFloat-e5-basev2 as Embedding model and Pinecone as
|
|
| 136 |
for msg in st.session_state.messages:
|
| 137 |
with st.chat_message(msg["role"]):
|
| 138 |
st.markdown(msg["content"])
|
| 139 |
-
if "images" in msg and msg["images"]:
|
| 140 |
# Display images in a row
|
| 141 |
-
cols = st.columns(len(msg["images"]))
|
| 142 |
-
for idx, img_b64 in enumerate(msg["images"]):
|
| 143 |
-
with cols[idx]:
|
| 144 |
-
if "," in img_b64: img_b64 = img_b64.split(",")[1]
|
| 145 |
-
st.image(base64.b64decode(img_b64), use_container_width=True)
|
| 146 |
|
| 147 |
# Chat Input
|
| 148 |
if prompt := st.chat_input("Ask about your document..."):
|
|
@@ -167,7 +167,7 @@ if prompt := st.chat_input("Ask about your document..."):
|
|
| 167 |
with st.chat_message("assistant"):
|
| 168 |
with st.spinner("Thinking (retrieving the context)..."):
|
| 169 |
try:
|
| 170 |
-
answer
|
| 171 |
prompt,
|
| 172 |
st.session_state.session_id,
|
| 173 |
st.session_state.bm25,
|
|
@@ -178,20 +178,20 @@ if prompt := st.chat_input("Ask about your document..."):
|
|
| 178 |
st.markdown(answer)
|
| 179 |
|
| 180 |
# Display Images if found
|
| 181 |
-
if images:
|
| 182 |
-
st.write("---")
|
| 183 |
-
st.caption("📸 Retrieved Visual Context:")
|
| 184 |
-
cols = st.columns(min(3, len(images)))
|
| 185 |
-
for idx, img_b64 in enumerate(images[:3]):
|
| 186 |
-
with cols[idx]:
|
| 187 |
-
if "," in img_b64: img_b64 = img_b64.split(",")[1]
|
| 188 |
-
st.image(base64.b64decode(img_b64), use_container_width=True)
|
| 189 |
|
| 190 |
# Save to history
|
| 191 |
st.session_state.messages.append({
|
| 192 |
"role": "assistant",
|
| 193 |
-
"content": answer
|
| 194 |
-
"images": images[:3] if images else []
|
| 195 |
})
|
| 196 |
|
| 197 |
except Exception as e:
|
|
|
|
| 136 |
for msg in st.session_state.messages:
|
| 137 |
with st.chat_message(msg["role"]):
|
| 138 |
st.markdown(msg["content"])
|
| 139 |
+
#if "images" in msg and msg["images"]:
|
| 140 |
# Display images in a row
|
| 141 |
+
#cols = st.columns(len(msg["images"]))
|
| 142 |
+
#for idx, img_b64 in enumerate(msg["images"]):
|
| 143 |
+
#with cols[idx]:
|
| 144 |
+
#if "," in img_b64: img_b64 = img_b64.split(",")[1]
|
| 145 |
+
#st.image(base64.b64decode(img_b64), use_container_width=True)
|
| 146 |
|
| 147 |
# Chat Input
|
| 148 |
if prompt := st.chat_input("Ask about your document..."):
|
|
|
|
| 167 |
with st.chat_message("assistant"):
|
| 168 |
with st.spinner("Thinking (retrieving the context)..."):
|
| 169 |
try:
|
| 170 |
+
answer = run_advanced_rag(
|
| 171 |
prompt,
|
| 172 |
st.session_state.session_id,
|
| 173 |
st.session_state.bm25,
|
|
|
|
| 178 |
st.markdown(answer)
|
| 179 |
|
| 180 |
# Display Images if found
|
| 181 |
+
#if images:
|
| 182 |
+
#st.write("---")
|
| 183 |
+
#st.caption("📸 Retrieved Visual Context:")
|
| 184 |
+
#cols = st.columns(min(3, len(images)))
|
| 185 |
+
#for idx, img_b64 in enumerate(images[:3]):
|
| 186 |
+
#with cols[idx]:
|
| 187 |
+
#if "," in img_b64: img_b64 = img_b64.split(",")[1]
|
| 188 |
+
#st.image(base64.b64decode(img_b64), use_container_width=True)
|
| 189 |
|
| 190 |
# Save to history
|
| 191 |
st.session_state.messages.append({
|
| 192 |
"role": "assistant",
|
| 193 |
+
"content": answer
|
| 194 |
+
#"images": images[:3] if images else []
|
| 195 |
})
|
| 196 |
|
| 197 |
except Exception as e:
|