Commit ·
35b36a4
1
Parent(s): 4d6fe6c
Update app.py
Browse files
app.py
CHANGED
|
@@ -69,11 +69,9 @@ def parse_pdf(file_path):
|
|
| 69 |
|
| 70 |
def preprocess_pdf_text(pdf_file): #(list_of_text):
|
| 71 |
global page_num
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
pdf_txt, page_num = parse_pdf("/.cache/temp.pdf")
|
| 76 |
-
file_check("/.cache/temp.pdf")
|
| 77 |
|
| 78 |
page_docs = [Document(page_content=page) for page in pdf_txt]
|
| 79 |
|
|
@@ -86,8 +84,11 @@ def preprocess_pdf_text(pdf_file): #(list_of_text):
|
|
| 86 |
for section in sections_doc:
|
| 87 |
doc_sections.append(section)
|
| 88 |
|
| 89 |
-
return
|
| 90 |
-
|
|
|
|
|
|
|
|
|
|
| 91 |
def summarize_pdf(pdf_file, api_key,
|
| 92 |
model_name, temperature, llm_max_tokens,
|
| 93 |
custom_map_prompt, custom_combine_prompt):
|
|
@@ -181,8 +182,8 @@ def main():
|
|
| 181 |
|
| 182 |
# summarize_click = summarize_button.click(preprocess_pdf_text, inputs=[pdf_doc], outputs=[ingest_pdf]).\
|
| 183 |
# then(summarize_pdf, inputs=list_inputs, outputs=[summarized_text])
|
| 184 |
-
summarize_click = summarize_button.click(
|
| 185 |
-
demo.queue(concurrency_count=1).launch(
|
| 186 |
|
| 187 |
if __name__ == "__main__":
|
| 188 |
main()
|
|
|
|
| 69 |
|
| 70 |
def preprocess_pdf_text(pdf_file): #(list_of_text):
|
| 71 |
global page_num
|
| 72 |
+
|
| 73 |
+
pdf_txt, page_num = parse_pdf(pdf_file.name)
|
| 74 |
+
file_check(pdf_file.name)
|
|
|
|
|
|
|
| 75 |
|
| 76 |
page_docs = [Document(page_content=page) for page in pdf_txt]
|
| 77 |
|
|
|
|
| 84 |
for section in sections_doc:
|
| 85 |
doc_sections.append(section)
|
| 86 |
|
| 87 |
+
return doc_sections
|
| 88 |
+
|
| 89 |
+
def dummy1(pdf_file):
|
| 90 |
+
return pdf_file.name
|
| 91 |
+
|
| 92 |
def summarize_pdf(pdf_file, api_key,
|
| 93 |
model_name, temperature, llm_max_tokens,
|
| 94 |
custom_map_prompt, custom_combine_prompt):
|
|
|
|
| 182 |
|
| 183 |
# summarize_click = summarize_button.click(preprocess_pdf_text, inputs=[pdf_doc], outputs=[ingest_pdf]).\
|
| 184 |
# then(summarize_pdf, inputs=list_inputs, outputs=[summarized_text])
|
| 185 |
+
summarize_click = summarize_button.click(dummy1, inputs=[pdf_doc], outputs=[summarized_text])
|
| 186 |
+
demo.queue(concurrency_count=1).launch(share=True)
|
| 187 |
|
| 188 |
if __name__ == "__main__":
|
| 189 |
main()
|