Thinking Agent

Code

1from kern.agent import Agent
2from kern.media import Image
3from kern.models.dashscope import DashScope
4
5agent = Agent(
6 model=DashScope(id="qvq-max", enable_thinking=True),
7)
8
9image_url = "https://img.alicdn.com/imgextra/i1/O1CN01gDEY8M1W114Hi3XcN_!!6000000002727-0-tps-1024-406.jpg"
10
11agent.print_response(
12 "How do I solve this problem? Please think through each step carefully.",
13 images=[Image(url=image_url)],
14 stream=True,
15)

Usage

Set up your virtual environment

1uv venv --python 3.12
2source .venv/bin/activate
1uv venv --python 3.12
2.venv\Scripts\activate

Set your API key

1export DASHSCOPE_API_KEY=xxx

Install dependencies

1uv pip install -U kern-ai

Run Agent

1python cookbook/11_models/dashscope/thinking_agent.py