Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
@@ -1,9 +1,7 @@
|
|
1 |
-
# main.py
|
2 |
from fastapi import FastAPI
|
3 |
from fastapi.responses import RedirectResponse
|
4 |
import gradio as gr
|
5 |
|
6 |
-
# ✅ Import your QA functions from app.py and appImage.py
|
7 |
from app import answer_question_from_doc
|
8 |
from appImage import answer_question_from_image
|
9 |
|
@@ -15,7 +13,8 @@ with gr.Blocks() as doc_interface:
|
|
15 |
doc_file = gr.File(label="Upload File (PDF, DOCX, PPTX, XLSX)")
|
16 |
doc_question = gr.Textbox(label="Ask a question")
|
17 |
doc_answer = gr.Textbox(label="Answer")
|
18 |
-
|
|
|
19 |
|
20 |
# === Image QA Tab ===
|
21 |
with gr.Blocks() as img_interface:
|
@@ -23,7 +22,8 @@ with gr.Blocks() as img_interface:
|
|
23 |
img_input = gr.Image(label="Upload an Image")
|
24 |
img_question = gr.Textbox(label="Ask a question")
|
25 |
img_answer = gr.Textbox(label="Answer")
|
26 |
-
|
|
|
27 |
|
28 |
# === Combine Tabs ===
|
29 |
demo = gr.TabbedInterface([doc_interface, img_interface], tab_names=["Document QA", "Image QA"])
|
|
|
|
|
1 |
from fastapi import FastAPI
|
2 |
from fastapi.responses import RedirectResponse
|
3 |
import gradio as gr
|
4 |
|
|
|
5 |
from app import answer_question_from_doc
|
6 |
from appImage import answer_question_from_image
|
7 |
|
|
|
13 |
doc_file = gr.File(label="Upload File (PDF, DOCX, PPTX, XLSX)")
|
14 |
doc_question = gr.Textbox(label="Ask a question")
|
15 |
doc_answer = gr.Textbox(label="Answer")
|
16 |
+
doc_submit = gr.Button("Get Answer")
|
17 |
+
doc_submit.click(fn=answer_question_from_doc, inputs=[doc_file, doc_question], outputs=doc_answer)
|
18 |
|
19 |
# === Image QA Tab ===
|
20 |
with gr.Blocks() as img_interface:
|
|
|
22 |
img_input = gr.Image(label="Upload an Image")
|
23 |
img_question = gr.Textbox(label="Ask a question")
|
24 |
img_answer = gr.Textbox(label="Answer")
|
25 |
+
img_submit = gr.Button("Get Answer")
|
26 |
+
img_submit.click(fn=answer_question_from_image, inputs=[img_input, img_question], outputs=img_answer)
|
27 |
|
28 |
# === Combine Tabs ===
|
29 |
demo = gr.TabbedInterface([doc_interface, img_interface], tab_names=["Document QA", "Image QA"])
|