代码
cookbook/models/cerebras/basic_storage.py
用法
1
创建虚拟环境
打开
Terminal 并创建一个 python 虚拟环境。2
设置您的 API 密钥
3
安装库
4
启动您的 Postgres 服务器
确保您的 Postgres 服务器正在运行,并且可以从
db_url 中使用的连接字符串进行访问。5
运行 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.models.cerebras import Cerebras
from agno.storage.postgres import PostgresStorage
from agno.tools.duckduckgo import DuckDuckGoTools
db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai"
agent = Agent(
model=Cerebras(id="llama-4-scout-17b-16e-instruct"),
storage=PostgresStorage(table_name="agent_sessions", db_url=db_url),
tools=[DuckDuckGoTools()],
add_history_to_messages=True,
)
agent.print_response("How many people live in Canada?")
agent.print_response("What is their national anthem called?")
创建虚拟环境
Terminal 并创建一个 python 虚拟环境。python3 -m venv .venv
source .venv/bin/activate
python3 -m venv .venv
.venv/scripts/activate
设置您的 API 密钥
export CEREBRAS_API_KEY=xxx
安装库
pip install -U duckduckgo-search cerebras-cloud-sdk agno
启动您的 Postgres 服务器
db_url 中使用的连接字符串进行访问。运行 Agent
python cookbook/models/cerebras/basic_storage.py
python cookbook/models/cerebras/basic_storage.py