代码
cookbook/agent_concepts/other/instructions_via_function.py
用法
1
创建虚拟环境
打开
Terminal
并创建一个 python 虚拟环境。2
设置您的 API 密钥
3
安装库
4
运行代理
from typing import List
from agno.agent import Agent
def get_instructions(agent: Agent) -> List[str]:
return [
f"Your name is {agent.name}!",
"Talk in haiku's!",
"Use poetry to answer questions.",
]
agent = Agent(
name="AgentX",
instructions=get_instructions,
markdown=True,
show_tool_calls=True,
)
agent.print_response("Who are you?", stream=True)
创建虚拟环境
Terminal
并创建一个 python 虚拟环境。python3 -m venv .venv
source .venv/bin/activate
设置您的 API 密钥
export OPENAI_API_KEY=xxx
安装库
pip install -U openai agno
运行代理
python cookbook/agent_concepts/other/instructions_via_function.py