了解如何使用 Agno 以及 Anthropic 的代码执行工具。
通过 Anthropic 的 代码执行工具,您的模型可以在安全、沙盒化的环境中执行 Python 代码。 这对于模型执行诸如分析数据、创建可视化或执行复杂计算等任务非常有用。
from agno.agent import Agent
from agno.models.anthropic import Claude
agent = Agent(
model=Claude(
id="claude-sonnet-4-20250514",
default_headers={
"anthropic-beta": "code-execution-2025-05-22"
}
),
tools=[
{
"type": "code_execution_20250522",
"name": "code_execution",
}
],
markdown=True,
)
agent.print_response("Calculate the mean and standard deviation of [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]", stream=True)