Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -147,6 +147,9 @@ def generate_answer(question, context):
|
|
| 147 |
# ============================================================
|
| 148 |
|
| 149 |
def load_pdf(files, state):
|
|
|
|
|
|
|
|
|
|
| 150 |
if not files:
|
| 151 |
return "No file uploaded.", state
|
| 152 |
|
|
@@ -202,7 +205,7 @@ def answer_question(question, state):
|
|
| 202 |
|
| 203 |
with gr.Blocks(
|
| 204 |
title="PDF Q&A Chatbot",
|
| 205 |
-
css=".clear-btn button { height: 100%; }"
|
| 206 |
) as demo:
|
| 207 |
|
| 208 |
gr.Markdown("## 📄 PDF Q&A Chatbot\nUpload a PDF and ask questions about its content.")
|
|
@@ -216,14 +219,15 @@ with gr.Blocks(
|
|
| 216 |
|
| 217 |
with gr.Column(scale=2):
|
| 218 |
with gr.Row():
|
| 219 |
-
question = gr.Textbox(label="Your question", lines=2, scale =
|
| 220 |
clear_button = gr.Button("Clear", scale=1, min_width=80, elem_classes="clear-btn")
|
| 221 |
|
| 222 |
answer = gr.Textbox(label="Answer", lines=8)
|
| 223 |
ask_button = gr.Button("Ask")
|
| 224 |
|
| 225 |
|
| 226 |
-
pdf_input.upload(load_pdf, inputs=[pdf_input, state], outputs=[pdf_status, state])
|
|
|
|
| 227 |
ask_button.click(answer_question, inputs=[question, state], outputs=answer)
|
| 228 |
clear_button.click(lambda: "", outputs=question)
|
| 229 |
|
|
|
|
| 147 |
# ============================================================
|
| 148 |
|
| 149 |
def load_pdf(files, state):
|
| 150 |
+
print("FILES RECEIVED:", files)
|
| 151 |
+
print("TYPE:", type(files))
|
| 152 |
+
|
| 153 |
if not files:
|
| 154 |
return "No file uploaded.", state
|
| 155 |
|
|
|
|
| 205 |
|
| 206 |
with gr.Blocks(
|
| 207 |
title="PDF Q&A Chatbot",
|
| 208 |
+
css=".clear-btn button { height: 100%; min-height: 52px; }"
|
| 209 |
) as demo:
|
| 210 |
|
| 211 |
gr.Markdown("## 📄 PDF Q&A Chatbot\nUpload a PDF and ask questions about its content.")
|
|
|
|
| 219 |
|
| 220 |
with gr.Column(scale=2):
|
| 221 |
with gr.Row():
|
| 222 |
+
question = gr.Textbox(label="Your question", lines=2, scale =4)
|
| 223 |
clear_button = gr.Button("Clear", scale=1, min_width=80, elem_classes="clear-btn")
|
| 224 |
|
| 225 |
answer = gr.Textbox(label="Answer", lines=8)
|
| 226 |
ask_button = gr.Button("Ask")
|
| 227 |
|
| 228 |
|
| 229 |
+
pdf_input.upload(load_pdf, inputs=[pdf_input, state], outputs=[pdf_status, state, file_selector])
|
| 230 |
+
|
| 231 |
ask_button.click(answer_question, inputs=[question, state], outputs=answer)
|
| 232 |
clear_button.click(lambda: "", outputs=question)
|
| 233 |
|