Code
pptx_reader_async.py
Usage
1
Create a virtual environment
Open the
Terminal and create a python virtual environment.2
Install libraries
3
Run PgVector
4
Run Agent
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
import asyncio
from agno.agent import Agent
from agno.knowledge.knowledge import Knowledge
from agno.knowledge.reader.pptx_reader import PPTXReader
from agno.vectordb.pgvector import PgVector
db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai"
knowledge = Knowledge(
# Table name: ai.pptx_documents
vector_db=PgVector(
table_name="pptx_documents",
db_url=db_url,
),
)
# Create an agent with the knowledge
agent = Agent(
knowledge=knowledge,
search_knowledge=True,
)
def main():
# Load the knowledge
asyncio.run(
knowledge.add_content_async(
path="data/pptx_files",
reader=PPTXReader(),
)
)
# Create and use the agent
asyncio.run(
agent.aprint_response(
"What can you tell me about the content in these PowerPoint presentations?", markdown=True
)
)
if __name__ == "__main__":
main()
Create a virtual environment
Terminal and create a python virtual environment.python3 -m venv .venv
source .venv/bin/activate
python3 -m venv .venv
.venv/scripts/activate
Install libraries
pip install -U python-pptx sqlalchemy psycopg pgvector agno
Run PgVector
docker run -d \
-e POSTGRES_DB=ai \
-e POSTGRES_USER=ai \
-e POSTGRES_PASSWORD=ai \
-e PGDATA=/var/lib/postgresql/data/pgdata \
-v pgvolume:/var/lib/postgresql/data \
-p 5532:5432 \
--name pgvector \
agno/pgvector:16
Run Agent
python pptx_reader_async.py
python pptx_reader_async.py
| Parameter | Type | Default | Description |
|---|---|---|---|
file | Union[Path, IO[Any]] | Required | Path to PPTX file or file-like object containing a PowerPoint presentation |
name | Optional[str] | None | Optional name for the document |
chunk | bool | True | Whether to chunk the document |
chunk_size | int | 5000 | Size of chunks when chunking is enabled |
chunking_strategy | Optional[ChunkingStrategy] | DocumentChunking() | Strategy for chunking the document |
encoding | Optional[str] | None | Text encoding to use for reading |