Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -25,7 +25,7 @@ WRITE_ACCESS_TOKEN = st.secrets["Llama_3_1"]
|
|
25 |
|
26 |
def get_rag_answer(query, top_results):
|
27 |
context = "\n\n".join([res.payload["page_content"] for res in top_results])
|
28 |
-
max_context_chars =
|
29 |
if len(context) > max_context_chars:
|
30 |
context = context[:max_context_chars]
|
31 |
prompt = (
|
@@ -183,7 +183,7 @@ country_name_mapping, iso_code_to_sub_region = get_country_name_and_region_mappi
|
|
183 |
unique_country_names = sorted(country_name_mapping.keys())
|
184 |
|
185 |
# Layout filters in columns
|
186 |
-
col1, col2, col3, col4 = st.columns([1, 1, 1,
|
187 |
with col1:
|
188 |
region_filter = st.selectbox("Region", ["All/Not allocated"] + sorted(unique_sub_regions))
|
189 |
# Compute filtered_country_names based on region_filter:
|
@@ -255,7 +255,7 @@ if show_exact_matches:
|
|
255 |
display_title = highlight_query(metadata["title"], var) if var.strip() else metadata["title"]
|
256 |
proj_id = metadata.get('id', 'Unknown')
|
257 |
st.markdown(f"#### {display_title}")
|
258 |
-
countries = metadata.get('countries'
|
259 |
client_name = metadata.get('client', 'Unknown Client')
|
260 |
start_year = metadata.get('start_year', None)
|
261 |
end_year = metadata.get('end_year', None)
|
@@ -306,7 +306,7 @@ if show_exact_matches:
|
|
306 |
|
307 |
# Build the additional text with original details, then add Sector and contact.
|
308 |
additional_text = (
|
309 |
-
f"
|
310 |
f"Projekt duration **{start_year_str}-{end_year_str}**\n"
|
311 |
f"Budget: Project: **{formatted_project_budget}**, Total volume: **{formatted_total_volume}**\n"
|
312 |
f"Country: **{', '.join(matched_countries)}**\n"
|
@@ -338,7 +338,7 @@ else:
|
|
338 |
metadata["title"] = compute_title(metadata)
|
339 |
display_title = metadata["title"]
|
340 |
st.markdown(f"#### {display_title}")
|
341 |
-
countries = metadata.get('countries'
|
342 |
client_name = metadata.get('client', 'Unknown Client')
|
343 |
start_year = metadata.get('start_year', None)
|
344 |
end_year = metadata.get('end_year', None)
|
@@ -387,7 +387,7 @@ else:
|
|
387 |
|
388 |
# Build the additional text with original details, then add Sector and contact.
|
389 |
additional_text = (
|
390 |
-
f"
|
391 |
f"Projekt duration **{start_year_str}-{end_year_str}**\n"
|
392 |
f"Budget: Project: **{formatted_project_budget}**, Total volume: **{formatted_total_volume}**\n"
|
393 |
f"Country: **{', '.join(matched_countries)}**\n"
|
|
|
25 |
|
26 |
def get_rag_answer(query, top_results):
|
27 |
context = "\n\n".join([res.payload["page_content"] for res in top_results])
|
28 |
+
max_context_chars = 13500
|
29 |
if len(context) > max_context_chars:
|
30 |
context = context[:max_context_chars]
|
31 |
prompt = (
|
|
|
183 |
unique_country_names = sorted(country_name_mapping.keys())
|
184 |
|
185 |
# Layout filters in columns
|
186 |
+
col1, col2, col3, col4 = st.columns([1, 1, 1, 1])
|
187 |
with col1:
|
188 |
region_filter = st.selectbox("Region", ["All/Not allocated"] + sorted(unique_sub_regions))
|
189 |
# Compute filtered_country_names based on region_filter:
|
|
|
255 |
display_title = highlight_query(metadata["title"], var) if var.strip() else metadata["title"]
|
256 |
proj_id = metadata.get('id', 'Unknown')
|
257 |
st.markdown(f"#### {display_title}")
|
258 |
+
countries = metadata.get('countries')
|
259 |
client_name = metadata.get('client', 'Unknown Client')
|
260 |
start_year = metadata.get('start_year', None)
|
261 |
end_year = metadata.get('end_year', None)
|
|
|
306 |
|
307 |
# Build the additional text with original details, then add Sector and contact.
|
308 |
additional_text = (
|
309 |
+
f"Commissioned by **{client_name}**\n"
|
310 |
f"Projekt duration **{start_year_str}-{end_year_str}**\n"
|
311 |
f"Budget: Project: **{formatted_project_budget}**, Total volume: **{formatted_total_volume}**\n"
|
312 |
f"Country: **{', '.join(matched_countries)}**\n"
|
|
|
338 |
metadata["title"] = compute_title(metadata)
|
339 |
display_title = metadata["title"]
|
340 |
st.markdown(f"#### {display_title}")
|
341 |
+
countries = metadata.get('countries')
|
342 |
client_name = metadata.get('client', 'Unknown Client')
|
343 |
start_year = metadata.get('start_year', None)
|
344 |
end_year = metadata.get('end_year', None)
|
|
|
387 |
|
388 |
# Build the additional text with original details, then add Sector and contact.
|
389 |
additional_text = (
|
390 |
+
f"Commissioned by **{client_name}**\n"
|
391 |
f"Projekt duration **{start_year_str}-{end_year_str}**\n"
|
392 |
f"Budget: Project: **{formatted_project_budget}**, Total volume: **{formatted_total_volume}**\n"
|
393 |
f"Country: **{', '.join(matched_countries)}**\n"
|