Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -154,18 +154,38 @@ if query:
|
|
| 154 |
with st.expander("π View Source Data used for this summary"):
|
| 155 |
st.text(full_doc_text[:2000] + "...")
|
| 156 |
|
| 157 |
-
# --- SEARCH RESULTS SECTION ---
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
score = res['score']
|
| 161 |
-
# Dynamic color coding based on relevance
|
| 162 |
-
color = "#09ab3b" if score > 2 else "#ffbd45" if score > 0 else "#ff4b4b"
|
| 163 |
|
| 164 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
st.markdown(f"""
|
| 166 |
-
<div style="
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
</div>
|
| 171 |
""", unsafe_allow_html=True)
|
|
|
|
| 154 |
with st.expander("π View Source Data used for this summary"):
|
| 155 |
st.text(full_doc_text[:2000] + "...")
|
| 156 |
|
| 157 |
+
# --- SEARCH RESULTS SECTION (Updated) ---
|
| 158 |
+
# We wrap the results in an expander to keep the UI clean
|
| 159 |
+
with st.expander("π Reference Documents (Click to view)", expanded=False):
|
|
|
|
|
|
|
|
|
|
| 160 |
|
| 161 |
+
if not results:
|
| 162 |
+
st.info("No matching documents found.")
|
| 163 |
+
|
| 164 |
+
for res in results:
|
| 165 |
+
score = res['score']
|
| 166 |
+
# Dynamic color coding based on relevance
|
| 167 |
+
color = "#09ab3b" if score > 2 else "#ffbd45" if score > 0 else "#ff4b4b"
|
| 168 |
+
|
| 169 |
+
# CSS FIX:
|
| 170 |
+
# 1. We kept 'background-color: #f0f2f6' (Light Gray)
|
| 171 |
+
# 2. We ADDED 'color: #1f1f1f' (Dark Gray) to force readability
|
| 172 |
+
# regardless of whether the user is in Dark Mode or Light Mode.
|
| 173 |
+
|
| 174 |
st.markdown(f"""
|
| 175 |
+
<div style="
|
| 176 |
+
border-left: 5px solid {color};
|
| 177 |
+
padding: 15px;
|
| 178 |
+
background-color: #f0f2f6;
|
| 179 |
+
margin-bottom: 10px;
|
| 180 |
+
border-radius: 5px;
|
| 181 |
+
color: #1f1f1f;
|
| 182 |
+
">
|
| 183 |
+
<div style="display: flex; justify-content: space-between; align-items: center;">
|
| 184 |
+
<h4 style="margin:0; color: #0e1117;">π {res['source']}</h4>
|
| 185 |
+
<span style="font-size: 0.8em; color: #555; background: #ddd; padding: 2px 6px; border-radius: 4px;">Score: {score:.2f}</span>
|
| 186 |
+
</div>
|
| 187 |
+
<p style="margin: 8px 0; font-style: italic; font-size: 0.95em; color: #333; line-height: 1.5;">
|
| 188 |
+
"...{res['snippet']}..."
|
| 189 |
+
</p>
|
| 190 |
</div>
|
| 191 |
""", unsafe_allow_html=True)
|