YU-XI commited on
Commit
8b06ac5
1 Parent(s): fc697fd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -18
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
- # 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()
 
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()