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 runtime type check for llm in Agent init
மனோஜ்குமார் பழனிச்சாமி95009f7d95e0
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.pyindex 8fd81ccdd..783694533 100644--- a/browser_use/agent/service.py+++ b/browser_use/agent/service.py@@ -185,6 +185,8 @@ class Agent(Generic[Context, AgentStructuredOutput]):include_tool_call_examples: bool = False,**kwargs,):+ if not isinstance(llm, BaseChatModel):+ raise ValueError('invalid llm, must be from browser_use.llm')# Check for deprecated planner parametersplanner_params = [planner_llm, use_vision_for_planner, is_planner_reasoning, extend_planner_system_message]if any(param is not None and param is not False for param in planner_params) or planner_interval != 1:diff --git a/browser_use/llm/base.py b/browser_use/llm/base.pyindex 6bc4ae563..0e623d780 100644--- a/browser_use/llm/base.py+++ b/browser_use/llm/base.py@@ -4,7 +4,7 @@ We have switched all of our code from langchain to openai.types.chat.chat_compleFor easier transition we have"""-from typing import Any, Protocol, TypeVar, overload+from typing import Any, Protocol, TypeVar, overload, runtime_checkablefrom pydantic import BaseModel@@ -14,6 +14,7 @@ from browser_use.llm.views import ChatInvokeCompletionT = TypeVar('T', bound=BaseModel)+@runtime_checkableclass BaseChatModel(Protocol):_verified_api_keys: bool = False