File size: 802 Bytes
bec0737
536d66f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import gradio as gr
from utils import ques_csv, ques_pdf

def ask_ques(model_input, file_path, selection):
    if selection == 'csv':
        ans = ques_csv(file_path, model_input)
    elif selection == 'pdf':
        ans = ques_pdf(file_path,model_input)
        
    return ans

with gr.Blocks() as demo:
    selection = gr.Radio(["csv", "pdf"], label="File Format", info="Select the file format you want to upload.")
    uploaded_file = gr.File(file_types=[".pdf", ".csv"], file_count="single")              
    question = gr.Textbox( label="Your Question:", placeholder="What's your question?", interactive=True)
    ask_button = gr.Button("Ask")
    output = gr.Textbox(label="Output")
    ask_button.click(ask_ques, inputs = [question, uploaded_file, selection], outputs = output)

demo.launch()