-
Notifications
You must be signed in to change notification settings - Fork 0
summarize
gitpavleenbali edited this page Feb 17, 2026
·
2 revisions
The summarize function condenses text, files, or URLs into concise summaries.
from pyai import summarize# Summarize text
summary = summarize("Long article text here...")
# Summarize URL
summary = summarize("https://example.com/article")
# Summarize file
summary = summarize("document.pdf")| Parameter | Type | Default | Description |
|---|---|---|---|
content |
str | required | Text, URL, or file path |
length |
str | "medium" | Output length: "short", "medium", "long" |
format |
str | "paragraph" | Format: "paragraph", "bullets", "numbered" |
focus |
str | None | Specific aspect to focus on |
Returns a string containing the summarized content.
from pyai import summarize
article = """
PYAI is a comprehensive Python SDK for building AI agents...
[long article text]
"""
summary = summarize(article)
print(summary)# Fetch and summarize web content
summary = summarize("https://en.wikipedia.org/wiki/Artificial_intelligence")# Supports PDF, TXT, DOCX, MD
summary = summarize("report.pdf")
summary = summarize("notes.txt")# Short bullet-point summary
summary = summarize(
article,
length="short",
format="bullets"
)
# Focus on specific topic
summary = summarize(
article,
focus="technical implementation"
)import asyncio
from pyai import summarize
async def main():
summary = await summarize.async_("https://example.com/article")
print(summary)
asyncio.run(main())| Extension | Description |
|---|---|
.txt |
Plain text files |
.md |
Markdown files |
.pdf |
PDF documents |
.docx |
Word documents |
.html |
HTML files |
Intelligence, Embedded.