Update app.py
Browse files
app.py
CHANGED
|
@@ -113,7 +113,21 @@ def update_sources_number_display(sources_textbox, figures_cards, current_graphs
|
|
| 113 |
|
| 114 |
return gr.update(label=recommended_content_notif_label), gr.update(label=sources_notif_label), gr.update(label=figures_notif_label), gr.update(label=graphs_notif_label), gr.update(label=papers_notif_label)
|
| 115 |
|
| 116 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
# # UI Layout Components
|
| 118 |
def cqa_tab(tab_name):
|
| 119 |
# State variables
|
|
@@ -153,19 +167,7 @@ def cqa_tab(tab_name):
|
|
| 153 |
"<h2>There are no graphs to be displayed at the moment. Try asking another question.</h2>",
|
| 154 |
elem_id="graphs-container"
|
| 155 |
)
|
| 156 |
-
|
| 157 |
-
vanna_direct_question = gr.Textbox(label="Direct Question", placeholder="You can write direct question here",elem_id="direct-question", interactive=True)
|
| 158 |
-
with gr.Accordion("Details",elem_id = 'vanna-details', open=False) as vanna_details :
|
| 159 |
-
vanna_sql_query = gr.Textbox(label="SQL Query Used", elem_id="sql-query", interactive=False)
|
| 160 |
-
show_vanna_table = gr.Button("Show Table", elem_id="show-table")
|
| 161 |
-
with Modal(visible=False) as vanna_table_modal:
|
| 162 |
-
vanna_table = gr.DataFrame([], elem_id="vanna-table")
|
| 163 |
-
close_vanna_modal = gr.Button("Close", elem_id="close-vanna-modal")
|
| 164 |
-
close_vanna_modal.click(lambda: Modal(visible=False),None, [vanna_table_modal])
|
| 165 |
-
show_vanna_table.click(lambda: Modal(visible=True),None ,[vanna_table_modal])
|
| 166 |
-
|
| 167 |
-
vanna_display = gr.Plot()
|
| 168 |
-
vanna_direct_question.submit(ask_vanna, [vanna_direct_question], [vanna_sql_query ,vanna_table, vanna_display])
|
| 169 |
|
| 170 |
return {
|
| 171 |
"chatbot": chatbot,
|
|
@@ -189,9 +191,9 @@ def cqa_tab(tab_name):
|
|
| 189 |
"tab_graphs": tab_graphs,
|
| 190 |
"tab_papers": tab_papers,
|
| 191 |
"graph_container": graphs_container,
|
| 192 |
-
"vanna_sql_query": vanna_sql_query,
|
| 193 |
-
"vanna_table" : vanna_table,
|
| 194 |
-
"vanna_display": vanna_display
|
| 195 |
}
|
| 196 |
|
| 197 |
def config_event_handling(main_tabs_components : list[dict], config_componenets : dict):
|
|
@@ -232,9 +234,9 @@ def event_handling(
|
|
| 232 |
tab_graphs = main_tab_components["tab_graphs"]
|
| 233 |
tab_papers = main_tab_components["tab_papers"]
|
| 234 |
graphs_container = main_tab_components["graph_container"]
|
| 235 |
-
vanna_sql_query = main_tab_components["vanna_sql_query"]
|
| 236 |
-
vanna_table = main_tab_components["vanna_table"]
|
| 237 |
-
vanna_display = main_tab_components["vanna_display"]
|
| 238 |
|
| 239 |
|
| 240 |
# config_open = config_components["config_open"]
|
|
@@ -317,6 +319,7 @@ def main_ui():
|
|
| 317 |
with gr.Tabs():
|
| 318 |
cqa_components = cqa_tab(tab_name = "ClimateQ&A")
|
| 319 |
local_cqa_components = cqa_tab(tab_name = "Beta - POC Adapt'Action")
|
|
|
|
| 320 |
|
| 321 |
create_about_tab()
|
| 322 |
|
|
|
|
| 113 |
|
| 114 |
return gr.update(label=recommended_content_notif_label), gr.update(label=sources_notif_label), gr.update(label=figures_notif_label), gr.update(label=graphs_notif_label), gr.update(label=papers_notif_label)
|
| 115 |
|
| 116 |
+
def create_drias_tab():
|
| 117 |
+
with gr.Tab("Beta - Talk to DRIAS", elem_id="tab-vanna", id=6) as tab_vanna:
|
| 118 |
+
vanna_direct_question = gr.Textbox(label="Direct Question", placeholder="You can write direct question here",elem_id="direct-question", interactive=True)
|
| 119 |
+
with gr.Accordion("Details",elem_id = 'vanna-details', open=False) as vanna_details :
|
| 120 |
+
vanna_sql_query = gr.Textbox(label="SQL Query Used", elem_id="sql-query", interactive=False)
|
| 121 |
+
show_vanna_table = gr.Button("Show Table", elem_id="show-table")
|
| 122 |
+
with Modal(visible=False) as vanna_table_modal:
|
| 123 |
+
vanna_table = gr.DataFrame([], elem_id="vanna-table")
|
| 124 |
+
close_vanna_modal = gr.Button("Close", elem_id="close-vanna-modal")
|
| 125 |
+
close_vanna_modal.click(lambda: Modal(visible=False),None, [vanna_table_modal])
|
| 126 |
+
show_vanna_table.click(lambda: Modal(visible=True),None ,[vanna_table_modal])
|
| 127 |
+
|
| 128 |
+
vanna_display = gr.Plot()
|
| 129 |
+
vanna_direct_question.submit(ask_vanna, [vanna_direct_question], [vanna_sql_query ,vanna_table, vanna_display])
|
| 130 |
+
|
| 131 |
# # UI Layout Components
|
| 132 |
def cqa_tab(tab_name):
|
| 133 |
# State variables
|
|
|
|
| 167 |
"<h2>There are no graphs to be displayed at the moment. Try asking another question.</h2>",
|
| 168 |
elem_id="graphs-container"
|
| 169 |
)
|
| 170 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 171 |
|
| 172 |
return {
|
| 173 |
"chatbot": chatbot,
|
|
|
|
| 191 |
"tab_graphs": tab_graphs,
|
| 192 |
"tab_papers": tab_papers,
|
| 193 |
"graph_container": graphs_container,
|
| 194 |
+
# "vanna_sql_query": vanna_sql_query,
|
| 195 |
+
# "vanna_table" : vanna_table,
|
| 196 |
+
# "vanna_display": vanna_display
|
| 197 |
}
|
| 198 |
|
| 199 |
def config_event_handling(main_tabs_components : list[dict], config_componenets : dict):
|
|
|
|
| 234 |
tab_graphs = main_tab_components["tab_graphs"]
|
| 235 |
tab_papers = main_tab_components["tab_papers"]
|
| 236 |
graphs_container = main_tab_components["graph_container"]
|
| 237 |
+
# vanna_sql_query = main_tab_components["vanna_sql_query"]
|
| 238 |
+
# vanna_table = main_tab_components["vanna_table"]
|
| 239 |
+
# vanna_display = main_tab_components["vanna_display"]
|
| 240 |
|
| 241 |
|
| 242 |
# config_open = config_components["config_open"]
|
|
|
|
| 319 |
with gr.Tabs():
|
| 320 |
cqa_components = cqa_tab(tab_name = "ClimateQ&A")
|
| 321 |
local_cqa_components = cqa_tab(tab_name = "Beta - POC Adapt'Action")
|
| 322 |
+
create_drias_tab()
|
| 323 |
|
| 324 |
create_about_tab()
|
| 325 |
|