AskMyPDF / app.py
agoyal496's picture
initial prototype app
f31b8a3
raw
history blame
1.1 kB
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()