NavyDevilDoc commited on
Commit
a859b2e
Β·
verified Β·
1 Parent(s): d27c2a1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -11
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
- st.subheader("Reference Documents")
159
- for res in results:
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
- with st.container():
 
 
 
 
 
 
 
 
 
 
 
 
165
  st.markdown(f"""
166
- <div style="border-left: 5px solid {color}; padding: 10px; background-color: #f0f2f6; margin-bottom: 10px; border-radius: 5px;">
167
- <h4 style="margin:0;">πŸ“„ {res['source']}</h4>
168
- <p style="margin:0; font-style: italic; font-size: 0.9em;">"...{res['snippet']}..."</p>
169
- <small>Relevance Score: {score:.2f}</small>
 
 
 
 
 
 
 
 
 
 
 
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)