thinking_agent.py
Run the Example
1
Set up your virtual environment
2
Install dependencies
3
Export your DashScope API key
4
Run the example
Save the code above as
thinking_agent.py, then run:Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Enable thinking on DashScope’s QVQ Max to reason through an image problem.
"""
Dashscope Thinking Agent
========================
Cookbook example for `dashscope/thinking_agent.py`.
"""
from agno.agent import Agent
from agno.media import Image
from agno.models.dashscope import DashScope
# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
agent = Agent(
model=DashScope(id="qvq-max", enable_thinking=True),
)
image_url = "https://img.alicdn.com/imgextra/i1/O1CN01gDEY8M1W114Hi3XcN_!!6000000002727-0-tps-1024-406.jpg"
agent.print_response(
"How do I solve this problem? Please think through each step carefully.",
images=[Image(url=image_url)],
stream=True,
)
# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
pass
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activate
uv venv --python 3.12
.venv\Scripts\activate
Install dependencies
uv pip install -U agno openai
Export your DashScope API key
export DASHSCOPE_API_KEY="your_dashscope_api_key_here"
$Env:DASHSCOPE_API_KEY="your_dashscope_api_key_here"
Run the example
thinking_agent.py, then run:python thinking_agent.py
Was this page helpful?