add notification on tabs
Browse files
app.py
CHANGED
@@ -455,7 +455,7 @@ with gr.Blocks(title="Climate Q&A", css_paths=os.getcwd()+ "/style.css", theme=t
|
|
455 |
textbox=gr.Textbox(placeholder="Ask me anything here!",show_label=False,scale=7,lines = 1,interactive = True,elem_id="input-textbox")
|
456 |
|
457 |
|
458 |
-
with gr.Column(scale=
|
459 |
|
460 |
|
461 |
with gr.Tabs() as tabs:
|
@@ -486,15 +486,14 @@ with gr.Blocks(title="Climate Q&A", css_paths=os.getcwd()+ "/style.css", theme=t
|
|
486 |
samples.append(group_examples)
|
487 |
|
488 |
|
489 |
-
with gr.Tab("Sources",elem_id = "tab-citations",id = 1):
|
490 |
sources_textbox = gr.HTML(show_label=False, elem_id="sources-textbox")
|
491 |
docs_textbox = gr.State("")
|
492 |
|
493 |
|
494 |
|
495 |
-
|
496 |
# with Modal(visible = False) as config_modal:
|
497 |
-
with gr.Tab("Configuration",elem_id = "tab-config",id = 2):
|
498 |
|
499 |
gr.Markdown("Reminders: You can talk in any language, ClimateQ&A is multi-lingual!")
|
500 |
|
@@ -524,12 +523,19 @@ with gr.Blocks(title="Climate Q&A", css_paths=os.getcwd()+ "/style.css", theme=t
|
|
524 |
output_query = gr.Textbox(label="Query used for retrieval",show_label = True,elem_id = "reformulated-query",lines = 2,interactive = False)
|
525 |
output_language = gr.Textbox(label="Language",show_label = True,elem_id = "language",lines = 1,interactive = False)
|
526 |
|
527 |
-
|
528 |
-
|
529 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
530 |
graphs_container = gr.HTML("<h2>There are no graphs to be displayed at the moment. Try asking another question.</h2>")
|
531 |
current_graphs.change(lambda x : x, inputs=[current_graphs], outputs=[graphs_container])
|
532 |
-
gr.Textbox(current_graphs.value)
|
533 |
|
534 |
# @gr.render(inputs=[current_graphs])
|
535 |
# def display_default_recommended(current_graphs):
|
@@ -564,15 +570,7 @@ with gr.Blocks(title="Climate Q&A", css_paths=os.getcwd()+ "/style.css", theme=t
|
|
564 |
# )
|
565 |
|
566 |
|
567 |
-
with gr.Tab("Figures",elem_id = "tab-figures",id = 3):
|
568 |
-
with Modal(visible=False, elem_id="modal_figure_galery") as modal:
|
569 |
-
gallery_component = gr.Gallery(object_fit='scale-down',elem_id="gallery-component", height="80vh")
|
570 |
-
|
571 |
-
show_full_size_figures = gr.Button("Show figures in full size",elem_id="show-figures",interactive=True)
|
572 |
-
show_full_size_figures.click(lambda : Modal(visible=True),None,modal)
|
573 |
|
574 |
-
figures_cards = gr.HTML(show_label=False, elem_id="sources-figures")
|
575 |
-
|
576 |
|
577 |
|
578 |
|
@@ -683,25 +681,31 @@ with gr.Blocks(title="Climate Q&A", css_paths=os.getcwd()+ "/style.css", theme=t
|
|
683 |
current_state = 1 - current_state
|
684 |
return current_state
|
685 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
686 |
|
687 |
(textbox
|
688 |
.submit(start_chat, [textbox,chatbot], [textbox,tabs,chatbot],queue = False,api_name = "start_chat_textbox")
|
689 |
.then(chat, [textbox,chatbot,dropdown_audience, dropdown_sources,dropdown_reports, current_graphs], [chatbot,sources_textbox,output_query,output_language,gallery_component, figures_cards, current_graphs],concurrency_limit = 8,api_name = "chat_textbox")
|
690 |
.then(finish_chat, None, [textbox,tabs],api_name = "finish_chat_textbox")
|
691 |
-
.then(
|
692 |
-
# .then(lambda graphs : generate_html_graphs(graphs), [current_graphs], [graphs_container],)
|
693 |
-
|
694 |
)
|
695 |
|
696 |
(examples_hidden
|
697 |
-
# .change(start_chat, [examples_hidden,chatbot], [textbox,tabs,chatbot],queue = False,api_name = "start_chat_examples")
|
698 |
-
# .then(chat, [examples_hidden,chatbot,dropdown_audience, dropdown_sources,dropdown_reports,current_graphs], [chatbot,sources_textbox,output_query,output_language,gallery_component, current_graphs],concurrency_limit = 8,api_name = "chat_examples")
|
699 |
-
# .then(finish_chat, None, [textbox,tabs],api_name = "finish_chat_examples")
|
700 |
-
# .then(change_completion_status, [chat_completed_state], [chat_completed_state])
|
701 |
.change(start_chat, [examples_hidden,chatbot], [textbox,tabs,chatbot],queue = False,api_name = "start_chat_examples")
|
702 |
.then(chat, [examples_hidden,chatbot,dropdown_audience, dropdown_sources,dropdown_reports, current_graphs], [chatbot,sources_textbox,output_query,output_language,gallery_component, figures_cards, current_graphs],concurrency_limit = 8,api_name = "chat_examples")
|
703 |
.then(finish_chat, None, [textbox],api_name = "finish_chat_examples")
|
704 |
-
|
705 |
|
706 |
)
|
707 |
|
|
|
455 |
textbox=gr.Textbox(placeholder="Ask me anything here!",show_label=False,scale=7,lines = 1,interactive = True,elem_id="input-textbox")
|
456 |
|
457 |
|
458 |
+
with gr.Column(scale=2, variant="panel",elem_id = "right-panel"):
|
459 |
|
460 |
|
461 |
with gr.Tabs() as tabs:
|
|
|
486 |
samples.append(group_examples)
|
487 |
|
488 |
|
489 |
+
with gr.Tab("Sources",elem_id = "tab-citations",id = 1) as tab_sources:
|
490 |
sources_textbox = gr.HTML(show_label=False, elem_id="sources-textbox")
|
491 |
docs_textbox = gr.State("")
|
492 |
|
493 |
|
494 |
|
|
|
495 |
# with Modal(visible = False) as config_modal:
|
496 |
+
with gr.Tab("Configuration",elem_id = "tab-config",id = 2) as tab_config:
|
497 |
|
498 |
gr.Markdown("Reminders: You can talk in any language, ClimateQ&A is multi-lingual!")
|
499 |
|
|
|
523 |
output_query = gr.Textbox(label="Query used for retrieval",show_label = True,elem_id = "reformulated-query",lines = 2,interactive = False)
|
524 |
output_language = gr.Textbox(label="Language",show_label = True,elem_id = "language",lines = 1,interactive = False)
|
525 |
|
526 |
+
with gr.Tab("Figures",elem_id = "tab-figures",id = 3) as tab_figures:
|
527 |
+
with Modal(visible=False, elem_id="modal_figure_galery") as modal:
|
528 |
+
gallery_component = gr.Gallery(object_fit='scale-down',elem_id="gallery-component", height="80vh")
|
529 |
+
|
530 |
+
show_full_size_figures = gr.Button("Show figures in full size",elem_id="show-figures",interactive=True)
|
531 |
+
show_full_size_figures.click(lambda : Modal(visible=True),None,modal)
|
532 |
+
|
533 |
+
figures_cards = gr.HTML(show_label=False, elem_id="sources-figures")
|
534 |
+
|
535 |
+
|
536 |
+
with gr.Tab("Recommended content", elem_id="tab-recommended_content", id=4) as tab_recommended_content:
|
537 |
graphs_container = gr.HTML("<h2>There are no graphs to be displayed at the moment. Try asking another question.</h2>")
|
538 |
current_graphs.change(lambda x : x, inputs=[current_graphs], outputs=[graphs_container])
|
|
|
539 |
|
540 |
# @gr.render(inputs=[current_graphs])
|
541 |
# def display_default_recommended(current_graphs):
|
|
|
570 |
# )
|
571 |
|
572 |
|
|
|
|
|
|
|
|
|
|
|
|
|
573 |
|
|
|
|
|
574 |
|
575 |
|
576 |
|
|
|
681 |
current_state = 1 - current_state
|
682 |
return current_state
|
683 |
|
684 |
+
def update_sources_number_display(sources_textbox, figures_cards, current_graphs):
|
685 |
+
sources_number = sources_textbox.count("<h2>")
|
686 |
+
figures_number = figures_cards.count("<h2>")
|
687 |
+
graphs_number = current_graphs.count("<iframe")
|
688 |
+
sources_notif_label = f"Sources ({sources_number})"
|
689 |
+
figures_notif_label = f"Figures ({figures_number})"
|
690 |
+
graphs_notif_label = f"Recommended content ({graphs_number})"
|
691 |
+
# sources_notif_label = f"Sources (π)"
|
692 |
+
# figures_notif_label = f"Figures (π)"
|
693 |
+
# graphs_notif_label = f"Recommended content (π)"
|
694 |
+
|
695 |
+
return gr.update(label = sources_notif_label), gr.update(label = figures_notif_label), gr.update(label = graphs_notif_label)
|
696 |
|
697 |
(textbox
|
698 |
.submit(start_chat, [textbox,chatbot], [textbox,tabs,chatbot],queue = False,api_name = "start_chat_textbox")
|
699 |
.then(chat, [textbox,chatbot,dropdown_audience, dropdown_sources,dropdown_reports, current_graphs], [chatbot,sources_textbox,output_query,output_language,gallery_component, figures_cards, current_graphs],concurrency_limit = 8,api_name = "chat_textbox")
|
700 |
.then(finish_chat, None, [textbox,tabs],api_name = "finish_chat_textbox")
|
701 |
+
.then(update_sources_number_display, [sources_textbox, figures_cards, current_graphs],[tab_sources, tab_figures, tab_recommended_content] )
|
|
|
|
|
702 |
)
|
703 |
|
704 |
(examples_hidden
|
|
|
|
|
|
|
|
|
705 |
.change(start_chat, [examples_hidden,chatbot], [textbox,tabs,chatbot],queue = False,api_name = "start_chat_examples")
|
706 |
.then(chat, [examples_hidden,chatbot,dropdown_audience, dropdown_sources,dropdown_reports, current_graphs], [chatbot,sources_textbox,output_query,output_language,gallery_component, figures_cards, current_graphs],concurrency_limit = 8,api_name = "chat_examples")
|
707 |
.then(finish_chat, None, [textbox],api_name = "finish_chat_examples")
|
708 |
+
.then(update_sources_number_display, [sources_textbox, figures_cards, current_graphs],[tab_sources, tab_figures, tab_recommended_content] )
|
709 |
|
710 |
)
|
711 |
|