fix config button trigger
Browse files
app.py
CHANGED
|
@@ -95,6 +95,7 @@ async def chat_poc(query, history, audience, sources, reports, relevant_content_
|
|
| 95 |
|
| 96 |
# Function to update modal visibility
|
| 97 |
def update_config_modal_visibility(config_open):
|
|
|
|
| 98 |
new_config_visibility_status = not config_open
|
| 99 |
return Modal(visible=new_config_visibility_status), new_config_visibility_status
|
| 100 |
|
|
@@ -193,7 +194,17 @@ def cqa_tab(tab_name):
|
|
| 193 |
"vanna_display": vanna_display
|
| 194 |
}
|
| 195 |
|
| 196 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 197 |
|
| 198 |
def event_handling(
|
| 199 |
main_tab_components,
|
|
@@ -210,7 +221,7 @@ def event_handling(
|
|
| 210 |
sources_textbox = main_tab_components["sources_textbox"]
|
| 211 |
figures_cards = main_tab_components["figures_cards"]
|
| 212 |
gallery_component = main_tab_components["gallery_component"]
|
| 213 |
-
config_button = main_tab_components["config_button"]
|
| 214 |
papers_direct_search = main_tab_components["papers_direct_search"]
|
| 215 |
papers_html = main_tab_components["papers_html"]
|
| 216 |
citations_network = main_tab_components["citations_network"]
|
|
@@ -226,8 +237,8 @@ def event_handling(
|
|
| 226 |
vanna_display = main_tab_components["vanna_display"]
|
| 227 |
|
| 228 |
|
| 229 |
-
config_open = config_components["config_open"]
|
| 230 |
-
config_modal = config_components["config_modal"]
|
| 231 |
dropdown_sources = config_components["dropdown_sources"]
|
| 232 |
dropdown_reports = config_components["dropdown_reports"]
|
| 233 |
dropdown_external_sources = config_components["dropdown_external_sources"]
|
|
@@ -236,18 +247,18 @@ def event_handling(
|
|
| 236 |
after = config_components["after"]
|
| 237 |
output_query = config_components["output_query"]
|
| 238 |
output_language = config_components["output_language"]
|
| 239 |
-
close_config_modal = config_components["close_config_modal_button"]
|
| 240 |
|
| 241 |
new_sources_hmtl = gr.State([])
|
| 242 |
ttd_data = gr.State([])
|
| 243 |
|
| 244 |
|
| 245 |
-
for button in [config_button, close_config_modal]:
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
|
| 252 |
if tab_name == "ClimateQ&A":
|
| 253 |
print("chat cqa - message sent")
|
|
@@ -313,6 +324,8 @@ def main_ui():
|
|
| 313 |
event_handling(cqa_components, config_components, tab_name = 'ClimateQ&A')
|
| 314 |
event_handling(local_cqa_components, config_components, tab_name = "Beta - POC Adapt'Action")
|
| 315 |
|
|
|
|
|
|
|
| 316 |
demo.queue()
|
| 317 |
|
| 318 |
return demo
|
|
|
|
| 95 |
|
| 96 |
# Function to update modal visibility
|
| 97 |
def update_config_modal_visibility(config_open):
|
| 98 |
+
print(config_open)
|
| 99 |
new_config_visibility_status = not config_open
|
| 100 |
return Modal(visible=new_config_visibility_status), new_config_visibility_status
|
| 101 |
|
|
|
|
| 194 |
"vanna_display": vanna_display
|
| 195 |
}
|
| 196 |
|
| 197 |
+
def config_event_handling(main_tabs_components : list[dict], config_componenets : dict):
|
| 198 |
+
config_open = config_componenets["config_open"]
|
| 199 |
+
config_modal = config_componenets["config_modal"]
|
| 200 |
+
close_config_modal = config_componenets["close_config_modal_button"]
|
| 201 |
+
|
| 202 |
+
for button in [close_config_modal] + [main_tab_component["config_button"] for main_tab_component in main_tabs_components]:
|
| 203 |
+
button.click(
|
| 204 |
+
fn=update_config_modal_visibility,
|
| 205 |
+
inputs=[config_open],
|
| 206 |
+
outputs=[config_modal, config_open]
|
| 207 |
+
)
|
| 208 |
|
| 209 |
def event_handling(
|
| 210 |
main_tab_components,
|
|
|
|
| 221 |
sources_textbox = main_tab_components["sources_textbox"]
|
| 222 |
figures_cards = main_tab_components["figures_cards"]
|
| 223 |
gallery_component = main_tab_components["gallery_component"]
|
| 224 |
+
# config_button = main_tab_components["config_button"]
|
| 225 |
papers_direct_search = main_tab_components["papers_direct_search"]
|
| 226 |
papers_html = main_tab_components["papers_html"]
|
| 227 |
citations_network = main_tab_components["citations_network"]
|
|
|
|
| 237 |
vanna_display = main_tab_components["vanna_display"]
|
| 238 |
|
| 239 |
|
| 240 |
+
# config_open = config_components["config_open"]
|
| 241 |
+
# config_modal = config_components["config_modal"]
|
| 242 |
dropdown_sources = config_components["dropdown_sources"]
|
| 243 |
dropdown_reports = config_components["dropdown_reports"]
|
| 244 |
dropdown_external_sources = config_components["dropdown_external_sources"]
|
|
|
|
| 247 |
after = config_components["after"]
|
| 248 |
output_query = config_components["output_query"]
|
| 249 |
output_language = config_components["output_language"]
|
| 250 |
+
# close_config_modal = config_components["close_config_modal_button"]
|
| 251 |
|
| 252 |
new_sources_hmtl = gr.State([])
|
| 253 |
ttd_data = gr.State([])
|
| 254 |
|
| 255 |
|
| 256 |
+
# for button in [config_button, close_config_modal]:
|
| 257 |
+
# button.click(
|
| 258 |
+
# fn=update_config_modal_visibility,
|
| 259 |
+
# inputs=[config_open],
|
| 260 |
+
# outputs=[config_modal, config_open]
|
| 261 |
+
# )
|
| 262 |
|
| 263 |
if tab_name == "ClimateQ&A":
|
| 264 |
print("chat cqa - message sent")
|
|
|
|
| 324 |
event_handling(cqa_components, config_components, tab_name = 'ClimateQ&A')
|
| 325 |
event_handling(local_cqa_components, config_components, tab_name = "Beta - POC Adapt'Action")
|
| 326 |
|
| 327 |
+
config_event_handling([cqa_components,local_cqa_components] ,config_components)
|
| 328 |
+
|
| 329 |
demo.queue()
|
| 330 |
|
| 331 |
return demo
|