File size: 1,097 Bytes
f31b8a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr

def process_inputs(api_key, pdf_file, questions):

    # In this placeholder, we'll simply echo the inputs.
    if pdf_file is not None:
        pdf_name = pdf_file.name
    else:
        pdf_name = "No file uploaded"
        
    questions_list = questions.strip().split('\n')
    response = f"API Key: {api_key}\nUploaded PDF: {pdf_name}\nQuestions: {questions_list}"
    return response

with gr.Blocks() as demo:
    gr.Markdown("# AskMYPDF Q&A App")
    gr.Markdown("Enter your OPENAI API key, upload a PDF, and list your questions below.")
    
    api_key_input = gr.Textbox(label="API Key", type="password")
    pdf_input = gr.File(label="Upload PDF", file_types=[".pdf"])
    questions_input = gr.Textbox(label="List of Questions (one per line)", lines=5, placeholder="Question 1\nQuestion 2\n...")

    submit_button = gr.Button("Submit")
    output = gr.Textbox(label="Output")

    submit_button.click(
        fn=process_inputs,
        inputs=[api_key_input, pdf_input, questions_input],
        outputs=output
    )

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