-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
π Add new example for PDF summarization using Claude-3
- Loading branch information
1 parent
83cd6f8
commit 54704fb
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from typing import Annotated | ||
|
||
from funcchain import Depends, chain, settings | ||
from langchain.document_loaders.pdf import PyPDFLoader | ||
|
||
settings.llm = "anthropic/claude-3-opus-20240229" | ||
|
||
|
||
def load_pdf(input: dict) -> str: | ||
if path := input.get("path"): | ||
return " ".join([d.page_content for d in PyPDFLoader(path).load()]) | ||
return "No URL given" | ||
|
||
|
||
def summarize_pdf(path: str, pdf: Annotated[str, Depends(load_pdf)] = "") -> str: | ||
""" | ||
Given the full pdf summarize the entire document and focus on the most important parts. | ||
""" | ||
return chain() | ||
|
||
|
||
path = "~/Downloads/muzio1966.pdf" | ||
|
||
summary = summarize_pdf(path) | ||
|
||
print(summary) |