agoyal496 commited on
Commit
f31b8a3
·
1 Parent(s): d9af2a5

initial prototype app

Browse files
Files changed (1) hide show
  1. app.py +33 -0
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ def process_inputs(api_key, pdf_file, questions):
4
+
5
+ # In this placeholder, we'll simply echo the inputs.
6
+ if pdf_file is not None:
7
+ pdf_name = pdf_file.name
8
+ else:
9
+ pdf_name = "No file uploaded"
10
+
11
+ questions_list = questions.strip().split('\n')
12
+ response = f"API Key: {api_key}\nUploaded PDF: {pdf_name}\nQuestions: {questions_list}"
13
+ return response
14
+
15
+ with gr.Blocks() as demo:
16
+ gr.Markdown("# AskMYPDF Q&A App")
17
+ gr.Markdown("Enter your OPENAI API key, upload a PDF, and list your questions below.")
18
+
19
+ api_key_input = gr.Textbox(label="API Key", type="password")
20
+ pdf_input = gr.File(label="Upload PDF", file_types=[".pdf"])
21
+ questions_input = gr.Textbox(label="List of Questions (one per line)", lines=5, placeholder="Question 1\nQuestion 2\n...")
22
+
23
+ submit_button = gr.Button("Submit")
24
+ output = gr.Textbox(label="Output")
25
+
26
+ submit_button.click(
27
+ fn=process_inputs,
28
+ inputs=[api_key_input, pdf_input, questions_input],
29
+ outputs=output
30
+ )
31
+
32
+ if __name__ == "__main__":
33
+ demo.launch()