Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -22,7 +22,7 @@ from appStore.region_utils import (
|
|
22 |
# TF-IDF part (excluded from the app for now)
|
23 |
# from appStore.tfidf_extraction import extract_top_keywords
|
24 |
|
25 |
-
# Import
|
26 |
from appStore.rag_utils import (
|
27 |
highlight_query,
|
28 |
get_rag_answer,
|
@@ -34,6 +34,9 @@ from appStore.filter_utils import (
|
|
34 |
get_crs_options
|
35 |
)
|
36 |
|
|
|
|
|
|
|
37 |
###########################################
|
38 |
# Model Config
|
39 |
###########################################
|
@@ -82,7 +85,7 @@ device = 'cuda' if cuda.is_available() else 'cpu'
|
|
82 |
###########################################
|
83 |
col_title, col_about = st.columns([8, 2])
|
84 |
with col_title:
|
85 |
-
st.markdown("<h1 style='text-align:center;'>GIZ Project
|
86 |
with col_about:
|
87 |
with st.expander("ℹ️ About"):
|
88 |
st.markdown(
|
@@ -250,7 +253,7 @@ else:
|
|
250 |
top_results = filtered_lexical_no_dupe[:10]
|
251 |
# RAG answer
|
252 |
rag_answer = get_rag_answer(var, top_results, DEDICATED_ENDPOINT, WRITE_ACCESS_TOKEN)
|
253 |
-
st.markdown(f"<
|
254 |
st.write(rag_answer)
|
255 |
st.divider()
|
256 |
|
@@ -292,6 +295,10 @@ else:
|
|
292 |
formatted_total_volume = format_currency(total_volume)
|
293 |
country_raw = metadata.get('country', "Unknown")
|
294 |
crs_key = metadata.get("crs_key", "").strip()
|
|
|
|
|
|
|
|
|
295 |
|
296 |
# Additional text
|
297 |
additional_text = (
|
@@ -300,7 +307,7 @@ else:
|
|
300 |
f"**Projekt duration:** {start_year_str}-{end_year_str}<br>"
|
301 |
f"**Budget:** Project: {formatted_project_budget}, Total volume: {formatted_total_volume}<br>"
|
302 |
f"**Country:** {country_raw}<br>"
|
303 |
-
f"**Sector:** {
|
304 |
)
|
305 |
contact = metadata.get("contact", "").strip()
|
306 |
if contact and contact.lower() != "[email protected]":
|
@@ -356,6 +363,10 @@ else:
|
|
356 |
formatted_total_volume = format_currency(total_volume)
|
357 |
country_raw = metadata.get('country', "Unknown")
|
358 |
crs_key = metadata.get("crs_key", "").strip()
|
|
|
|
|
|
|
|
|
359 |
|
360 |
additional_text = (
|
361 |
f"**Objective:** {metadata.get('objective', '')}<br>"
|
@@ -363,7 +374,7 @@ else:
|
|
363 |
f"**Projekt duration:** {start_year_str}-{end_year_str}<br>"
|
364 |
f"**Budget:** Project: {formatted_project_budget}, Total volume: {formatted_total_volume}<br>"
|
365 |
f"**Country:** {country_raw}<br>"
|
366 |
-
f"**Sector:** {
|
367 |
)
|
368 |
contact = metadata.get("contact", "").strip()
|
369 |
if contact and contact.lower() != "[email protected]":
|
|
|
22 |
# TF-IDF part (excluded from the app for now)
|
23 |
# from appStore.tfidf_extraction import extract_top_keywords
|
24 |
|
25 |
+
# Import helper modules
|
26 |
from appStore.rag_utils import (
|
27 |
highlight_query,
|
28 |
get_rag_answer,
|
|
|
34 |
get_crs_options
|
35 |
)
|
36 |
|
37 |
+
from appStore.crs_utils import lookup_crs_value
|
38 |
+
|
39 |
+
|
40 |
###########################################
|
41 |
# Model Config
|
42 |
###########################################
|
|
|
85 |
###########################################
|
86 |
col_title, col_about = st.columns([8, 2])
|
87 |
with col_title:
|
88 |
+
st.markdown("<h1 style='text-align:center;'>GIZ Project Search (PROTOTYPE)</h1>", unsafe_allow_html=True)
|
89 |
with col_about:
|
90 |
with st.expander("ℹ️ About"):
|
91 |
st.markdown(
|
|
|
253 |
top_results = filtered_lexical_no_dupe[:10]
|
254 |
# RAG answer
|
255 |
rag_answer = get_rag_answer(var, top_results, DEDICATED_ENDPOINT, WRITE_ACCESS_TOKEN)
|
256 |
+
st.markdown(f"<h3 style='text-align:center; font-size:1.2em; font-style: italic;'>{var}</h3>", unsafe_allow_html=True)
|
257 |
st.write(rag_answer)
|
258 |
st.divider()
|
259 |
|
|
|
295 |
formatted_total_volume = format_currency(total_volume)
|
296 |
country_raw = metadata.get('country', "Unknown")
|
297 |
crs_key = metadata.get("crs_key", "").strip()
|
298 |
+
crs_key_clean = re.sub(r'\.0$', '', str(crs_key))
|
299 |
+
new_crs_value = lookup_crs_value(crs_key_clean)
|
300 |
+
new_crs_value_clean = re.sub(r'\.0$', '', str(new_crs_value))
|
301 |
+
crs_combined = f"{crs_key_clean}: {new_crs_value_clean}" if crs_key_clean else "Unknown"
|
302 |
|
303 |
# Additional text
|
304 |
additional_text = (
|
|
|
307 |
f"**Projekt duration:** {start_year_str}-{end_year_str}<br>"
|
308 |
f"**Budget:** Project: {formatted_project_budget}, Total volume: {formatted_total_volume}<br>"
|
309 |
f"**Country:** {country_raw}<br>"
|
310 |
+
f"**Sector:** {crs_combined}"
|
311 |
)
|
312 |
contact = metadata.get("contact", "").strip()
|
313 |
if contact and contact.lower() != "[email protected]":
|
|
|
363 |
formatted_total_volume = format_currency(total_volume)
|
364 |
country_raw = metadata.get('country', "Unknown")
|
365 |
crs_key = metadata.get("crs_key", "").strip()
|
366 |
+
crs_key_clean = re.sub(r'\.0$', '', str(crs_key))
|
367 |
+
new_crs_value = lookup_crs_value(crs_key_clean)
|
368 |
+
new_crs_value_clean = re.sub(r'\.0$', '', str(new_crs_value))
|
369 |
+
crs_combined = f"{crs_key_clean}: {new_crs_value_clean}" if crs_key_clean else "Unknown"
|
370 |
|
371 |
additional_text = (
|
372 |
f"**Objective:** {metadata.get('objective', '')}<br>"
|
|
|
374 |
f"**Projekt duration:** {start_year_str}-{end_year_str}<br>"
|
375 |
f"**Budget:** Project: {formatted_project_budget}, Total volume: {formatted_total_volume}<br>"
|
376 |
f"**Country:** {country_raw}<br>"
|
377 |
+
f"**Sector:** {crs_combined}"
|
378 |
)
|
379 |
contact = metadata.get("contact", "").strip()
|
380 |
if contact and contact.lower() != "[email protected]":
|