annikwag commited on
Commit
4ec0c95
·
verified ·
1 Parent(s): 9d9ace2

Update app.py

Browse files

Adjust results formatting

Files changed (1) hide show
  1. app.py +11 -14
app.py CHANGED
@@ -46,18 +46,16 @@ def get_unique_countries(_client, collection_name):
46
  unique_countries = get_unique_countries(client, collection_name)
47
 
48
  # Layout filters in columns
49
- col1, col2 = st.columns([1, 1])
50
 
51
  with col1:
52
- country_filter = st.selectbox("Filter by Country Code", ["All"] + unique_countries)
53
  with col2:
54
- end_year_range = st.slider("Filter by Project End Year", min_value=2010, max_value=2030, value=(2010, 2030))
55
-
56
 
57
  # Checkbox to control whether to show only exact matches
58
  show_exact_matches = st.checkbox("Show only exact matches", value=False)
59
 
60
-
61
  button=st.button("search")
62
  #found_docs = vectorstore.similarity_search(var)
63
  #print(found_docs)
@@ -89,23 +87,22 @@ if button:
89
  st.write(f"Showing **Top 10 Lexical Search results** for query: {var}")
90
  lexical_results = results[1] # Lexical results are in index 1
91
  filtered_lexical_results = filter_results(lexical_results, country_filter, end_year_range)
92
- for i, res in enumerate(filtered_lexical_results[:10]):
93
- st.markdown(f"#### Result {i+1}")
94
- st.write(res.payload['page_content'])
95
- url = res.payload['metadata'].get('url', '#')
96
  project_name = res.payload['metadata'].get('project_name', 'Project Link')
 
 
 
97
  st.caption(f"**Source:** [{project_name}]({url})")
98
  st.divider()
99
  else:
100
  st.write(f"Showing **Top 10 Semantic Search results** for query: {var}")
101
  semantic_results = results[0] # Semantic results are in index 0
102
  filtered_semantic_results = filter_results(semantic_results, country_filter, end_year_range)
103
- for i, res in enumerate(filtered_semantic_results[:10]):
104
- st.markdown(f"#### Result {i+1}")
105
- st.write(res.payload['page_content'])
106
- url = res.payload['metadata'].get('url', '#')
107
  project_name = res.payload['metadata'].get('project_name', 'Project Link')
108
- st.caption(f"**Source:** [{project_name}]({url})")
 
 
109
  st.divider()
110
 
111
 
 
46
  unique_countries = get_unique_countries(client, collection_name)
47
 
48
  # Layout filters in columns
49
+ col1, col2, col3 = st.columns([1, 1, 4])
50
 
51
  with col1:
52
+ country_filter = st.selectbox("Country Code", ["All"] + unique_countries)
53
  with col2:
54
+ end_year_range = st.slider("Project End Year", min_value=2010, max_value=2030, value=(2010, 2030))
 
55
 
56
  # Checkbox to control whether to show only exact matches
57
  show_exact_matches = st.checkbox("Show only exact matches", value=False)
58
 
 
59
  button=st.button("search")
60
  #found_docs = vectorstore.similarity_search(var)
61
  #print(found_docs)
 
87
  st.write(f"Showing **Top 10 Lexical Search results** for query: {var}")
88
  lexical_results = results[1] # Lexical results are in index 1
89
  filtered_lexical_results = filter_results(lexical_results, country_filter, end_year_range)
90
+ for res in filtered_lexical_results[:10]:
 
 
 
91
  project_name = res.payload['metadata'].get('project_name', 'Project Link')
92
+ url = res.payload['metadata'].get('url', '#')
93
+ st.markdown(f"#### [{project_name}]({url})")
94
+ st.write(res.payload['page_content'])
95
  st.caption(f"**Source:** [{project_name}]({url})")
96
  st.divider()
97
  else:
98
  st.write(f"Showing **Top 10 Semantic Search results** for query: {var}")
99
  semantic_results = results[0] # Semantic results are in index 0
100
  filtered_semantic_results = filter_results(semantic_results, country_filter, end_year_range)
101
+ for res in filtered_semantic_results[:10]:
 
 
 
102
  project_name = res.payload['metadata'].get('project_name', 'Project Link')
103
+ url = res.payload['metadata'].get('url', '#')
104
+ st.markdown(f"#### [{project_name}]({url})")
105
+ st.write(res.payload['page_content'])
106
  st.divider()
107
 
108