import gradio as gr from gradio.helpers import Examples from typing import TypedDict from .chat_interface import create_chat_interface from .tab_examples import create_examples_tab from .tab_papers import create_papers_tab from .tab_figures import create_figures_tab from dataclasses import dataclass @dataclass class MainTabPanel: chatbot: gr.Chatbot textbox: gr.Textbox tabs: gr.Tabs sources_raw: gr.State new_figures: gr.State current_graphs: gr.State examples_hidden: gr.State sources_textbox: gr.HTML figures_cards: gr.HTML gallery_component: gr.Gallery config_button: gr.Button papers_direct_search: gr.TextArea papers_html: gr.HTML citations_network: gr.Plot papers_summary: gr.Textbox tab_recommended_content: gr.Tab tab_sources: gr.Tab tab_figures: gr.Tab tab_graphs: gr.Tab tab_papers: gr.Tab graph_container: gr.HTML follow_up_examples : Examples follow_up_examples_hidden : gr.Textbox def cqa_tab(tab_name): # State variables current_graphs = gr.State([]) with gr.Tab(tab_name): with gr.Row(elem_id="chatbot-row"): # Left column - Chat interface with gr.Column(scale=2): chatbot, textbox, config_button, follow_up_examples, follow_up_examples_hidden = create_chat_interface(tab_name) # Right column - Content panels with gr.Column(scale=2, variant="panel", elem_id="right-panel"): with gr.Tabs(elem_id="right_panel_tab") as tabs: # Examples tab with gr.TabItem("Examples", elem_id="tab-examples", id=0): examples_hidden = create_examples_tab(tab_name) # Sources tab with gr.Tab("Sources", elem_id="tab-sources", id=1) as tab_sources: sources_textbox = gr.HTML(show_label=False, elem_id="sources-textbox") # Recommended content tab with gr.Tab("Recommended content", elem_id="tab-recommended_content", id=2) as tab_recommended_content: with gr.Tabs(elem_id="group-subtabs") as tabs_recommended_content: # Figures subtab with gr.Tab("Figures", elem_id="tab-figures", id=3) as tab_figures: sources_raw, new_figures, used_figures, gallery_component, figures_cards, figure_modal = create_figures_tab() # Papers subtab with gr.Tab("Papers", elem_id="tab-citations", id=4) as tab_papers: papers_direct_search, papers_summary, papers_html, citations_network, papers_modal = create_papers_tab() # Graphs subtab with gr.Tab("Graphs", elem_id="tab-graphs", id=5) as tab_graphs: graphs_container = gr.HTML( "