Spaces:
Running
Running
Create Summary
Browse filescreate a summary of a pdf
summary
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from langchain.document_loaders import PyPDFLoader
|
2 |
+
import gradio as gr
|
3 |
+
loader = PyPDFLoader("whitepaper.pdf")
|
4 |
+
documents = loader.load()
|
5 |
+
|
6 |
+
def summarize_pdf (pdf_file_path, custom_prompt=""):
|
7 |
+
loader = PyPDFLoader(pdf_file_path)
|
8 |
+
docs = loader.load_and_split()
|
9 |
+
chain = load_summarize_chain(llm, chain_type="map_reduce")
|
10 |
+
summary = chain.run(docs)
|
11 |
+
|
12 |
+
return summary
|
13 |
+
|
14 |
+
def main():
|
15 |
+
input_pdf_path = gr.inputs.Textbox(label="Enter the PDF file path")
|
16 |
+
output_summary = gr.outputs.Textbox(label="Summary")
|
17 |
+
|
18 |
+
interface = gr.Interface(
|
19 |
+
fn = summarize_pdf,
|
20 |
+
inputs = input_pdf_path,
|
21 |
+
outputs = output_summary,
|
22 |
+
title = "PDF Summarizer",
|
23 |
+
description = "This app allows you to summarize your PDF files.",
|
24 |
+
).launch(share=True)
|
25 |
+
|
26 |
+
|