The S3TextKnowledgeBase reads text files from an S3 bucket, converts them into vector embeddings and loads them to a vector database.

Usage

We are using a local PgVector database for this example. Make sure it’s running

pip install textract
from agno.knowledge.s3.text import S3TextKnowledgeBase
from agno.vectordb.pgvector import PgVector

db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai"

knowledge_base = S3TextKnowledgeBase(
    bucket_name="agno-public",
    key="recipes/recipes.docx",
    vector_db=PgVector(table_name="recipes", db_url=db_url),
)

Then use the knowledge_base with an Agent:

from agno.agent import Agent
from knowledge_base import knowledge_base

agent = Agent(
    knowledge=knowledge_base,
    search_knowledge=True,
)
agent.knowledge.load(recreate=False)

agent.print_response("How to make Hummus?")

Params

ParameterTypeDefaultDescription
bucket_namestrNoneThe name of the S3 Bucket where the files are.
keystrNoneThe key of the file in the bucket.
formatsList[str][".doc", ".docx"]Formats accepted by this knowledge base.
readerS3TextReaderS3TextReader()A S3TextReader that converts the Text files into Documents for the vector database.

S3TextKnowledgeBase is a subclass of the AgentKnowledge class and has access to the same params.

Developer Resources