Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import streamlit as st
|
2 |
import requests
|
3 |
import pandas as pd
|
|
|
4 |
from appStore.prep_data import process_giz_worldwide, remove_duplicates, get_max_end_year, extract_year
|
5 |
from appStore.prep_utils import create_documents, get_client
|
6 |
from appStore.embed import hybrid_embed_chunks
|
@@ -275,6 +276,13 @@ if show_exact_matches:
|
|
275 |
if top_keywords:
|
276 |
st.markdown(f"_{' 路 '.join(top_keywords)}_")
|
277 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
278 |
try:
|
279 |
c_list = json.loads(metadata.get('countries', "[]").replace("'", '"'))
|
280 |
except json.JSONDecodeError:
|
@@ -286,10 +294,23 @@ if show_exact_matches:
|
|
286 |
if resolved_name.upper() != code.upper():
|
287 |
matched_countries.append(resolved_name)
|
288 |
|
289 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
290 |
contact = metadata.get("contact", "").strip()
|
291 |
if contact and contact.lower() != "[email protected]":
|
292 |
additional_text += f" | Contact: **{contact}**"
|
|
|
293 |
st.markdown(additional_text)
|
294 |
st.divider()
|
295 |
|
@@ -331,6 +352,13 @@ else:
|
|
331 |
if top_keywords:
|
332 |
st.markdown(f"_{' 路 '.join(top_keywords)}_")
|
333 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
334 |
try:
|
335 |
c_list = json.loads(metadata.get('countries', "[]").replace("'", '"'))
|
336 |
except json.JSONDecodeError:
|
@@ -342,12 +370,25 @@ else:
|
|
342 |
if resolved_name.upper() != code.upper():
|
343 |
matched_countries.append(resolved_name)
|
344 |
|
345 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
346 |
contact = metadata.get("contact", "").strip()
|
347 |
if contact and contact.lower() != "[email protected]":
|
348 |
additional_text += f" | Contact: **{contact}**"
|
|
|
349 |
st.markdown(additional_text)
|
350 |
-
st.divider()
|
351 |
# for i in results:
|
352 |
# st.subheader(str(i.metadata['id'])+":"+str(i.metadata['title_main']))
|
353 |
# st.caption(f"Status:{str(i.metadata['status'])}, Country:{str(i.metadata['country_name'])}")
|
|
|
1 |
import streamlit as st
|
2 |
import requests
|
3 |
import pandas as pd
|
4 |
+
import re
|
5 |
from appStore.prep_data import process_giz_worldwide, remove_duplicates, get_max_end_year, extract_year
|
6 |
from appStore.prep_utils import create_documents, get_client
|
7 |
from appStore.embed import hybrid_embed_chunks
|
|
|
276 |
if top_keywords:
|
277 |
st.markdown(f"_{' 路 '.join(top_keywords)}_")
|
278 |
|
279 |
+
# Format year range and budget info
|
280 |
+
start_year_str = extract_year(start_year) if start_year else "Unknown"
|
281 |
+
end_year_str = extract_year(end_year) if end_year else "Unknown"
|
282 |
+
formatted_project_budget = format_currency(total_project)
|
283 |
+
formatted_total_volume = format_currency(total_volume)
|
284 |
+
|
285 |
+
# Compute matched country names (as before)
|
286 |
try:
|
287 |
c_list = json.loads(metadata.get('countries', "[]").replace("'", '"'))
|
288 |
except json.JSONDecodeError:
|
|
|
294 |
if resolved_name.upper() != code.upper():
|
295 |
matched_countries.append(resolved_name)
|
296 |
|
297 |
+
# Compute CRS combined value
|
298 |
+
crs_key = metadata.get("crs_key", "").strip()
|
299 |
+
crs_value = metadata.get("crs_value", "").strip()
|
300 |
+
crs_combined = f"{crs_key}: {crs_value}" if (crs_key or crs_value) else "Unknown"
|
301 |
+
|
302 |
+
# Build the additional text with original details, then add Sector and contact.
|
303 |
+
additional_text = (
|
304 |
+
f"**{', '.join(matched_countries)}**, commissioned by **{client_name}**\n"
|
305 |
+
f"Projekt duration **{start_year_str}-{end_year_str}**\n"
|
306 |
+
f"Budget: Project: **{formatted_project_budget}**, Total volume: **{formatted_total_volume}**\n"
|
307 |
+
f"Country: **{', '.join(matched_countries)}**\n"
|
308 |
+
f"Sector: **{crs_combined}**"
|
309 |
+
)
|
310 |
contact = metadata.get("contact", "").strip()
|
311 |
if contact and contact.lower() != "[email protected]":
|
312 |
additional_text += f" | Contact: **{contact}**"
|
313 |
+
|
314 |
st.markdown(additional_text)
|
315 |
st.divider()
|
316 |
|
|
|
352 |
if top_keywords:
|
353 |
st.markdown(f"_{' 路 '.join(top_keywords)}_")
|
354 |
|
355 |
+
# Format year range and budget info
|
356 |
+
start_year_str = extract_year(start_year) if start_year else "Unknown"
|
357 |
+
end_year_str = extract_year(end_year) if end_year else "Unknown"
|
358 |
+
formatted_project_budget = format_currency(total_project)
|
359 |
+
formatted_total_volume = format_currency(total_volume)
|
360 |
+
|
361 |
+
# Compute matched country names (as before)
|
362 |
try:
|
363 |
c_list = json.loads(metadata.get('countries', "[]").replace("'", '"'))
|
364 |
except json.JSONDecodeError:
|
|
|
370 |
if resolved_name.upper() != code.upper():
|
371 |
matched_countries.append(resolved_name)
|
372 |
|
373 |
+
# Compute CRS combined value
|
374 |
+
crs_key = metadata.get("crs_key", "").strip()
|
375 |
+
crs_value = metadata.get("crs_value", "").strip()
|
376 |
+
crs_combined = f"{crs_key}: {crs_value}" if (crs_key or crs_value) else "Unknown"
|
377 |
+
|
378 |
+
# Build the additional text with original details, then add Sector and contact.
|
379 |
+
additional_text = (
|
380 |
+
f"**{', '.join(matched_countries)}**, commissioned by **{client_name}**\n"
|
381 |
+
f"Projekt duration **{start_year_str}-{end_year_str}**\n"
|
382 |
+
f"Budget: Project: **{formatted_project_budget}**, Total volume: **{formatted_total_volume}**\n"
|
383 |
+
f"Country: **{', '.join(matched_countries)}**\n"
|
384 |
+
f"Sector: **{crs_combined}**"
|
385 |
+
)
|
386 |
contact = metadata.get("contact", "").strip()
|
387 |
if contact and contact.lower() != "[email protected]":
|
388 |
additional_text += f" | Contact: **{contact}**"
|
389 |
+
|
390 |
st.markdown(additional_text)
|
391 |
+
st.divider()
|
392 |
# for i in results:
|
393 |
# st.subheader(str(i.metadata['id'])+":"+str(i.metadata['title_main']))
|
394 |
# st.caption(f"Status:{str(i.metadata['status'])}, Country:{str(i.metadata['country_name'])}")
|