repo stringlengths 7 90 | file_url stringlengths 81 315 | file_path stringlengths 4 228 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 14:38:15 2026-01-05 02:33:18 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/tools/utils.py | browser_use/tools/utils.py | """Utility functions for browser tools."""
from browser_use.dom.service import EnhancedDOMTreeNode
def get_click_description(node: EnhancedDOMTreeNode) -> str:
"""Get a brief description of the clicked element for memory."""
parts = []
# Tag name
parts.append(node.tag_name)
# Add type for inputs
if node.tag_... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/tools/registry/views.py | browser_use/tools/registry/views.py | from collections.abc import Callable
from typing import TYPE_CHECKING, Any
from pydantic import BaseModel, ConfigDict
from browser_use.browser import BrowserSession
from browser_use.filesystem.file_system import FileSystem
from browser_use.llm.base import BaseChatModel
if TYPE_CHECKING:
pass
class RegisteredActio... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/tools/registry/service.py | browser_use/tools/registry/service.py | import asyncio
import functools
import inspect
import logging
import re
from collections.abc import Callable
from inspect import Parameter, iscoroutinefunction, signature
from types import UnionType
from typing import Any, Generic, Optional, TypeVar, Union, get_args, get_origin
import pyotp
from pydantic import BaseMo... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/integrations/gmail/service.py | browser_use/integrations/gmail/service.py | """
Gmail API Service for Browser Use
Handles Gmail API authentication, email reading, and 2FA code extraction.
This service provides a clean interface for agents to interact with Gmail.
"""
import base64
import logging
import os
from pathlib import Path
from typing import Any
import anyio
from google.auth.transport.... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/integrations/gmail/__init__.py | browser_use/integrations/gmail/__init__.py | """
Gmail Integration for Browser Use
Provides Gmail API integration for email reading and verification code extraction.
This integration enables agents to read email content and extract verification codes themselves.
Usage:
from browser_use.integrations.gmail import GmailService, register_gmail_actions
# Optio... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/integrations/gmail/actions.py | browser_use/integrations/gmail/actions.py | """
Gmail Actions for Browser Use
Defines agent actions for Gmail integration including 2FA code retrieval,
email reading, and authentication management.
"""
import logging
from pydantic import BaseModel, Field
from browser_use.agent.views import ActionResult
from browser_use.tools.service import Tools
from .servic... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/skills/views.py | browser_use/skills/views.py | """Skills views - wraps SDK types with helper methods"""
from typing import Any
from browser_use_sdk.types.parameter_schema import ParameterSchema
from browser_use_sdk.types.skill_response import SkillResponse
from pydantic import BaseModel, ConfigDict, Field
class MissingCookieException(Exception):
"""Raised when... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/skills/service.py | browser_use/skills/service.py | """Skills service for fetching and executing skills from the Browser Use API"""
import logging
import os
from typing import Any, Literal
from browser_use_sdk import AsyncBrowserUse
from browser_use_sdk.types.execute_skill_response import ExecuteSkillResponse
from browser_use_sdk.types.skill_list_response import Skill... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/skills/utils.py | browser_use/skills/utils.py | """Utilities for skill schema conversion"""
from typing import Any
from pydantic import BaseModel, Field, create_model
from browser_use.skills.views import ParameterSchema
def convert_parameters_to_pydantic(parameters: list[ParameterSchema], model_name: str = 'SkillParameters') -> type[BaseModel]:
"""Convert a li... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/skills/__init__.py | browser_use/skills/__init__.py | from browser_use.skills.service import SkillService
from browser_use.skills.views import MissingCookieException
__all__ = ['SkillService', 'MissingCookieException']
| python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/code_use/views.py | browser_use/code_use/views.py | """Data models for code-use mode."""
from __future__ import annotations
import json
from enum import Enum
from pathlib import Path
from typing import Any
from pydantic import BaseModel, ConfigDict, Field, PrivateAttr
from uuid_extensions import uuid7str
from browser_use.tokens.views import UsageSummary
class Cell... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/code_use/service.py | browser_use/code_use/service.py | """Code-use agent service - Jupyter notebook-like code execution for browser automation."""
import asyncio
import datetime
import html
import json
import logging
import re
import traceback
from pathlib import Path
from typing import Any
from uuid_extensions import uuid7str
from browser_use.browser import BrowserSess... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | true |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/code_use/utils.py | browser_use/code_use/utils.py | """Utility functions for code-use agent."""
import re
def truncate_message_content(content: str, max_length: int = 10000) -> str:
"""Truncate message content to max_length characters for history."""
if len(content) <= max_length:
return content
# Truncate and add marker
return content[:max_length] + f'\n\n[...... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/code_use/namespace.py | browser_use/code_use/namespace.py | """Namespace initialization for code-use mode.
This module creates a namespace with all browser tools available as functions,
similar to a Jupyter notebook environment.
"""
import asyncio
import csv
import datetime
import json
import logging
import re
from pathlib import Path
from typing import Any
import requests
... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/code_use/notebook_export.py | browser_use/code_use/notebook_export.py | """Export code-use session to Jupyter notebook format."""
import json
import re
from pathlib import Path
from browser_use.code_use.service import CodeAgent
from .views import CellType, NotebookExport
def export_to_ipynb(agent: CodeAgent, output_path: str | Path) -> Path:
"""
Export a NotebookSession to a Jupyter... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/code_use/__init__.py | browser_use/code_use/__init__.py | """Code-use mode - Jupyter notebook-like code execution for browser automation."""
from browser_use.code_use.namespace import create_namespace
from browser_use.code_use.notebook_export import export_to_ipynb, session_to_python_script
from browser_use.code_use.service import CodeAgent
from browser_use.code_use.views im... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/code_use/formatting.py | browser_use/code_use/formatting.py | """Browser state formatting helpers for code-use agent."""
import logging
from typing import Any
from browser_use.browser.session import BrowserSession
from browser_use.browser.views import BrowserStateSummary
logger = logging.getLogger(__name__)
async def format_browser_state_for_llm(
state: BrowserStateSummary,... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/filesystem/file_system.py | browser_use/filesystem/file_system.py | import asyncio
import base64
import os
import re
import shutil
from abc import ABC, abstractmethod
from concurrent.futures import ThreadPoolExecutor
from pathlib import Path
from typing import Any
from pydantic import BaseModel, Field
INVALID_FILENAME_ERROR_MESSAGE = 'Error: Invalid filename format. Must be alphanume... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/filesystem/__init__.py | browser_use/filesystem/__init__.py | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false | |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/views.py | browser_use/llm/views.py | from typing import Generic, TypeVar, Union
from pydantic import BaseModel
T = TypeVar('T', bound=Union[BaseModel, str])
class ChatInvokeUsage(BaseModel):
"""
Usage information for a chat model invocation.
"""
prompt_tokens: int
"""The number of tokens in the prompt (this includes the cached tokens as well. Wh... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/schema.py | browser_use/llm/schema.py | """
Utilities for creating optimized Pydantic schemas for LLM usage.
"""
from typing import Any
from pydantic import BaseModel
class SchemaOptimizer:
@staticmethod
def create_optimized_json_schema(
model: type[BaseModel],
*,
remove_min_items: bool = False,
remove_defaults: bool = False,
) -> dict[str, An... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/models.py | browser_use/llm/models.py | """
Convenient access to LLM models.
Usage:
from browser_use import llm
# Simple model access
model = llm.azure_gpt_4_1_mini
model = llm.openai_gpt_4o
model = llm.google_gemini_2_5_pro
model = llm.bu_latest
"""
import os
from typing import TYPE_CHECKING
from browser_use.llm.azure.chat import... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/exceptions.py | browser_use/llm/exceptions.py | class ModelError(Exception):
pass
class ModelProviderError(ModelError):
"""Exception raised when a model provider returns an error."""
def __init__(
self,
message: str,
status_code: int = 502,
model: str | None = None,
):
super().__init__(message)
self.message = message
self.status_code = status_co... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/__init__.py | browser_use/llm/__init__.py | """
We have switched all of our code from langchain to openai.types.chat.chat_completion_message_param.
For easier transition we have
"""
from typing import TYPE_CHECKING
# Lightweight imports that are commonly used
from browser_use.llm.base import BaseChatModel
from browser_use.llm.messages import (
AssistantMessa... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/messages.py | browser_use/llm/messages.py | """
This implementation is based on the OpenAI types, while removing all the parts that are not needed for Browser Use.
"""
# region - Content parts
from typing import Literal, Union
from pydantic import BaseModel
def _truncate(text: str, max_length: int = 50) -> str:
"""Truncate text to max_length characters, add... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/base.py | browser_use/llm/base.py | """
We have switched all of our code from langchain to openai.types.chat.chat_completion_message_param.
For easier transition we have
"""
from typing import Any, Protocol, TypeVar, overload, runtime_checkable
from pydantic import BaseModel
from browser_use.llm.messages import BaseMessage
from browser_use.llm.views ... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/oci_raw/serializer.py | browser_use/llm/oci_raw/serializer.py | """
Message serializer for OCI Raw API integration.
This module handles the conversion between browser-use message formats
and the OCI Raw API message format using proper OCI SDK models.
"""
from oci.generative_ai_inference.models import ImageContent, ImageUrl, Message, TextContent
from browser_use.llm.messages impo... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/oci_raw/chat.py | browser_use/llm/oci_raw/chat.py | """
OCI Raw API chat model integration for browser-use.
This module provides direct integration with Oracle Cloud Infrastructure's
Generative AI service using raw API calls without Langchain dependencies.
"""
import asyncio
import json
from dataclasses import dataclass
from typing import Any, TypeVar, overload
impor... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/oci_raw/__init__.py | browser_use/llm/oci_raw/__init__.py | """
OCI Raw API integration for browser-use.
This module provides direct integration with Oracle Cloud Infrastructure's
Generative AI service using the raw API endpoints, without Langchain dependencies.
"""
from .chat import ChatOCIRaw
__all__ = ['ChatOCIRaw']
| python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/openai/responses_serializer.py | browser_use/llm/openai/responses_serializer.py | """Serializer for converting messages to OpenAI Responses API input format."""
from typing import overload
from openai.types.responses.easy_input_message_param import EasyInputMessageParam
from openai.types.responses.response_input_image_param import ResponseInputImageParam
from openai.types.responses.response_input_... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/openai/serializer.py | browser_use/llm/openai/serializer.py | from typing import overload
from openai.types.chat import (
ChatCompletionAssistantMessageParam,
ChatCompletionContentPartImageParam,
ChatCompletionContentPartRefusalParam,
ChatCompletionContentPartTextParam,
ChatCompletionMessageFunctionToolCallParam,
ChatCompletionMessageParam,
ChatCompletionSystemMessagePara... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/openai/chat.py | browser_use/llm/openai/chat.py | from collections.abc import Iterable, Mapping
from dataclasses import dataclass, field
from typing import Any, Literal, TypeVar, overload
import httpx
from openai import APIConnectionError, APIStatusError, AsyncOpenAI, RateLimitError
from openai.types.chat import ChatCompletionContentPartTextParam
from openai.types.ch... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/openai/like.py | browser_use/llm/openai/like.py | from dataclasses import dataclass
from browser_use.llm.openai.chat import ChatOpenAI
@dataclass
class ChatOpenAILike(ChatOpenAI):
"""
A class for to interact with any provider using the OpenAI API schema.
Args:
model (str): The name of the OpenAI model to use.
"""
model: str
| python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/browser_use/chat.py | browser_use/llm/browser_use/chat.py | """
ChatBrowserUse - Client for browser-use cloud API
This wraps the BaseChatModel protocol and sends requests to the browser-use cloud API
for optimized browser automation LLM inference.
"""
import asyncio
import logging
import os
import random
from typing import Any, TypeVar, overload
import httpx
from pydantic im... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/browser_use/__init__.py | browser_use/llm/browser_use/__init__.py | from browser_use.llm.browser_use.chat import ChatBrowserUse
__all__ = ['ChatBrowserUse']
| python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/openrouter/serializer.py | browser_use/llm/openrouter/serializer.py | from openai.types.chat import ChatCompletionMessageParam
from browser_use.llm.messages import BaseMessage
from browser_use.llm.openai.serializer import OpenAIMessageSerializer
class OpenRouterMessageSerializer:
"""
Serializer for converting between custom message types and OpenRouter message formats.
OpenRouter ... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/openrouter/chat.py | browser_use/llm/openrouter/chat.py | from collections.abc import Mapping
from dataclasses import dataclass
from typing import Any, TypeVar, overload
import httpx
from openai import APIConnectionError, APIStatusError, AsyncOpenAI, RateLimitError
from openai.types.chat.chat_completion import ChatCompletion
from openai.types.shared_params.response_format_js... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/aws/serializer.py | browser_use/llm/aws/serializer.py | import base64
import json
import re
from typing import Any, overload
from browser_use.llm.messages import (
AssistantMessage,
BaseMessage,
ContentPartImageParam,
ContentPartRefusalParam,
ContentPartTextParam,
SystemMessage,
ToolCall,
UserMessage,
)
class AWSBedrockMessageSerializer:
"""Serializer for conver... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/aws/chat_anthropic.py | browser_use/llm/aws/chat_anthropic.py | import json
from collections.abc import Mapping
from dataclasses import dataclass
from typing import TYPE_CHECKING, Any, TypeVar, overload
from anthropic import (
APIConnectionError,
APIStatusError,
AsyncAnthropicBedrock,
RateLimitError,
omit,
)
from anthropic.types import CacheControlEphemeralParam, Message, Too... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/aws/__init__.py | browser_use/llm/aws/__init__.py | from typing import TYPE_CHECKING
# Type stubs for lazy imports
if TYPE_CHECKING:
from browser_use.llm.aws.chat_anthropic import ChatAnthropicBedrock
from browser_use.llm.aws.chat_bedrock import ChatAWSBedrock
# Lazy imports mapping for AWS chat models
_LAZY_IMPORTS = {
'ChatAnthropicBedrock': ('browser_use.llm.aws... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/aws/chat_bedrock.py | browser_use/llm/aws/chat_bedrock.py | import json
from dataclasses import dataclass
from os import getenv
from typing import TYPE_CHECKING, Any, TypeVar, overload
from pydantic import BaseModel
from browser_use.llm.aws.serializer import AWSBedrockMessageSerializer
from browser_use.llm.base import BaseChatModel
from browser_use.llm.exceptions import Model... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/vercel/serializer.py | browser_use/llm/vercel/serializer.py | from openai.types.chat import ChatCompletionMessageParam
from browser_use.llm.messages import BaseMessage
from browser_use.llm.openai.serializer import OpenAIMessageSerializer
class VercelMessageSerializer:
"""
Serializer for converting between custom message types and Vercel AI Gateway message formats.
Vercel A... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/vercel/chat.py | browser_use/llm/vercel/chat.py | import json
from collections.abc import Mapping
from dataclasses import dataclass, field
from typing import Any, Literal, TypeAlias, TypeVar, overload
import httpx
from openai import APIConnectionError, APIStatusError, AsyncOpenAI, RateLimitError
from openai.types.chat.chat_completion import ChatCompletion
from openai... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/vercel/__init__.py | browser_use/llm/vercel/__init__.py | from browser_use.llm.vercel.chat import ChatVercel
__all__ = ['ChatVercel']
| python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/tests/test_mistral_schema.py | browser_use/llm/tests/test_mistral_schema.py | from pydantic import BaseModel, Field
from browser_use.llm.mistral.schema import MistralSchemaOptimizer
class NestedExample(BaseModel):
code: str = Field(..., min_length=2, max_length=4, pattern='[A-Z]+')
description: str
class RootExample(BaseModel):
item: NestedExample
email: str = Field(..., json_schema_ext... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/tests/test_single_step.py | browser_use/llm/tests/test_single_step.py | import logging
import os
import tempfile
import pytest
from browser_use.agent.prompts import AgentMessagePrompt
from browser_use.agent.service import Agent
from browser_use.browser.views import BrowserStateSummary, TabInfo
from browser_use.dom.views import DOMSelectorMap, EnhancedDOMTreeNode, NodeType, SerializedDOMS... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/tests/test_gemini_image.py | browser_use/llm/tests/test_gemini_image.py | import asyncio
import base64
import io
import random
from PIL import Image, ImageDraw, ImageFont
from browser_use.llm.google.chat import ChatGoogle
from browser_use.llm.google.serializer import GoogleMessageSerializer
from browser_use.llm.messages import (
BaseMessage,
ContentPartImageParam,
ContentPartTextParam,
... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/tests/test_chat_models.py | browser_use/llm/tests/test_chat_models.py | import os
import pytest
from pydantic import BaseModel
from browser_use.llm import ChatAnthropic, ChatGoogle, ChatGroq, ChatOpenAI, ChatOpenRouter
from browser_use.llm.messages import ContentPartTextParam
# Optional OCI import
try:
from examples.models.oci_models import xai_llm
OCI_MODELS_AVAILABLE = True
except ... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/tests/test_anthropic_cache.py | browser_use/llm/tests/test_anthropic_cache.py | import logging
from typing import cast
from browser_use.agent.service import Agent
from browser_use.llm.anthropic.chat import ChatAnthropic
from browser_use.llm.anthropic.serializer import AnthropicMessageSerializer, NonSystemMessage
from browser_use.llm.messages import (
AssistantMessage,
BaseMessage,
ContentPartI... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/tests/test_groq_loop.py | browser_use/llm/tests/test_groq_loop.py | import asyncio
from browser_use.llm import ContentText
from browser_use.llm.groq.chat import ChatGroq
from browser_use.llm.messages import SystemMessage, UserMessage
llm = ChatGroq(
model='meta-llama/llama-4-maverick-17b-128e-instruct',
temperature=0.5,
)
# llm = ChatOpenAI(model='gpt-4.1-mini')
async def main():... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/azure/chat.py | browser_use/llm/azure/chat.py | import os
from dataclasses import dataclass
from typing import Any, TypeVar, overload
import httpx
from openai import APIConnectionError, APIStatusError, RateLimitError
from openai import AsyncAzureOpenAI as AsyncAzureOpenAIClient
from openai.types.responses import Response
from openai.types.shared import ChatModel
fr... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/groq/serializer.py | browser_use/llm/groq/serializer.py | from typing import overload
from groq.types.chat import (
ChatCompletionAssistantMessageParam,
ChatCompletionContentPartImageParam,
ChatCompletionContentPartTextParam,
ChatCompletionMessageParam,
ChatCompletionMessageToolCallParam,
ChatCompletionSystemMessageParam,
ChatCompletionUserMessageParam,
)
from groq.ty... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/groq/chat.py | browser_use/llm/groq/chat.py | import logging
from dataclasses import dataclass
from typing import Any, Literal, TypeVar, overload
from groq import (
APIError,
APIResponseValidationError,
APIStatusError,
AsyncGroq,
NotGiven,
RateLimitError,
Timeout,
)
from groq.types.chat import ChatCompletion, ChatCompletionToolChoiceOptionParam, ChatComple... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/groq/parser.py | browser_use/llm/groq/parser.py | import json
import logging
import re
from typing import TypeVar
from groq import APIStatusError
from pydantic import BaseModel
logger = logging.getLogger(__name__)
T = TypeVar('T', bound=BaseModel)
class ParseFailedGenerationError(Exception):
pass
def try_parse_groq_failed_generation(
error: APIStatusError,
o... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/ollama/serializer.py | browser_use/llm/ollama/serializer.py | import base64
import json
from typing import Any, overload
from ollama._types import Image, Message
from browser_use.llm.messages import (
AssistantMessage,
BaseMessage,
SystemMessage,
ToolCall,
UserMessage,
)
class OllamaMessageSerializer:
"""Serializer for converting between custom message types and Ollama ... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/ollama/chat.py | browser_use/llm/ollama/chat.py | from collections.abc import Mapping
from dataclasses import dataclass
from typing import Any, TypeVar, overload
import httpx
from ollama import AsyncClient as OllamaAsyncClient
from ollama import Options
from pydantic import BaseModel
from browser_use.llm.base import BaseChatModel
from browser_use.llm.exceptions impo... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/mistral/chat.py | browser_use/llm/mistral/chat.py | from __future__ import annotations
import json
import logging
import os
from collections.abc import Mapping
from dataclasses import dataclass
from typing import Any, TypeVar, cast, overload
import httpx
from pydantic import BaseModel
from browser_use.llm.base import BaseChatModel
from browser_use.llm.exceptions impo... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/mistral/schema.py | browser_use/llm/mistral/schema.py | """Schema optimizer for Mistral-compatible JSON schemas."""
from __future__ import annotations
from typing import Any
from pydantic import BaseModel
from browser_use.llm.schema import SchemaOptimizer
class MistralSchemaOptimizer:
"""Create JSON schemas that avoid Mistral's unsupported keywords."""
UNSUPPORTED_... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/mistral/__init__.py | browser_use/llm/mistral/__init__.py | """Mistral chat model integration."""
from browser_use.llm.mistral.chat import ChatMistral
__all__ = ['ChatMistral']
| python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/anthropic/serializer.py | browser_use/llm/anthropic/serializer.py | import json
from typing import overload
from anthropic.types import (
Base64ImageSourceParam,
CacheControlEphemeralParam,
ImageBlockParam,
MessageParam,
TextBlockParam,
ToolUseBlockParam,
URLImageSourceParam,
)
from browser_use.llm.messages import (
AssistantMessage,
BaseMessage,
ContentPartImageParam,
Con... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/anthropic/chat.py | browser_use/llm/anthropic/chat.py | import json
from collections.abc import Mapping
from dataclasses import dataclass
from typing import Any, TypeVar, overload
import httpx
from anthropic import (
APIConnectionError,
APIStatusError,
AsyncAnthropic,
NotGiven,
RateLimitError,
omit,
)
from anthropic.types import CacheControlEphemeralParam, Message, T... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/cerebras/serializer.py | browser_use/llm/cerebras/serializer.py | from __future__ import annotations
import json
from typing import Any, overload
from browser_use.llm.messages import (
AssistantMessage,
BaseMessage,
ContentPartImageParam,
ContentPartTextParam,
SystemMessage,
ToolCall,
UserMessage,
)
MessageDict = dict[str, Any]
class CerebrasMessageSerializer:
"""Seriali... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/cerebras/chat.py | browser_use/llm/cerebras/chat.py | from __future__ import annotations
from dataclasses import dataclass
from typing import Any, TypeVar, overload
import httpx
from openai import (
APIConnectionError,
APIError,
APIStatusError,
APITimeoutError,
AsyncOpenAI,
RateLimitError,
)
from openai.types.chat import ChatCompletion
from pydantic import BaseMod... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/google/serializer.py | browser_use/llm/google/serializer.py | import base64
from google.genai.types import Content, ContentListUnion, Part
from browser_use.llm.messages import (
AssistantMessage,
BaseMessage,
SystemMessage,
UserMessage,
)
class GoogleMessageSerializer:
"""Serializer for converting messages to Google Gemini format."""
@staticmethod
def serialize_messag... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/google/chat.py | browser_use/llm/google/chat.py | import asyncio
import json
import logging
import random
import time
from dataclasses import dataclass, field
from typing import Any, Literal, TypeVar, overload
from google import genai
from google.auth.credentials import Credentials
from google.genai import types
from google.genai.types import MediaModality
from pydan... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/google/__init__.py | browser_use/llm/google/__init__.py | from browser_use.llm.google.chat import ChatGoogle
__all__ = ['ChatGoogle']
| python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/deepseek/serializer.py | browser_use/llm/deepseek/serializer.py | from __future__ import annotations
import json
from typing import Any, overload
from browser_use.llm.messages import (
AssistantMessage,
BaseMessage,
ContentPartImageParam,
ContentPartTextParam,
SystemMessage,
ToolCall,
UserMessage,
)
MessageDict = dict[str, Any]
class DeepSeekMessageSerializer:
"""Seriali... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/llm/deepseek/chat.py | browser_use/llm/deepseek/chat.py | from __future__ import annotations
import json
from dataclasses import dataclass
from typing import Any, TypeVar, overload
import httpx
from openai import (
APIConnectionError,
APIError,
APIStatusError,
APITimeoutError,
AsyncOpenAI,
RateLimitError,
)
from pydantic import BaseModel
from browser_use.llm.base imp... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/dom/views.py | browser_use/dom/views.py | import hashlib
from dataclasses import asdict, dataclass, field
from enum import Enum
from typing import Any
from cdp_use.cdp.accessibility.commands import GetFullAXTreeReturns
from cdp_use.cdp.accessibility.types import AXPropertyName
from cdp_use.cdp.dom.commands import GetDocumentReturns
from cdp_use.cdp.dom.types ... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/dom/enhanced_snapshot.py | browser_use/dom/enhanced_snapshot.py | """
Enhanced snapshot processing for browser-use DOM tree extraction.
This module provides stateless functions for parsing Chrome DevTools Protocol (CDP) DOMSnapshot data
to extract visibility, clickability, cursor styles, and other layout information.
"""
from cdp_use.cdp.domsnapshot.commands import CaptureSnapshotR... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/dom/service.py | browser_use/dom/service.py | import asyncio
import logging
import time
from typing import TYPE_CHECKING
from cdp_use.cdp.accessibility.commands import GetFullAXTreeReturns
from cdp_use.cdp.accessibility.types import AXNode
from cdp_use.cdp.dom.types import Node
from cdp_use.cdp.target import TargetID
from browser_use.dom.enhanced_snapshot import... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | true |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/dom/utils.py | browser_use/dom/utils.py | def cap_text_length(text: str, max_length: int) -> str:
"""Cap text length for display."""
if len(text) <= max_length:
return text
return text[:max_length] + '...'
def generate_css_selector_for_element(enhanced_node) -> str | None:
"""Generate a CSS selector using node properties from version 0.5.0 approach."""... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/dom/markdown_extractor.py | browser_use/dom/markdown_extractor.py | """
Shared markdown extraction utilities for browser content processing.
This module provides a unified interface for extracting clean markdown from browser content,
used by both the tools service and page actor.
"""
import re
from typing import TYPE_CHECKING, Any
from browser_use.dom.serializer.html_serializer impo... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/dom/serializer/paint_order.py | browser_use/dom/serializer/paint_order.py | from collections import defaultdict
from dataclasses import dataclass
from browser_use.dom.views import SimplifiedNode
"""
Helper class for maintaining a union of rectangles (used for order of elements calculation)
"""
@dataclass(frozen=True, slots=True)
class Rect:
"""Closed axis-aligned rectangle with (x1,y1) bo... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/dom/serializer/serializer.py | browser_use/dom/serializer/serializer.py | # @file purpose: Serializes enhanced DOM trees to string format for LLM consumption
from typing import Any
from browser_use.dom.serializer.clickable_elements import ClickableElementDetector
from browser_use.dom.serializer.paint_order import PaintOrderRemover
from browser_use.dom.utils import cap_text_length
from brow... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | true |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/dom/serializer/code_use_serializer.py | browser_use/dom/serializer/code_use_serializer.py | # @file purpose: Ultra-compact serializer optimized for code-use agents
# Focuses on minimal token usage while preserving essential interactive context
from browser_use.dom.utils import cap_text_length
from browser_use.dom.views import (
EnhancedDOMTreeNode,
NodeType,
SimplifiedNode,
)
# Minimal but sufficient att... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/dom/serializer/clickable_elements.py | browser_use/dom/serializer/clickable_elements.py | from browser_use.dom.views import EnhancedDOMTreeNode, NodeType
class ClickableElementDetector:
@staticmethod
def is_interactive(node: EnhancedDOMTreeNode) -> bool:
"""Check if this node is clickable/interactive using enhanced scoring."""
# Skip non-element nodes
if node.node_type != NodeType.ELEMENT_NODE:
... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/dom/serializer/html_serializer.py | browser_use/dom/serializer/html_serializer.py | # @file purpose: Serializes enhanced DOM trees to HTML format including shadow roots
from browser_use.dom.views import EnhancedDOMTreeNode, NodeType
class HTMLSerializer:
"""Serializes enhanced DOM trees back to HTML format.
This serializer reconstructs HTML from the enhanced DOM tree, including:
- Shadow DOM co... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/dom/serializer/eval_serializer.py | browser_use/dom/serializer/eval_serializer.py | # @file purpose: Concise evaluation serializer for DOM trees - optimized for LLM query writing
from browser_use.dom.utils import cap_text_length
from browser_use.dom.views import (
EnhancedDOMTreeNode,
NodeType,
SimplifiedNode,
)
# Critical attributes for query writing and form interaction
# NOTE: Removed 'id' an... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/dom/playground/extraction.py | browser_use/dom/playground/extraction.py | import asyncio
import json
import os
import time
import anyio
import pyperclip
import tiktoken
from browser_use.agent.prompts import AgentMessagePrompt
from browser_use.browser import BrowserProfile, BrowserSession
from browser_use.browser.events import ClickElementEvent, TypeTextEvent
from browser_use.browser.profil... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/dom/playground/multi_act.py | browser_use/dom/playground/multi_act.py | from browser_use import Agent
from browser_use.browser import BrowserProfile, BrowserSession
from browser_use.browser.profile import ViewportSize
from browser_use.llm import ChatAzureOpenAI
# Initialize the Azure OpenAI client
llm = ChatAzureOpenAI(
model='gpt-4.1-mini',
)
TASK = """
Go to https://browser-use.githu... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/tokens/views.py | browser_use/tokens/views.py | from datetime import datetime
from typing import Any, TypeVar
from pydantic import BaseModel, Field
from browser_use.llm.views import ChatInvokeUsage
T = TypeVar('T', bound=BaseModel)
class TokenUsageEntry(BaseModel):
"""Single token usage entry"""
model: str
timestamp: datetime
usage: ChatInvokeUsage
class... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/tokens/service.py | browser_use/tokens/service.py | """
Token cost service that tracks LLM token usage and costs.
Fetches pricing data from LiteLLM repository and caches it for 1 day.
Automatically tracks token usage when LLMs are registered and invoked.
"""
import logging
import os
from datetime import datetime, timedelta
from pathlib import Path
from typing import A... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/tokens/custom_pricing.py | browser_use/tokens/custom_pricing.py | """
Custom model pricing for models not available in LiteLLM's pricing data.
Prices are per token (not per 1M tokens).
"""
from typing import Any
# Custom model pricing data
# Format matches LiteLLM's model_prices_and_context_window.json structure
CUSTOM_MODEL_PRICING: dict[str, dict[str, Any]] = {
'bu-1-0': {
'i... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/tokens/mappings.py | browser_use/tokens/mappings.py | # Mapping from model_name to LiteLLM model name
MODEL_TO_LITELLM: dict[str, str] = {
'gemini-flash-latest': 'gemini/gemini-flash-latest',
}
| python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/tokens/__init__.py | browser_use/tokens/__init__.py | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false | |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/tokens/tests/test_cost.py | browser_use/tokens/tests/test_cost.py | """
Simple test for token cost tracking with real LLM calls.
Tests ChatOpenAI and ChatGoogle by iteratively generating countries.
"""
import asyncio
import logging
from browser_use.llm import ChatGoogle, ChatOpenAI
from browser_use.llm.messages import AssistantMessage, SystemMessage, UserMessage
from browser_use.tok... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/sandbox/views.py | browser_use/sandbox/views.py | """Type-safe event models for sandbox execution SSE streaming"""
import json
from enum import Enum
from typing import Any
from pydantic import BaseModel
class SandboxError(Exception):
pass
class SSEEventType(str, Enum):
"""Event types for Server-Sent Events"""
BROWSER_CREATED = 'browser_created'
INSTANCE_CRE... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/sandbox/sandbox.py | browser_use/sandbox/sandbox.py | import ast
import asyncio
import base64
import dataclasses
import enum
import inspect
import json
import os
import sys
import textwrap
from collections.abc import Callable, Coroutine
from functools import wraps
from typing import TYPE_CHECKING, Any, Concatenate, ParamSpec, TypeVar, Union, cast, get_args, get_origin
im... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/sandbox/__init__.py | browser_use/sandbox/__init__.py | """Sandbox execution package for browser-use
This package provides type-safe sandbox code execution with SSE streaming.
Example:
from browser_use.sandbox import sandbox, SSEEvent, SSEEventType
@sandbox(log_level="INFO")
async def my_task(browser: Browser) -> str:
page = await browser.get_current_... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/browser/watchdog_base.py | browser_use/browser/watchdog_base.py | """Base watchdog class for browser monitoring components."""
import inspect
import time
from collections.abc import Iterable
from typing import Any, ClassVar
from bubus import BaseEvent, EventBus
from pydantic import BaseModel, ConfigDict, Field
from browser_use.browser.session import BrowserSession
class BaseWatc... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/browser/views.py | browser_use/browser/views.py | from dataclasses import dataclass, field
from typing import Any
from bubus import BaseEvent
from cdp_use.cdp.target import TargetID
from pydantic import AliasChoices, BaseModel, ConfigDict, Field, field_serializer
from browser_use.dom.views import DOMInteractedElement, SerializedDOMState
# Known placeholder image da... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/browser/profile.py | browser_use/browser/profile.py | import os
import sys
import tempfile
from collections.abc import Iterable
from enum import Enum
from functools import cache
from pathlib import Path
from typing import Annotated, Any, Literal, Self
from urllib.parse import urlparse
from pydantic import AfterValidator, AliasChoices, BaseModel, ConfigDict, Field, field_... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | true |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/browser/session_manager.py | browser_use/browser/session_manager.py | """Event-driven CDP session management.
Manages CDP sessions by listening to Target.attachedToTarget and Target.detachedFromTarget
events, ensuring the session pool always reflects the current browser state.
"""
import asyncio
from typing import TYPE_CHECKING
from cdp_use.cdp.target import AttachedToTargetEvent, Det... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | true |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/browser/events.py | browser_use/browser/events.py | """Event definitions for browser communication."""
import inspect
import os
from typing import Any, Literal
from bubus import BaseEvent
from bubus.models import T_EventResultType
from cdp_use.cdp.target import TargetID
from pydantic import BaseModel, Field, field_validator
from browser_use.browser.views import Brows... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/browser/__init__.py | browser_use/browser/__init__.py | from typing import TYPE_CHECKING
# Type stubs for lazy imports
if TYPE_CHECKING:
from .profile import BrowserProfile, ProxySettings
from .session import BrowserSession
# Lazy imports mapping for heavy browser components
_LAZY_IMPORTS = {
'ProxySettings': ('.profile', 'ProxySettings'),
'BrowserProfile': ('.profil... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/browser/video_recorder.py | browser_use/browser/video_recorder.py | """Video Recording Service for Browser Use Sessions."""
import base64
import logging
import math
import subprocess
from pathlib import Path
from typing import Optional
from browser_use.browser.profile import ViewportSize
try:
import imageio.v2 as iio # type: ignore[import-not-found]
import imageio_ffmpeg # type:... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/browser/session.py | browser_use/browser/session.py | """Event-driven browser session with backwards compatibility."""
import asyncio
import logging
from functools import cached_property
from pathlib import Path
from typing import TYPE_CHECKING, Any, Literal, Self, Union, cast, overload
from urllib.parse import urlparse, urlunparse
from uuid import UUID
import httpx
fro... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | true |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/browser/demo_mode.py | browser_use/browser/demo_mode.py | """Demo mode helper for injecting and updating the in-browser log panel."""
from __future__ import annotations
import asyncio
import json
import logging
from datetime import datetime, timezone
from typing import Any
from browser_use.browser.session import BrowserSession
# Embedded JavaScript for demo panel (injecte... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | true |
browser-use/browser-use | https://github.com/browser-use/browser-use/blob/630f85dd05127c9d42810a5db235a14f5bac9043/browser_use/browser/python_highlights.py | browser_use/browser/python_highlights.py | """Python-based highlighting system for drawing bounding boxes on screenshots.
This module replaces JavaScript-based highlighting with fast Python image processing
to draw bounding boxes around interactive elements directly on screenshots.
"""
import asyncio
import base64
import io
import logging
import os
from PIL ... | python | MIT | 630f85dd05127c9d42810a5db235a14f5bac9043 | 2026-01-04T14:38:16.467592Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.