Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -52,24 +52,25 @@ def generate_text(prompt, max_length=50):
|
|
52 |
return tokenizer.decode(outputs[0])
|
53 |
|
54 |
# Gradio Interface
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
def pdf_qa_wrapper(file, question):
|
56 |
return asyncio.run(pdf_qa(file, question))
|
57 |
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
input_file
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
output_text_mistral = gr.Textbox(label="Completed Text - Mistral")
|
70 |
-
complete_text_button = gr.Button("Complete Text")
|
71 |
-
|
72 |
-
pdf_qa_button.click(pdf_qa_wrapper, inputs=[input_file, input_question], outputs=output_text_gemini)
|
73 |
-
complete_text_button.click(generate_text, inputs=input_prompt, outputs=output_text_mistral)
|
74 |
|
75 |
-
|
|
|
52 |
return tokenizer.decode(outputs[0])
|
53 |
|
54 |
# Gradio Interface
|
55 |
+
input_file = gr.File(label="Upload PDF File")
|
56 |
+
input_question = gr.Textbox(label="Ask about the document")
|
57 |
+
output_text_gemini = gr.Textbox(label="Answer - GeminiPro")
|
58 |
+
input_prompt = gr.Textbox(label="Enter prompt for text completion")
|
59 |
+
output_text_mistral = gr.Textbox(label="Completed Text - Mistral")
|
60 |
+
|
61 |
def pdf_qa_wrapper(file, question):
|
62 |
return asyncio.run(pdf_qa(file, question))
|
63 |
|
64 |
+
# Create Gradio Interface
|
65 |
+
iface = gr.Interface(
|
66 |
+
fn=[pdf_qa_wrapper, generate_text],
|
67 |
+
inputs=[
|
68 |
+
[input_file, input_question],
|
69 |
+
input_prompt
|
70 |
+
],
|
71 |
+
outputs=[output_text_gemini, output_text_mistral],
|
72 |
+
title="Combined PDF QA and Text Completion System",
|
73 |
+
description="Upload a PDF file to ask questions about its content, or enter a prompt for text completion."
|
74 |
+
)
|
|
|
|
|
|
|
|
|
|
|
75 |
|
76 |
+
iface.launch()
|