question-answer / app.py
DrDavis's picture
Uptading
8bb76f3
raw
history blame
741 Bytes
import gradio as gr
def answer_doc_question(pdf_file, question):
pdf_text = get_text_from_pdf(pdf_file)
answer = question_answerer(question, pdf_text)
return answer["answer"]
# Add default a file and question, so it's easy to try out the app.
pdf_input = gr.File(
value="https://comptroller.defense.gov/Portals/45/Documents/defbudget/FY2025/FY2025_Budget_Request.pdf"
file_types=[".pdf"],
label="Upload a PDF document and ask a question about it.",
)
question = gr.Textbox(
value="What is the grand total (AC + RC) amount for FY 2025 Request?",
label="Type a question regarding the uploaded document here.",
)
gr.Interface(
fn=answer_doc_question, inputs=[pdf_input, question], outputs="text"
).launch()