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
fix type errors
Gregor Žuničc385639a77c1
diff --git a/browser_use/llm/aws/chat_bedrock.py b/browser_use/llm/aws/chat_bedrock.pyindex eba47da94..b752f6fc9 100644--- a/browser_use/llm/aws/chat_bedrock.py+++ b/browser_use/llm/aws/chat_bedrock.py@@ -1,7 +1,9 @@+# pyright: reportMissingImports=false+import jsonfrom dataclasses import dataclassfrom os import getenv-from typing import Any, TypeVar, overload+from typing import TYPE_CHECKING, Any, TypeVar, overloadfrom pydantic import BaseModel@@ -11,14 +13,9 @@ from browser_use.llm.exceptions import ModelProviderError, ModelRateLimitErrorfrom browser_use.llm.messages import BaseMessagefrom browser_use.llm.views import ChatInvokeCompletion, ChatInvokeUsage-try:- from boto3 import client as AwsClient # pyright: ignore- from boto3.session import Session # pyright: ignore- from botocore.exceptions import ClientError # pyright: ignore-except ImportError:- raise ImportError(- '`boto3` not installed. Please install using `pip install browser-use[aws] or pip install browser-use[all]`'- )+if TYPE_CHECKING:+ from boto3 import client as AwsClient+ from boto3.session import SessionT = TypeVar('T', bound=BaseModel)@@ -52,7 +49,7 @@ class ChatAWSBedrock(BaseChatModel):aws_secret_access_key: str | None = Noneaws_region: str | None = Noneaws_sso_auth: bool = False- session: Session | None = None+ session: 'Session | None' = None# Request parametersrequest_params: dict[str, Any] | None = None@@ -62,8 +59,15 @@ class ChatAWSBedrock(BaseChatModel):def provider(self) -> str:return 'aws_bedrock'- def _get_client(self) -> AwsClient: # type: ignore[reportUnknownReturnType]+ def _get_client(self) -> AwsClient:"""Get the AWS Bedrock client."""+ try:+ from boto3 import client as AwsClient+ except ImportError:+ raise ImportError(+ '`boto3` not installed. Please install using `pip install browser-use[aws] or pip install browser-use[all]`'+ )+if self.session:return self.session.client('bedrock-runtime')@@ -166,6 +170,13 @@ class ChatAWSBedrock(BaseChatModel):Returns:Either a string response or an instance of output_format"""+ try:+ from botocore.exceptions import ClientError+ except ImportError:+ raise ImportError(+ '`boto3` not installed. Please install using `pip install browser-use[aws] or pip install browser-use[all]`'+ )+bedrock_messages, system_message = AWSBedrockMessageSerializer.serialize_messages(messages)try: