Spaces:
Runtime error
Runtime error
Commit ·
1e9cfdf
1
Parent(s): a60f639
Update app.py
Browse files
app.py
CHANGED
|
@@ -248,7 +248,10 @@ def pdfv2(files, chainType):
|
|
| 248 |
output = extractScannedPDF(new_path, chainType)
|
| 249 |
|
| 250 |
return output
|
| 251 |
-
|
|
|
|
|
|
|
|
|
|
| 252 |
|
| 253 |
|
| 254 |
with gr.Blocks() as demo:
|
|
@@ -267,31 +270,31 @@ with gr.Blocks() as demo:
|
|
| 267 |
)
|
| 268 |
user_token.change(on_token_change, inputs=[user_token], outputs=[])
|
| 269 |
with gr.Tab("Summarise PDF"):
|
| 270 |
-
|
| 271 |
-
|
| 272 |
["map_reduce", "stuff", "refine"], label="Chain_Type", value="map_reduce"
|
| 273 |
)
|
| 274 |
-
|
| 275 |
-
|
| 276 |
|
| 277 |
-
|
| 278 |
-
|
| 279 |
|
| 280 |
gr.Markdown("""# Q&A""")
|
| 281 |
-
|
| 282 |
gr.Examples(
|
| 283 |
examples=["what is the main idea of this journal?","when did this paper publish?"],
|
| 284 |
-
inputs=
|
| 285 |
# outputs=answer,
|
| 286 |
# fn = qa1,
|
| 287 |
# cache_examples=False,
|
| 288 |
)
|
| 289 |
-
|
| 290 |
["default", "compact", "tree_summarize"], label="response_mode", value="default"
|
| 291 |
)
|
| 292 |
b1 = gr.Button("Query")
|
| 293 |
-
|
| 294 |
-
b1.click(qa1, inputs=[question,radio], outputs=
|
| 295 |
|
| 296 |
with gr.Tab("Summarise Scanned PDF"):
|
| 297 |
inp2 = gr.File(label="Input PDF")
|
|
@@ -316,15 +319,15 @@ with gr.Blocks() as demo:
|
|
| 316 |
radio2 = gr.Radio(
|
| 317 |
["default", "compact", "tree_summarize"], label="response_mode", value="default"
|
| 318 |
)
|
| 319 |
-
|
| 320 |
answer2 = gr.Textbox(label="Answer")
|
| 321 |
-
|
| 322 |
|
| 323 |
with gr.Tab("Reserved"):
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
# with gr.Accordion("Open for More!"):
|
| 329 |
# gr.Markdown("Look at me...")
|
| 330 |
|
|
|
|
| 248 |
output = extractScannedPDF(new_path, chainType)
|
| 249 |
|
| 250 |
return output
|
| 251 |
+
|
| 252 |
+
def pdfv3(in1, in2):
|
| 253 |
+
|
| 254 |
+
return 'ok!!'
|
| 255 |
|
| 256 |
|
| 257 |
with gr.Blocks() as demo:
|
|
|
|
| 270 |
)
|
| 271 |
user_token.change(on_token_change, inputs=[user_token], outputs=[])
|
| 272 |
with gr.Tab("Summarise PDF"):
|
| 273 |
+
inp1 = gr.File(label="Input PDF")
|
| 274 |
+
chainType1 = gr.Radio(
|
| 275 |
["map_reduce", "stuff", "refine"], label="Chain_Type", value="map_reduce"
|
| 276 |
)
|
| 277 |
+
doSum1 = gr.Button("Summarise")
|
| 278 |
+
out1 = gr.Textbox(label="Summary")
|
| 279 |
|
| 280 |
+
inp1.change(pdfv1, inputs=[inp1,chainType1], outputs=[out1])
|
| 281 |
+
doSum1.click(pdfv1, inputs=[inp1,chainType1], outputs=[out1])
|
| 282 |
|
| 283 |
gr.Markdown("""# Q&A""")
|
| 284 |
+
question1 = gr.Textbox(label="Question related to the pdf", placeholder = "Question...")
|
| 285 |
gr.Examples(
|
| 286 |
examples=["what is the main idea of this journal?","when did this paper publish?"],
|
| 287 |
+
inputs=question1,
|
| 288 |
# outputs=answer,
|
| 289 |
# fn = qa1,
|
| 290 |
# cache_examples=False,
|
| 291 |
)
|
| 292 |
+
radio1 = gr.Radio(
|
| 293 |
["default", "compact", "tree_summarize"], label="response_mode", value="default"
|
| 294 |
)
|
| 295 |
b1 = gr.Button("Query")
|
| 296 |
+
answer1 = gr.Textbox(label="Answer")
|
| 297 |
+
b1.click(qa1, inputs=[question,radio], outputs=answer1)
|
| 298 |
|
| 299 |
with gr.Tab("Summarise Scanned PDF"):
|
| 300 |
inp2 = gr.File(label="Input PDF")
|
|
|
|
| 319 |
radio2 = gr.Radio(
|
| 320 |
["default", "compact", "tree_summarize"], label="response_mode", value="default"
|
| 321 |
)
|
| 322 |
+
b2 = gr.Button("Query")
|
| 323 |
answer2 = gr.Textbox(label="Answer")
|
| 324 |
+
b2.click(qa2, inputs=[question2,radio2], outputs=answer2)
|
| 325 |
|
| 326 |
with gr.Tab("Reserved"):
|
| 327 |
+
inp3a = gr.Textbox()
|
| 328 |
+
inp3b = gr.Textbox()
|
| 329 |
+
out3 = gr.Textbox()
|
| 330 |
+
inp3.change(pdfv3, [inp3a,inp3b], out3)
|
| 331 |
# with gr.Accordion("Open for More!"):
|
| 332 |
# gr.Markdown("Look at me...")
|
| 333 |
|