Update app.py
Browse files
app.py
CHANGED
@@ -256,7 +256,10 @@ def ocr_converter(input_file):
|
|
256 |
ocrmypdf.ocr(image_pdf, image_pdf, skip_text=True, language="eng")
|
257 |
ocrmypdf.ocr(image_pdf, image_pdf, redo_ocr=True, language="eng")
|
258 |
return image_pdf
|
259 |
-
|
|
|
|
|
|
|
260 |
|
261 |
def answer_query(query):
|
262 |
question = query
|
@@ -290,6 +293,10 @@ with gr.Blocks(css=css,theme=gr.themes.Monochrome()) as demo:
|
|
290 |
status = gr.Textbox(label="Status", placeholder="", interactive=False)
|
291 |
load_pdf = gr.Button("Upload PDF and generate embeddings").style(full_width=False)
|
292 |
|
|
|
|
|
|
|
|
|
293 |
with gr.Row():
|
294 |
input = gr.Textbox(label="Type in your question")
|
295 |
output = gr.Textbox(label="Answer")
|
@@ -581,6 +588,7 @@ with gr.Blocks(css=css,theme=gr.themes.Monochrome()) as demo:
|
|
581 |
|
582 |
|
583 |
load_pdf.click(load_pdf_and_generate_embeddings, inputs=[pdf_doc, open_ai_key, relevant_pages], outputs=status)
|
|
|
584 |
load_csv.click(load_csv_and_store_questionset_into_sqlite, inputs=[csv_file, document_type_for_questionset, tag_for_questionset], outputs=status_for_loading_csv)
|
585 |
|
586 |
load_questionsets.click(retrieve_document_type_and_questionsettag_from_sqlite,outputs=questionsets)
|
|
|
256 |
ocrmypdf.ocr(image_pdf, image_pdf, skip_text=True, language="eng")
|
257 |
ocrmypdf.ocr(image_pdf, image_pdf, redo_ocr=True, language="eng")
|
258 |
return image_pdf
|
259 |
+
|
260 |
+
def summarize_contents():
|
261 |
+
question = "Generate a short summary of the contents along with no more than 3 leading/example questions"
|
262 |
+
return pdf_qa.run(question)
|
263 |
|
264 |
def answer_query(query):
|
265 |
question = query
|
|
|
293 |
status = gr.Textbox(label="Status", placeholder="", interactive=False)
|
294 |
load_pdf = gr.Button("Upload PDF and generate embeddings").style(full_width=False)
|
295 |
|
296 |
+
with gr.Row():
|
297 |
+
summary = gr.Textbox(label="Summary")
|
298 |
+
summarize_pdf = gr.Button("Have Moli Summarize the Contents").style(full_width=False)
|
299 |
+
|
300 |
with gr.Row():
|
301 |
input = gr.Textbox(label="Type in your question")
|
302 |
output = gr.Textbox(label="Answer")
|
|
|
588 |
|
589 |
|
590 |
load_pdf.click(load_pdf_and_generate_embeddings, inputs=[pdf_doc, open_ai_key, relevant_pages], outputs=status)
|
591 |
+
summarize_pdf.click(summarize_contents,outputs=summary)
|
592 |
load_csv.click(load_csv_and_store_questionset_into_sqlite, inputs=[csv_file, document_type_for_questionset, tag_for_questionset], outputs=status_for_loading_csv)
|
593 |
|
594 |
load_questionsets.click(retrieve_document_type_and_questionsettag_from_sqlite,outputs=questionsets)
|