Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -52,25 +52,24 @@ def generate_text(prompt, max_length=50):
|
|
| 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 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
|
| 76 |
-
|
|
|
|
| 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 |
+
with gr.Blocks() as demo:
|
| 59 |
+
gr.Markdown("# Combined PDF QA and Text Completion System")
|
| 60 |
+
|
| 61 |
+
with gr.Tab("PDF Question Answering"):
|
| 62 |
+
input_file = gr.File(label="Upload PDF File")
|
| 63 |
+
input_question = gr.Textbox(label="Ask about the document")
|
| 64 |
+
output_text_gemini = gr.Textbox(label="Answer - GeminiPro")
|
| 65 |
+
pdf_qa_button = gr.Button("Ask Question")
|
| 66 |
+
|
| 67 |
+
with gr.Tab("Text Completion"):
|
| 68 |
+
input_prompt = gr.Textbox(label="Enter prompt for text completion")
|
| 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 |
+
demo.launch()
|