Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -23,16 +23,9 @@ from appStore.region_utils import (
|
|
23 |
# from appStore.tfidf_extraction import extract_top_keywords
|
24 |
|
25 |
# Import helper modules
|
26 |
-
from appStore.rag_utils import
|
27 |
-
|
28 |
-
|
29 |
-
compute_title
|
30 |
-
)
|
31 |
-
from appStore.filter_utils import (
|
32 |
-
parse_budget,
|
33 |
-
filter_results,
|
34 |
-
get_crs_options
|
35 |
-
)
|
36 |
|
37 |
from appStore.crs_utils import lookup_crs_value
|
38 |
|
@@ -278,8 +271,10 @@ else:
|
|
278 |
return value
|
279 |
|
280 |
# --- Reprint Query (Right Aligned with "Query:") ---
|
281 |
-
st.markdown(
|
282 |
-
|
|
|
|
|
283 |
# 3) Display results
|
284 |
# Lexical Search Results Branch
|
285 |
if show_exact_matches:
|
@@ -354,18 +349,22 @@ else:
|
|
354 |
# Insert Predecessor/Successor line if available
|
355 |
predecessor = metadata.get("predecessor_id", "").strip()
|
356 |
successor = metadata.get("successor_id", "").strip()
|
357 |
-
|
358 |
-
if predecessor:
|
359 |
-
extra_line
|
360 |
-
|
361 |
-
|
|
|
|
|
|
|
|
|
362 |
|
363 |
additional_text = (
|
364 |
f"**Objective:** {highlight_query(objective, var)}<br>"
|
365 |
f"**Commissioned by:** {metadata.get('client', 'Unknown Client')}<br>"
|
366 |
f"**Projekt duration:** {start_year_str}-{end_year_str}<br>"
|
367 |
f"**Budget:** Project: <b>{formatted_project_budget}</b>, Total volume: <b>{formatted_total_volume}</b><br>"
|
368 |
-
+
|
369 |
f"<br>**Country:** {country_raw}<br>"
|
370 |
f"**Sector:** {crs_combined}"
|
371 |
)
|
@@ -415,7 +414,11 @@ else:
|
|
415 |
# Bold any numbers in the line
|
416 |
line_bold = re.sub(r'(\d+)', r'<b>\1</b>', line)
|
417 |
bullet_lines.append(f"<li>{line_bold}</li>")
|
418 |
-
formatted_rag_answer =
|
|
|
|
|
|
|
|
|
419 |
st.markdown(formatted_rag_answer, unsafe_allow_html=True)
|
420 |
st.divider()
|
421 |
|
@@ -460,18 +463,22 @@ else:
|
|
460 |
|
461 |
predecessor = metadata.get("predecessor_id", "").strip()
|
462 |
successor = metadata.get("successor_id", "").strip()
|
463 |
-
|
464 |
-
if predecessor:
|
465 |
-
extra_line
|
466 |
-
|
467 |
-
|
|
|
|
|
|
|
|
|
468 |
|
469 |
additional_text = (
|
470 |
f"**Objective:** {metadata.get('objective', '')}<br>"
|
471 |
f"**Commissioned by:** {metadata.get('client', 'Unknown Client')}<br>"
|
472 |
f"**Projekt duration:** {start_year_str}-{end_year_str}<br>"
|
473 |
f"**Budget:** Project: <b>{formatted_project_budget}</b>, Total volume: <b>{formatted_total_volume}</b><br>"
|
474 |
-
+
|
475 |
f"<br>**Country:** {country_raw}<br>"
|
476 |
f"**Sector:** {crs_combined}"
|
477 |
)
|
|
|
23 |
# from appStore.tfidf_extraction import extract_top_keywords
|
24 |
|
25 |
# Import helper modules
|
26 |
+
from appStore.rag_utils import highlight_query, get_rag_answer, compute_title, format_project_id
|
27 |
+
|
28 |
+
from appStore.filter_utils import parse_budget, filter_results, get_crs_options
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
from appStore.crs_utils import lookup_crs_value
|
31 |
|
|
|
271 |
return value
|
272 |
|
273 |
# --- Reprint Query (Right Aligned with "Query:") ---
|
274 |
+
st.markdown(
|
275 |
+
f"<div style='text-align: left; font-size:2.1em; font-style: italic; font-weight: bold;'>Query: {var}</div>",
|
276 |
+
unsafe_allow_html=True
|
277 |
+
)
|
278 |
# 3) Display results
|
279 |
# Lexical Search Results Branch
|
280 |
if show_exact_matches:
|
|
|
349 |
# Insert Predecessor/Successor line if available
|
350 |
predecessor = metadata.get("predecessor_id", "").strip()
|
351 |
successor = metadata.get("successor_id", "").strip()
|
352 |
+
pred_success_ids = ""
|
353 |
+
if predecessor or successor:
|
354 |
+
extra_line = "<br>"
|
355 |
+
parts = []
|
356 |
+
if predecessor:
|
357 |
+
parts.append(f"**Predecessor Project:** {format_project_id(predecessor)}")
|
358 |
+
if successor:
|
359 |
+
parts.append(f"**Successor Project:** {format_project_id(successor)}")
|
360 |
+
pred_success_ids += " | ".join(parts)
|
361 |
|
362 |
additional_text = (
|
363 |
f"**Objective:** {highlight_query(objective, var)}<br>"
|
364 |
f"**Commissioned by:** {metadata.get('client', 'Unknown Client')}<br>"
|
365 |
f"**Projekt duration:** {start_year_str}-{end_year_str}<br>"
|
366 |
f"**Budget:** Project: <b>{formatted_project_budget}</b>, Total volume: <b>{formatted_total_volume}</b><br>"
|
367 |
+
+ pred_success_ids +
|
368 |
f"<br>**Country:** {country_raw}<br>"
|
369 |
f"**Sector:** {crs_combined}"
|
370 |
)
|
|
|
414 |
# Bold any numbers in the line
|
415 |
line_bold = re.sub(r'(\d+)', r'<b>\1</b>', line)
|
416 |
bullet_lines.append(f"<li>{line_bold}</li>")
|
417 |
+
formatted_rag_answer = (
|
418 |
+
"<ul style='text-align: left; list-style-position: inside;'>"
|
419 |
+
+ "".join(bullet_lines)
|
420 |
+
+ "</ul>"
|
421 |
+
)
|
422 |
st.markdown(formatted_rag_answer, unsafe_allow_html=True)
|
423 |
st.divider()
|
424 |
|
|
|
463 |
|
464 |
predecessor = metadata.get("predecessor_id", "").strip()
|
465 |
successor = metadata.get("successor_id", "").strip()
|
466 |
+
pred_success_ids = ""
|
467 |
+
if predecessor or successor:
|
468 |
+
extra_line = "<br>"
|
469 |
+
parts = []
|
470 |
+
if predecessor:
|
471 |
+
parts.append(f"**Predecessor Project:** {format_project_id(predecessor)}")
|
472 |
+
if successor:
|
473 |
+
parts.append(f"**Successor Project:** {format_project_id(successor)}")
|
474 |
+
pred_success_ids += " | ".join(parts)
|
475 |
|
476 |
additional_text = (
|
477 |
f"**Objective:** {metadata.get('objective', '')}<br>"
|
478 |
f"**Commissioned by:** {metadata.get('client', 'Unknown Client')}<br>"
|
479 |
f"**Projekt duration:** {start_year_str}-{end_year_str}<br>"
|
480 |
f"**Budget:** Project: <b>{formatted_project_budget}</b>, Total volume: <b>{formatted_total_volume}</b><br>"
|
481 |
+
+ pred_success_ids +
|
482 |
f"<br>**Country:** {country_raw}<br>"
|
483 |
f"**Sector:** {crs_combined}"
|
484 |
)
|