File size: 1,041 Bytes
693d949
 
 
 
961c967
693d949
 
 
 
 
 
 
 
1a0f750
693d949
 
 
 
 
 
961c967
693d949
 
 
 
 
 
 
 
 
 
 
1a0f750
 
 
 
693d949
 
 
 
 
 
 
 
 
 
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
import gradio as gr
from main import (
    answer_query, 
    set_keys,
    handle_file
    )

from pydantic import ConfigDict
model_config = ConfigDict(protected_namespaces=())

setting_keys = gr.Interface(
    fn=set_keys,
    inputs=[
        gr.Textbox(label="Enter your CO_API_KEY"),
        gr.Textbox(label="Enter your LLAMA_CLOUD_API_KEY"),
    ],
    outputs=gr.Textbox(label="Status")
)

uploading_files = gr.Interface(
    fn=handle_file,
    inputs=gr.File(
        label="Upload a file",
        file_count="single",
        file_types=["text", ".pdf"],
    ),
    outputs=gr.Textbox(label="Status")
)
    
qa = gr.Interface(
    fn=answer_query,
    inputs=gr.Textbox(label="Enter your question"),
    outputs=[
        gr.Textbox(label="Answer"), 
        gr.Textbox(label="Relevant Nodes"),
    ],
    title="Document Q&A System"
)

demo = gr.TabbedInterface(
    interface_list=[setting_keys, uploading_files, qa],
    tab_names=["Settings",  "Upload File", "Q&A System"]
    )

if __name__ == "__main__":
    demo.launch()