Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
@@ -94,8 +94,6 @@ with col_about:
|
|
94 |
""", unsafe_allow_html=True
|
95 |
)
|
96 |
|
97 |
-
# Main query input (with a key so we can reset it)
|
98 |
-
var = st.text_input("Enter Question", key="query")
|
99 |
|
100 |
###########################################
|
101 |
# Create or load the embeddings collection
|
@@ -139,13 +137,20 @@ def reset_filters():
|
|
139 |
st.session_state["show_exact_matches"] = False
|
140 |
st.session_state["page"] = 1
|
141 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
###########################################
|
143 |
# Filter Controls - Row 1
|
144 |
###########################################
|
145 |
col1, col2, col3, col4, col5 = st.columns([1, 1, 1, 1, 1])
|
146 |
|
147 |
with col1:
|
148 |
-
region_filter = st.selectbox("Region", ["All/Not allocated"] + sorted(unique_sub_regions), key="region_filter")
|
149 |
if region_filter == "All/Not allocated":
|
150 |
filtered_country_names = unique_country_names
|
151 |
else:
|
@@ -155,7 +160,7 @@ else:
|
|
155 |
]
|
156 |
|
157 |
with col2:
|
158 |
-
country_filter = st.selectbox("Country", ["All/Not allocated"] + filtered_country_names, key="country_filter")
|
159 |
|
160 |
with col3:
|
161 |
current_year = datetime.now().year
|
@@ -165,12 +170,13 @@ with col3:
|
|
165 |
min_value=2010,
|
166 |
max_value=max_end_year,
|
167 |
value=(default_start_year, max_end_year),
|
168 |
-
key="end_year_range"
|
|
|
169 |
)
|
170 |
|
171 |
with col4:
|
172 |
crs_options = ["All/Not allocated"] + get_crs_options(client, collection_name)
|
173 |
-
crs_filter = st.selectbox("CRS", crs_options, key="crs_filter")
|
174 |
|
175 |
with col5:
|
176 |
min_budget = st.slider(
|
@@ -178,7 +184,8 @@ with col5:
|
|
178 |
min_value=min_budget_val,
|
179 |
max_value=max_budget_val,
|
180 |
value=min_budget_val,
|
181 |
-
key="min_budget"
|
|
|
182 |
)
|
183 |
|
184 |
###########################################
|
@@ -205,7 +212,7 @@ with col5_2:
|
|
205 |
col_left, col_right = st.columns([11, 1])
|
206 |
with col_left:
|
207 |
# Place the "Show only exact matches" checkbox here (or any other widgets)
|
208 |
-
show_exact_matches = st.checkbox("Show only exact matches", key="show_exact_matches")
|
209 |
with col_right:
|
210 |
# The reset button will now be in a narrow column on the far right.
|
211 |
with st.container():
|
|
|
94 |
""", unsafe_allow_html=True
|
95 |
)
|
96 |
|
|
|
|
|
97 |
|
98 |
###########################################
|
99 |
# Create or load the embeddings collection
|
|
|
137 |
st.session_state["show_exact_matches"] = False
|
138 |
st.session_state["page"] = 1
|
139 |
|
140 |
+
def reset_page():
|
141 |
+
st.session_state.page = 1
|
142 |
+
|
143 |
+
###########################################
|
144 |
+
# Main query input
|
145 |
+
###########################################
|
146 |
+
var = st.text_input("Enter Question", key="query", on_change=reset_page)
|
147 |
###########################################
|
148 |
# Filter Controls - Row 1
|
149 |
###########################################
|
150 |
col1, col2, col3, col4, col5 = st.columns([1, 1, 1, 1, 1])
|
151 |
|
152 |
with col1:
|
153 |
+
region_filter = st.selectbox("Region", ["All/Not allocated"] + sorted(unique_sub_regions), key="region_filter", on_change=reset_page)
|
154 |
if region_filter == "All/Not allocated":
|
155 |
filtered_country_names = unique_country_names
|
156 |
else:
|
|
|
160 |
]
|
161 |
|
162 |
with col2:
|
163 |
+
country_filter = st.selectbox("Country", ["All/Not allocated"] + filtered_country_names, key="country_filter", on_change=reset_page)
|
164 |
|
165 |
with col3:
|
166 |
current_year = datetime.now().year
|
|
|
170 |
min_value=2010,
|
171 |
max_value=max_end_year,
|
172 |
value=(default_start_year, max_end_year),
|
173 |
+
key="end_year_range",
|
174 |
+
on_change=reset_page
|
175 |
)
|
176 |
|
177 |
with col4:
|
178 |
crs_options = ["All/Not allocated"] + get_crs_options(client, collection_name)
|
179 |
+
crs_filter = st.selectbox("CRS", crs_options, key="crs_filter", on_change=reset_page)
|
180 |
|
181 |
with col5:
|
182 |
min_budget = st.slider(
|
|
|
184 |
min_value=min_budget_val,
|
185 |
max_value=max_budget_val,
|
186 |
value=min_budget_val,
|
187 |
+
key="min_budget",
|
188 |
+
on_change=reset_page
|
189 |
)
|
190 |
|
191 |
###########################################
|
|
|
212 |
col_left, col_right = st.columns([11, 1])
|
213 |
with col_left:
|
214 |
# Place the "Show only exact matches" checkbox here (or any other widgets)
|
215 |
+
show_exact_matches = st.checkbox("Show only exact matches", key="show_exact_matches", on_change=reset_page)
|
216 |
with col_right:
|
217 |
# The reset button will now be in a narrow column on the far right.
|
218 |
with st.container():
|