fix drais display
Browse files- app.py +18 -6
- front/tabs/tab_papers.py +3 -1
- style.css +5 -1
app.py
CHANGED
@@ -16,6 +16,7 @@ from climateqa.engine.talk_to_data.main import ask_vanna
|
|
16 |
|
17 |
from front.tabs import (create_config_modal, create_examples_tab, create_papers_tab, create_figures_tab, create_chat_interface, create_about_tab)
|
18 |
from front.utils import process_figures
|
|
|
19 |
|
20 |
|
21 |
from utils import create_user_id
|
@@ -95,7 +96,7 @@ async def chat_poc(query, history, audience, sources, reports, relevant_content_
|
|
95 |
# Function to update modal visibility
|
96 |
def update_config_modal_visibility(config_open):
|
97 |
new_config_visibility_status = not config_open
|
98 |
-
return
|
99 |
|
100 |
|
101 |
def update_sources_number_display(sources_textbox, figures_cards, current_graphs, papers_html):
|
@@ -143,7 +144,7 @@ def cqa_tab(tab_name):
|
|
143 |
|
144 |
# Papers subtab
|
145 |
with gr.Tab("Papers", elem_id="tab-citations", id=4) as tab_papers:
|
146 |
-
papers_summary, papers_html, citations_network, papers_modal = create_papers_tab()
|
147 |
|
148 |
# Graphs subtab
|
149 |
with gr.Tab("Graphs", elem_id="tab-graphs", id=5) as tab_graphs:
|
@@ -152,9 +153,18 @@ def cqa_tab(tab_name):
|
|
152 |
elem_id="graphs-container"
|
153 |
)
|
154 |
with gr.Tab("DRIAS", elem_id="tab-vanna", id=6) as tab_vanna:
|
155 |
-
|
156 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
157 |
vanna_display = gr.Plot()
|
|
|
158 |
|
159 |
return {
|
160 |
"chatbot": chatbot,
|
@@ -168,6 +178,7 @@ def cqa_tab(tab_name):
|
|
168 |
"figures_cards": figures_cards,
|
169 |
"gallery_component": gallery_component,
|
170 |
"config_button": config_button,
|
|
|
171 |
"papers_html": papers_html,
|
172 |
"citations_network": citations_network,
|
173 |
"papers_summary": papers_summary,
|
@@ -200,6 +211,7 @@ def event_handling(
|
|
200 |
figures_cards = main_tab_components["figures_cards"]
|
201 |
gallery_component = main_tab_components["gallery_component"]
|
202 |
config_button = main_tab_components["config_button"]
|
|
|
203 |
papers_html = main_tab_components["papers_html"]
|
204 |
citations_network = main_tab_components["citations_network"]
|
205 |
papers_summary = main_tab_components["papers_summary"]
|
@@ -278,9 +290,9 @@ def event_handling(
|
|
278 |
component.change(update_sources_number_display, [sources_textbox, figures_cards, current_graphs, papers_html], [tab_recommended_content, tab_sources, tab_figures, tab_graphs, tab_papers])
|
279 |
|
280 |
# Search for papers
|
281 |
-
for component in [textbox, examples_hidden]:
|
282 |
component.submit(find_papers, [component, after, dropdown_external_sources], [papers_html, citations_network, papers_summary])
|
283 |
-
|
284 |
|
285 |
|
286 |
if tab_name == "Beta - POC Adapt'Action":
|
|
|
16 |
|
17 |
from front.tabs import (create_config_modal, create_examples_tab, create_papers_tab, create_figures_tab, create_chat_interface, create_about_tab)
|
18 |
from front.utils import process_figures
|
19 |
+
from gradio_modal import Modal
|
20 |
|
21 |
|
22 |
from utils import create_user_id
|
|
|
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 |
|
101 |
|
102 |
def update_sources_number_display(sources_textbox, figures_cards, current_graphs, papers_html):
|
|
|
144 |
|
145 |
# Papers subtab
|
146 |
with gr.Tab("Papers", elem_id="tab-citations", id=4) as tab_papers:
|
147 |
+
papers_direct_search, papers_summary, papers_html, citations_network, papers_modal = create_papers_tab()
|
148 |
|
149 |
# Graphs subtab
|
150 |
with gr.Tab("Graphs", elem_id="tab-graphs", id=5) as tab_graphs:
|
|
|
153 |
elem_id="graphs-container"
|
154 |
)
|
155 |
with gr.Tab("DRIAS", elem_id="tab-vanna", id=6) as tab_vanna:
|
156 |
+
vanna_direct_question = gr.Textbox(label="Direct Question", placeholder="You can write direct question here",elem_id="direct-question", interactive=True)
|
157 |
+
with gr.Accordion("Details",elem_id = 'vanna-details', open=False) as vanna_details :
|
158 |
+
vanna_sql_query = gr.Textbox(label="SQL Query Used", elem_id="sql-query", interactive=False)
|
159 |
+
show_vanna_table = gr.Button("Show Table", elem_id="show-table")
|
160 |
+
with Modal(visible=False) as vanna_table_modal:
|
161 |
+
vanna_table = gr.DataFrame([], elem_id="vanna-table")
|
162 |
+
close_vanna_modal = gr.Button("Close", elem_id="close-vanna-modal")
|
163 |
+
close_vanna_modal.click(lambda: Modal(visible=False),None, [vanna_table_modal])
|
164 |
+
show_vanna_table.click(lambda: Modal(visible=True),None ,[vanna_table_modal])
|
165 |
+
|
166 |
vanna_display = gr.Plot()
|
167 |
+
vanna_direct_question.submit(ask_vanna, [vanna_direct_question], [vanna_sql_query ,vanna_table, vanna_display])
|
168 |
|
169 |
return {
|
170 |
"chatbot": chatbot,
|
|
|
178 |
"figures_cards": figures_cards,
|
179 |
"gallery_component": gallery_component,
|
180 |
"config_button": config_button,
|
181 |
+
"papers_direct_search" : papers_direct_search,
|
182 |
"papers_html": papers_html,
|
183 |
"citations_network": citations_network,
|
184 |
"papers_summary": papers_summary,
|
|
|
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"]
|
217 |
papers_summary = main_tab_components["papers_summary"]
|
|
|
290 |
component.change(update_sources_number_display, [sources_textbox, figures_cards, current_graphs, papers_html], [tab_recommended_content, tab_sources, tab_figures, tab_graphs, tab_papers])
|
291 |
|
292 |
# Search for papers
|
293 |
+
for component in [textbox, examples_hidden, papers_direct_search]:
|
294 |
component.submit(find_papers, [component, after, dropdown_external_sources], [papers_html, citations_network, papers_summary])
|
295 |
+
|
296 |
|
297 |
|
298 |
if tab_name == "Beta - POC Adapt'Action":
|
front/tabs/tab_papers.py
CHANGED
@@ -3,6 +3,8 @@ from gradio_modal import Modal
|
|
3 |
|
4 |
|
5 |
def create_papers_tab():
|
|
|
|
|
6 |
with gr.Accordion(
|
7 |
visible=True,
|
8 |
elem_id="papers-summary-popup",
|
@@ -32,5 +34,5 @@ def create_papers_tab():
|
|
32 |
papers_modal
|
33 |
)
|
34 |
|
35 |
-
return papers_summary, papers_html, citations_network, papers_modal
|
36 |
|
|
|
3 |
|
4 |
|
5 |
def create_papers_tab():
|
6 |
+
direct_search_textbox = gr.Textbox(label="Direct search for papers", placeholder= "What is climate change ?", elem_id="papers-search")
|
7 |
+
|
8 |
with gr.Accordion(
|
9 |
visible=True,
|
10 |
elem_id="papers-summary-popup",
|
|
|
34 |
papers_modal
|
35 |
)
|
36 |
|
37 |
+
return direct_search_textbox, papers_summary, papers_html, citations_network, papers_modal
|
38 |
|
style.css
CHANGED
@@ -608,9 +608,13 @@ a {
|
|
608 |
|
609 |
#vanna-display {
|
610 |
max-height: 300px;
|
611 |
-
overflow-y:
|
612 |
}
|
613 |
#sql-query{
|
614 |
max-height: 100px;
|
615 |
overflow-y:scroll;
|
616 |
}
|
|
|
|
|
|
|
|
|
|
608 |
|
609 |
#vanna-display {
|
610 |
max-height: 300px;
|
611 |
+
/* overflow-y: scroll; */
|
612 |
}
|
613 |
#sql-query{
|
614 |
max-height: 100px;
|
615 |
overflow-y:scroll;
|
616 |
}
|
617 |
+
#vanna-details{
|
618 |
+
max-height: 500px;
|
619 |
+
overflow-y:scroll;
|
620 |
+
}
|