代码

cookbook/reasoning/tools/gemini_finance_agent.py

from agno.agent import Agent
from agno.models.google import Gemini
from agno.tools.thinking import ThinkingTools
from agno.tools.yfinance import YFinanceTools

thinking_agent = Agent(
    model=Gemini(id="gemini-2.0-flash"),
    tools=[
        ThinkingTools(add_instructions=True),
        YFinanceTools(
            stock_price=True,
            analyst_recommendations=True,
            company_info=True,
            company_news=True,
        ),
    ],
    instructions="尽可能使用表格",
    show_tool_calls=True,
    markdown=True,
    stream_intermediate_steps=True,
)
thinking_agent.print_response(
    "撰写一份详细对比 NVDA 和 TSLA 的报告", stream=True, show_reasoning=True
)


用法

1

创建虚拟环境

打开 Terminal 并创建一个 python 虚拟环境。

python3 -m venv .venv
source .venv/bin/activate
2

设置你的 API 密钥

export GOOGLE_API_KEY=xxx
3

安装库

pip install -U google-genai agno
4

运行 Agent

python cookbook/reasoning/tools/gemini_finance_agent.py