Code
knowledge.py
Usage
1
Set up your virtual environment
2
Set your API key
3
Install dependencies
4
Run Agent
Save the code above as
knowledge.py, then run:Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Give a CerebrasOpenAI agent knowledge from a PDF stored in PgVector.
from agno.agent import Agent
from agno.knowledge.knowledge import Knowledge
from agno.models.cerebras import CerebrasOpenAI
from agno.vectordb.pgvector import PgVector
db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai"
knowledge = Knowledge(
vector_db=PgVector(table_name="recipes", db_url=db_url),
)
# Add content to the knowledge
knowledge.insert(url="https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf")
agent = Agent(
model=CerebrasOpenAI(id="gpt-oss-120b"), knowledge=knowledge
)
agent.print_response("How to make Thai curry?", markdown=True)
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activate
uv venv --python 3.12
.venv\Scripts\activate
Set your API key
export CEREBRAS_API_KEY=xxx
Install dependencies
uv pip install -U openai cerebras-cloud-sdk sqlalchemy psycopg pgvector pypdf agno
Run Agent
knowledge.py, then run:python knowledge.py
Was this page helpful?