Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
@@ -251,16 +251,20 @@ if show_exact_matches:
|
|
251 |
else:
|
252 |
top_results = filtered_lexical_no_dupe[:10]
|
253 |
rag_answer = get_rag_answer(var, top_results)
|
254 |
-
st.markdown("
|
255 |
st.write(rag_answer)
|
256 |
st.divider()
|
257 |
for res in top_results:
|
258 |
metadata = res.payload.get('metadata', {})
|
259 |
if "title" not in metadata:
|
260 |
metadata["title"] = compute_title(metadata)
|
261 |
-
|
|
|
|
|
|
|
|
|
262 |
proj_id = metadata.get('id', 'Unknown')
|
263 |
-
st.markdown(f"#### {
|
264 |
countries = metadata.get('countries')
|
265 |
client_name = metadata.get('client', 'Unknown Client')
|
266 |
start_year = metadata.get('start_year', None)
|
@@ -305,10 +309,14 @@ if show_exact_matches:
|
|
305 |
if resolved_name.upper() != code.upper():
|
306 |
matched_countries.append(resolved_name)
|
307 |
|
308 |
-
# Compute CRS combined value
|
309 |
crs_key = metadata.get("crs_key", "").strip()
|
310 |
crs_value = metadata.get("crs_value", "").strip()
|
311 |
-
|
|
|
|
|
|
|
|
|
312 |
|
313 |
# Build the additional text with original details, then add Sector and contact.
|
314 |
additional_text = (
|
@@ -318,9 +326,9 @@ if show_exact_matches:
|
|
318 |
f"Country: **{', '.join(matched_countries)}**\n"
|
319 |
f"Sector: **{crs_combined}**"
|
320 |
)
|
321 |
-
contact = metadata.get("contact", "").strip()
|
322 |
-
if contact and contact.lower() != "[email protected]":
|
323 |
-
|
324 |
|
325 |
st.markdown(additional_text)
|
326 |
st.divider()
|
@@ -334,7 +342,7 @@ else:
|
|
334 |
else:
|
335 |
top_results = filtered_semantic_no_dupe[:10]
|
336 |
rag_answer = get_rag_answer(var, top_results)
|
337 |
-
st.markdown("
|
338 |
st.write(rag_answer)
|
339 |
st.divider()
|
340 |
st.write(f"Showing **Top 15 Semantic Search results** for query: {var}")
|
@@ -389,7 +397,11 @@ else:
|
|
389 |
# Compute CRS combined value
|
390 |
crs_key = metadata.get("crs_key", "").strip()
|
391 |
crs_value = metadata.get("crs_value", "").strip()
|
392 |
-
|
|
|
|
|
|
|
|
|
393 |
|
394 |
# Build the additional text with original details, then add Sector and contact.
|
395 |
additional_text = (
|
@@ -399,9 +411,9 @@ else:
|
|
399 |
f"Country: **{', '.join(matched_countries)}**\n"
|
400 |
f"Sector: **{crs_combined}**"
|
401 |
)
|
402 |
-
contact = metadata.get("contact", "").strip()
|
403 |
-
if contact and contact.lower() != "[email protected]":
|
404 |
-
|
405 |
|
406 |
st.markdown(additional_text)
|
407 |
st.divider()
|
|
|
251 |
else:
|
252 |
top_results = filtered_lexical_no_dupe[:10]
|
253 |
rag_answer = get_rag_answer(var, top_results)
|
254 |
+
st.markdown(f"**{var}**")
|
255 |
st.write(rag_answer)
|
256 |
st.divider()
|
257 |
for res in top_results:
|
258 |
metadata = res.payload.get('metadata', {})
|
259 |
if "title" not in metadata:
|
260 |
metadata["title"] = compute_title(metadata)
|
261 |
+
# Highlight query in red and bold (allow HTML)
|
262 |
+
display_title = (
|
263 |
+
st.markdown(highlight_query(metadata["title"], var), unsafe_allow_html=True)
|
264 |
+
if var.strip() else metadata["title"]
|
265 |
+
)
|
266 |
proj_id = metadata.get('id', 'Unknown')
|
267 |
+
st.markdown(f"#### {metadata['title']}")
|
268 |
countries = metadata.get('countries')
|
269 |
client_name = metadata.get('client', 'Unknown Client')
|
270 |
start_year = metadata.get('start_year', None)
|
|
|
309 |
if resolved_name.upper() != code.upper():
|
310 |
matched_countries.append(resolved_name)
|
311 |
|
312 |
+
# Compute CRS combined value as integer
|
313 |
crs_key = metadata.get("crs_key", "").strip()
|
314 |
crs_value = metadata.get("crs_value", "").strip()
|
315 |
+
try:
|
316 |
+
crs_int = int(float(crs_value))
|
317 |
+
except:
|
318 |
+
crs_int = crs_value
|
319 |
+
crs_combined = f"{crs_key}: {crs_int}" if (crs_key or crs_value) else "Unknown"
|
320 |
|
321 |
# Build the additional text with original details, then add Sector and contact.
|
322 |
additional_text = (
|
|
|
326 |
f"Country: **{', '.join(matched_countries)}**\n"
|
327 |
f"Sector: **{crs_combined}**"
|
328 |
)
|
329 |
+
#contact = metadata.get("contact", "").strip()
|
330 |
+
#if contact and contact.lower() != "[email protected]":
|
331 |
+
# additional_text += f" | Contact: **{contact}**"
|
332 |
|
333 |
st.markdown(additional_text)
|
334 |
st.divider()
|
|
|
342 |
else:
|
343 |
top_results = filtered_semantic_no_dupe[:10]
|
344 |
rag_answer = get_rag_answer(var, top_results)
|
345 |
+
st.markdown(f"**{var}**")
|
346 |
st.write(rag_answer)
|
347 |
st.divider()
|
348 |
st.write(f"Showing **Top 15 Semantic Search results** for query: {var}")
|
|
|
397 |
# Compute CRS combined value
|
398 |
crs_key = metadata.get("crs_key", "").strip()
|
399 |
crs_value = metadata.get("crs_value", "").strip()
|
400 |
+
try:
|
401 |
+
crs_int = int(float(crs_value))
|
402 |
+
except:
|
403 |
+
crs_int = crs_value
|
404 |
+
crs_combined = f"{crs_key}: {crs_int}" if (crs_key or crs_value) else "Unknown"
|
405 |
|
406 |
# Build the additional text with original details, then add Sector and contact.
|
407 |
additional_text = (
|
|
|
411 |
f"Country: **{', '.join(matched_countries)}**\n"
|
412 |
f"Sector: **{crs_combined}**"
|
413 |
)
|
414 |
+
#contact = metadata.get("contact", "").strip()
|
415 |
+
#if contact and contact.lower() != "[email protected]":
|
416 |
+
# additional_text += f" | Contact: **{contact}**"
|
417 |
|
418 |
st.markdown(additional_text)
|
419 |
st.divider()
|