这是一个具有思维链推理的基础推理代理。
from agno.agent import Agent
from agno.models.openai import OpenAIChat
task = (
"分析导致 1919 年签署《凡尔赛条约》的关键因素。 "
"讨论该条约对德国的政治、经济和社会影响,以及它如何促成了第二次世界大战的爆发。 "
"提供包含多种历史观点的细致评估。"
)
reasoning_agent = Agent(
model=OpenAIChat(id="gpt-4o"),
reasoning=True,
markdown=True,
)
reasoning_agent.print_response(task, stream=True, show_full_reasoning=True)
创建虚拟环境
打开 Terminal
并创建一个 python 虚拟环境。
python3 -m venv .venv
source .venv/bin/activate
设置您的 API 密钥
export OPENAI_API_KEY=xxx
安装库
pip install -U openai agno
运行示例
python cookbook/reasoning/agents/analyse_treaty_of_versailles.py