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
Add ModelScope example and documentation
yrkbdc60097aa9e
diff --git a/.env.example b/.env.exampleindex 1128ae2e0..add5f7eda 100644--- a/.env.example+++ b/.env.example@@ -6,6 +6,7 @@ GEMINI_API_KEY=DEEPSEEK_API_KEY=GROK_API_KEY=NOVITA_API_KEY=+MODELSCOPE_API_KEY=# Set to false to disable anonymized telemetryANONYMIZED_TELEMETRY=truediff --git a/README.md b/README.mdindex ce72d3c61..04e160065 100644--- a/README.md+++ b/README.md@@ -69,6 +69,7 @@ GEMINI_API_KEY=DEEPSEEK_API_KEY=GROK_API_KEY=NOVITA_API_KEY=+MODELSCOPE_API_KEY=```For other settings, models, and more, check out the [documentation 📕](https://docs.browser-use.com).diff --git a/docs/customize/supported-models.mdx b/docs/customize/supported-models.mdxindex 67cc92e23..70c258d19 100644--- a/docs/customize/supported-models.mdx+++ b/docs/customize/supported-models.mdx@@ -283,6 +283,36 @@ Required environment variables:GROK_API_KEY=```+### ModelScope+[ModelScope](https://modelscope.cn/docs/model-service/API-Inference/intro) is an LLM API provider that offers a wide range of models. Note: choose a model that supports function calling.++```python+from langchain_openai import ChatOpenAI+from browser_use import Agent+from pydantic import SecretStr+from dotenv import load_dotenv+import os++load_dotenv()+api_key = os.getenv("MODELSCOPE_API_KEY")++# Initialize the model+llm = ChatOpenAI(base_url='https://api-inference.modelscope.cn/v1/', model='Qwen/Qwen2.5-VL-72B-Instruct', api_key=SecretStr(api_key))++# Create agent with the model+agent = Agent(+ task="Your task here",+ llm=llm,+ use_vision=False+)+```++Required environment variables:++```bash .env+MODELSCOPE_API_KEY=+```+## Coming soon(We are working on it)- Groqdiff --git a/docs/development/local-setup.mdx b/docs/development/local-setup.mdxindex b8566d6c5..84e65a459 100644--- a/docs/development/local-setup.mdx+++ b/docs/development/local-setup.mdx@@ -53,6 +53,7 @@ GEMINI_API_KEY=DEEPSEEK_API_KEY=GROK_API_KEY=NOVITA_API_KEY=+MODELSCOPE_API_KEY=```<Note>diff --git a/examples/models/modelscope_example.py b/examples/models/modelscope_example.pynew file mode 100644index 000000000..77fb13bd0--- /dev/null+++ b/examples/models/modelscope_example.py@@ -0,0 +1,39 @@+"""+Simple try of the agent.++@dev You need to add MODELSCOPE_API_KEY to your environment variables.+"""++import asyncio+import os++from dotenv import load_dotenv+from langchain_openai import ChatOpenAI+from pydantic import SecretStr++from browser_use import Agent++# dotenv+load_dotenv()++api_key = os.getenv('MODELSCOPE_API_KEY', '')+if not api_key:+ raise ValueError('MODELSCOPE_API_KEY is not set')+++async def run_search():+ agent = Agent(+ task=('go to amazon.com, search for laptop'),+ llm=ChatOpenAI(+ base_url='https://api-inference.modelscope.cn/v1/',+ model='Qwen/QwQ-32B-Preview',+ api_key=SecretStr(api_key),+ ),+ use_vision=False,+ )++ await agent.run()+++if __name__ == '__main__':+ asyncio.run(run_search())\ No newline at end of file