File size: 3,220 Bytes
52bc1cc
 
 
 
 
 
 
 
 
 
 
 
 
28684d8
52bc1cc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import gradio as gr
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

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 = 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, dropdown_samples, samples = create_examples_tab()

                    # 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_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(
                                    "<h2>There are no graphs to be displayed at the moment. Try asking another question.</h2>",
                                    elem_id="graphs-container"
                                )
    return {
        "chatbot": chatbot,
        "textbox": textbox,
        "tabs": tabs,
        "sources_raw": sources_raw,
        "new_figures": new_figures,
        "current_graphs": current_graphs,
        "examples_hidden": examples_hidden,
        "dropdown_samples": dropdown_samples,
        "samples": samples,
        "sources_textbox": sources_textbox,
        "figures_cards": figures_cards,
        "gallery_component": gallery_component,
        "config_button": config_button,
        "papers_html": papers_html,
        "citations_network": citations_network,
        "papers_summary": papers_summary,
        "tab_recommended_content": tab_recommended_content,
        "tab_sources": tab_sources,
        "tab_figures": tab_figures,
        "tab_graphs": tab_graphs,
        "tab_papers": tab_papers,
        "graph_container": graphs_container
    }