Code
pptx_reader.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.
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"
# Create a knowledge base with the PPTX documents
knowledge = Knowledge(
# Table name: ai.pptx_documents
vector_db=PgVector(
table_name="pptx_documents",
db_url=db_url,
),
)
# Load the knowledge
knowledge.add_content(
path="data/pptx_files",
reader=PPTXReader(),
)
# Create an agent with the knowledge
agent = Agent(
knowledge=knowledge,
search_knowledge=True,
)
# Ask the agent about the knowledge
agent.print_response("What can you tell me about the content in these PowerPoint presentations?", markdown=True)
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.py
python pptx_reader.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 |