Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
qwen support
Magnus Müller1380b1e9038d
diff --git a/.gitignore b/.gitignoreindex 4dc46ec24..65b8e28fa 100644--- a/.gitignore+++ b/.gitignore@@ -60,3 +60,6 @@ temp-profile-*screenshot.png# *.md++all_github_issues_progress.md+all_github_issues.md\ No newline at end of filediff --git a/browser_use/agent/system_prompt.md b/browser_use/agent/system_prompt.mdindex 1b59ac61c..b1e48e910 100644--- a/browser_use/agent/system_prompt.md+++ b/browser_use/agent/system_prompt.md@@ -209,7 +209,7 @@ You must ALWAYS respond with a valid JSON in this exact format:"evaluation_previous_goal": "Concise one-sentence analysis of your last action. Clearly state success, failure, or uncertain.","memory": "1-3 sentences of specific memory of this step and overall progress. You should put here everything that will help you track progress in future steps. Like counting pages visited, items found, etc.","next_goal": "State the next immediate goal and action to achieve it, in one clear sentence."- "action":[{{"one_action_name": {{// action-specific parameter}}}}, // ... more actions in sequence]+ "action":[{{"go_to_url": {{ "url": "url_value"}}}}, // ... more actions in sequence]}}Action list should NEVER be empty.diff --git a/browser_use/agent/system_prompt_flash.md b/browser_use/agent/system_prompt_flash.mdindex ae1e5eaf6..7a7379070 100644--- a/browser_use/agent/system_prompt_flash.md+++ b/browser_use/agent/system_prompt_flash.md@@ -177,7 +177,7 @@ You must ALWAYS respond with a valid JSON in this exact format:{{"memory": "1-3 sentences of specific memory of this step and overall progress. You should put here everything that will help you track progress in future steps. Like counting pages visited, items found, etc.",- "action":[{{"one_action_name": {{// action-specific parameter}}}}, // ... more actions in sequence]+ "action":[{{"go_to_url": {{ "url": "url_value"}}}}, // ... more actions in sequence]}}Action list should NEVER be empty.diff --git a/browser_use/agent/system_prompt_no_thinking.md b/browser_use/agent/system_prompt_no_thinking.mdindex a2ae0c556..f3dd8211a 100644--- a/browser_use/agent/system_prompt_no_thinking.md+++ b/browser_use/agent/system_prompt_no_thinking.md@@ -205,7 +205,7 @@ You must ALWAYS respond with a valid JSON in this exact format:"evaluation_previous_goal": "One-sentence analysis of your last action. Clearly state success, failure, or uncertain.","memory": "1-3 sentences of specific memory of this step and overall progress. You should put here everything that will help you track progress in future steps. Like counting pages visited, items found, etc.","next_goal": "State the next immediate goal and action to achieve it, in one clear sentence.",- "action":[{{"one_action_name": {{// action-specific parameter}}}}, // ... more actions in sequence]+ "action":[{{"go_to_url": {{ "url": "url_value"}}}}, // ... more actions in sequence]}}Action list should NEVER be empty.diff --git a/docs/customize/agent/supported-models.mdx b/docs/customize/agent/supported-models.mdxindex 3af6dd826..7af3b21a0 100644--- a/docs/customize/agent/supported-models.mdx+++ b/docs/customize/agent/supported-models.mdx@@ -208,7 +208,41 @@ llm = ChatOllama(model="llama3.1:8b")[Example](https://github.com/browser-use/browser-use/blob/main/examples/models/langchain) on how to use Langchain with Browser Use.-## Other models (DeepSeek, Novita, X, Qwen...)+## Qwen [example](https://github.com/browser-use/browser-use/blob/main/examples/models/qwen.py)++Currently, only `qwen-vl-max` is recommended for Browser Use. Other Qwen models, including `qwen-max`, have issues with the action schema format.++```python+from browser_use import Agent, ChatOpenAI+from dotenv import load_dotenv+import os++load_dotenv()++# Get API key from https://modelstudio.console.alibabacloud.com/?tab=playground#/api-key+api_key = os.getenv('ALIBABA_CLOUD')+base_url = 'https://dashscope-intl.aliyuncs.com/compatible-mode/v1'++llm = ChatOpenAI(model='qwen-vl-max', api_key=api_key, base_url=base_url)++agent = Agent(+ task="Your task here",+ llm=llm,+ use_vision=True+)+```++Required environment variables:++```bash .env+ALIBABA_CLOUD=+```++<Warning>+ Smaller Qwen models may return incorrect action schema formats (e.g., `actions: [{"go_to_url": "google.com"}]` instead of `[{"go_to_url": {"url": "google.com"}}]`). If you want to use other models, add concrete examples of the correct action format to your prompt.+</Warning>++## Other models (DeepSeek, Novita, X...)We support all other models that can be called via OpenAI compatible API. We are open to PRs for more providers.diff --git a/examples/models/qwen.py b/examples/models/qwen.pynew file mode 100644index 000000000..48c22a9b9--- /dev/null+++ b/examples/models/qwen.py@@ -0,0 +1,26 @@+import os++from dotenv import load_dotenv++from browser_use import Agent, ChatOpenAI++load_dotenv()+import asyncio++# get an api key from https://modelstudio.console.alibabacloud.com/?tab=playground#/api-key+api_key = os.getenv('ALIBABA_CLOUD')+base_url = 'https://dashscope-intl.aliyuncs.com/compatible-mode/v1'++# so far we only had success with qwen-vl-max+# other models, even qwen-max, do not return the right output format. They confuse the action schema.+# E.g. they return actions: [{"go_to_url": "google.com"}] instead of [{"go_to_url": {"url": "google.com"}}]+# If you want to use smaller models and you see they mix up the action schema, add concrete examples to your prompt of the right format.+llm = ChatOpenAI(model='qwen-vl-max', api_key=api_key, base_url=base_url)+++async def main():+ agent = Agent(task='go find the founders of browser-use', llm=llm, use_vision=True, max_actions_per_step=1)+ await agent.run()+++asyncio.run(main())