Skip to content

Commit

Permalink
πŸ†• Add new example for PDF summarization using Claude-3
Browse files Browse the repository at this point in the history
  • Loading branch information
shroominic committed Mar 10, 2024
1 parent 83cd6f8 commit 54704fb
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions examples/claude3.py
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)

0 comments on commit 54704fb

Please sign in to comment.