from agno.agent import Agent
from agno.knowledge.pdf_url import PDFUrlKnowledgeBase
from agno.models.nebius import Nebius
from agno.vectordb.pgvector import PgVector
db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai"
knowledge_base = PDFUrlKnowledgeBase(
urls=["https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf"],
vector_db=PgVector(table_name="recipes", db_url=db_url),
)
knowledge_base.load(recreate=True) #首次运行后注释掉此行
agent = Agent(
model=Nebius(id="Qwen/Qwen3-30B-A3B"),
knowledge=knowledge_base,
show_tool_calls=True,
)
agent.print_response("How to make Thai curry?", markdown=True)
创建虚拟环境
打开 Terminal
并创建一个 python 虚拟环境。
python3 -m venv .venv
source .venv/bin/activate
设置您的 API 密钥
export NEBIUS_API_KEY=xxx
安装库
pip install duckduckgo-search sqlalchemy pgvector pypdf cerebras_cloud_sdk
运行 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 \
agnohq/pgvector:16
运行 Agent
python cookbook/models/nebius/knowledge.py