Spaces:
Runtime error
Runtime error
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() |