File size: 4,132 Bytes
52bc1cc
069de45
976fea9
52bc1cc
 
 
 
976fea9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
069de45
cf2e6bf
52bc1cc
 
 
 
 
 
 
 
cf2e6bf
52bc1cc
 
 
 
 
 
976fea9
52bc1cc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
976fea9
52bc1cc
 
 
 
 
 
 
976fea9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cf2e6bf
 
 
976fea9
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
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(
                                    "<h2>There are no graphs to be displayed at the moment. Try asking another question.</h2>",
                                    elem_id="graphs-container"
                                )

                                
    return MainTabPanel(
        chatbot=chatbot,
        textbox=textbox,
        tabs=tabs,
        sources_raw=sources_raw,
        new_figures=new_figures,
        current_graphs=current_graphs,
        examples_hidden=examples_hidden,
        sources_textbox=sources_textbox,
        figures_cards=figures_cards,
        gallery_component=gallery_component,
        config_button=config_button,
        papers_direct_search=papers_direct_search,
        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,
        follow_up_examples= follow_up_examples,
        follow_up_examples_hidden = follow_up_examples_hidden
    )