sample_id stringlengths 21 196 | text stringlengths 105 936k | metadata dict | category stringclasses 6
values |
|---|---|---|---|
browser-use/browser-use:browser_use/browser/watchdogs/default_action_watchdog.py | """Default browser action handlers using CDP."""
import asyncio
import json
import os
from cdp_use.cdp.input.commands import DispatchKeyEventParameters
from browser_use.actor.utils import get_key_info
from browser_use.browser.events import (
ClickCoordinateEvent,
ClickElementEvent,
GetDropdownOptionsEvent,
GoBac... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/browser/watchdogs/default_action_watchdog.py",
"license": "MIT License",
"lines": 3141,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:browser_use/browser/watchdogs/dom_watchdog.py | """DOM watchdog for browser DOM tree management using CDP."""
import asyncio
import time
from typing import TYPE_CHECKING
from browser_use.browser.events import (
BrowserErrorEvent,
BrowserStateRequestEvent,
ScreenshotEvent,
TabCreatedEvent,
)
from browser_use.browser.watchdog_base import BaseWatchdog
from browse... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/browser/watchdogs/dom_watchdog.py",
"license": "MIT License",
"lines": 723,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:browser_use/browser/watchdogs/downloads_watchdog.py | """Downloads watchdog for monitoring and handling file downloads."""
import asyncio
import json
import os
import tempfile
from pathlib import Path
from typing import TYPE_CHECKING, Any, ClassVar
from urllib.parse import urlparse
import anyio
from bubus import BaseEvent
from cdp_use.cdp.browser import DownloadProgress... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/browser/watchdogs/downloads_watchdog.py",
"license": "MIT License",
"lines": 1183,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:browser_use/browser/watchdogs/local_browser_watchdog.py | """Local browser watchdog for managing browser subprocess lifecycle."""
from __future__ import annotations
import asyncio
import os
import shutil
import tempfile
from pathlib import Path
from typing import TYPE_CHECKING, Any, ClassVar
import psutil
from bubus import BaseEvent
from pydantic import PrivateAttr
from b... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/browser/watchdogs/local_browser_watchdog.py",
"license": "MIT License",
"lines": 425,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:browser_use/browser/watchdogs/permissions_watchdog.py | """Permissions watchdog for granting browser permissions on connection."""
from typing import TYPE_CHECKING, ClassVar
from bubus import BaseEvent
from browser_use.browser.events import BrowserConnectedEvent
from browser_use.browser.watchdog_base import BaseWatchdog
if TYPE_CHECKING:
pass
class PermissionsWatchdo... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/browser/watchdogs/permissions_watchdog.py",
"license": "MIT License",
"lines": 32,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:browser_use/browser/watchdogs/popups_watchdog.py | """Watchdog for handling JavaScript dialogs (alert, confirm, prompt) automatically."""
import asyncio
from typing import ClassVar
from bubus import BaseEvent
from pydantic import PrivateAttr
from browser_use.browser.events import TabCreatedEvent
from browser_use.browser.watchdog_base import BaseWatchdog
class Popu... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/browser/watchdogs/popups_watchdog.py",
"license": "MIT License",
"lines": 119,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:browser_use/browser/watchdogs/recording_watchdog.py | """Recording Watchdog for Browser Use Sessions."""
import asyncio
from pathlib import Path
from typing import Any, ClassVar
from bubus import BaseEvent
from cdp_use.cdp.page.events import ScreencastFrameEvent
from pydantic import PrivateAttr
from uuid_extensions import uuid7str
from browser_use.browser.events import... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/browser/watchdogs/recording_watchdog.py",
"license": "MIT License",
"lines": 144,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:browser_use/browser/watchdogs/screenshot_watchdog.py | """Screenshot watchdog for handling screenshot requests using CDP."""
from typing import TYPE_CHECKING, Any, ClassVar
from bubus import BaseEvent
from cdp_use.cdp.page import CaptureScreenshotParameters
from browser_use.browser.events import ScreenshotEvent
from browser_use.browser.views import BrowserError
from bro... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/browser/watchdogs/screenshot_watchdog.py",
"license": "MIT License",
"lines": 59,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:browser_use/browser/watchdogs/storage_state_watchdog.py | """Storage state watchdog for managing browser cookies and storage persistence."""
import asyncio
import json
import os
from pathlib import Path
from typing import Any, ClassVar
from bubus import BaseEvent
from cdp_use.cdp.network import Cookie
from pydantic import Field, PrivateAttr
from browser_use.browser.events ... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/browser/watchdogs/storage_state_watchdog.py",
"license": "MIT License",
"lines": 307,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:browser_use/config.py | """Configuration system for browser-use with automatic migration support."""
import json
import logging
import os
from datetime import datetime
from functools import cache
from pathlib import Path
from typing import Any
from uuid import uuid4
import psutil
from pydantic import BaseModel, ConfigDict, Field
from pydant... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/config.py",
"license": "MIT License",
"lines": 398,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use: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... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/dom/enhanced_snapshot.py",
"license": "MIT License",
"lines": 147,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use: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... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/dom/playground/extraction.py",
"license": "MIT License",
"lines": 261,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use: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... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/dom/playground/multi_act.py",
"license": "MIT License",
"lines": 22,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use: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."""
def has_form_control_descendant(element: EnhancedDOMTreeNode, max_depth:... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/dom/serializer/clickable_elements.py",
"license": "MIT License",
"lines": 212,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use: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... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/dom/serializer/serializer.py",
"license": "MIT License",
"lines": 1096,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use: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... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/integrations/gmail/actions.py",
"license": "MIT License",
"lines": 91,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use: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.... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/integrations/gmail/service.py",
"license": "MIT License",
"lines": 188,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use: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... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/llm/anthropic/chat.py",
"license": "MIT License",
"lines": 206,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use: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... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/llm/anthropic/serializer.py",
"license": "MIT License",
"lines": 275,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use: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... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/llm/aws/chat_anthropic.py",
"license": "MIT License",
"lines": 205,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use: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... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/llm/aws/chat_bedrock.py",
"license": "MIT License",
"lines": 243,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use: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... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/llm/aws/serializer.py",
"license": "MIT License",
"lines": 211,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use: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... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/llm/azure/chat.py",
"license": "MIT License",
"lines": 230,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use: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 ... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/llm/base.py",
"license": "MIT License",
"lines": 43,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use: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... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/llm/deepseek/chat.py",
"license": "MIT License",
"lines": 194,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use: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... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/llm/deepseek/serializer.py",
"license": "MIT License",
"lines": 95,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use: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... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/llm/exceptions.py",
"license": "MIT License",
"lines": 23,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use: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... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/llm/google/chat.py",
"license": "MIT License",
"lines": 519,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use: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... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/llm/google/serializer.py",
"license": "MIT License",
"lines": 102,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use: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... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/llm/groq/chat.py",
"license": "MIT License",
"lines": 195,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use: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... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/llm/groq/parser.py",
"license": "MIT License",
"lines": 130,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use: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... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/llm/groq/serializer.py",
"license": "MIT License",
"lines": 129,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use: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... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/llm/messages.py",
"license": "MIT License",
"lines": 172,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use: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 # or bu_1_0, bu_2_0
"""
import os
from typing import TYPE_CHECKING
from browser_use.... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/llm/models.py",
"license": "MIT License",
"lines": 279,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use: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... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/llm/ollama/chat.py",
"license": "MIT License",
"lines": 78,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use: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 ... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/llm/ollama/serializer.py",
"license": "MIT License",
"lines": 113,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use: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... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/llm/openai/chat.py",
"license": "MIT License",
"lines": 257,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use: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
| {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/llm/openai/like.py",
"license": "MIT License",
"lines": 10,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
browser-use/browser-use:browser_use/llm/openai/serializer.py | from typing import overload
from openai.types.chat import (
ChatCompletionAssistantMessageParam,
ChatCompletionContentPartImageParam,
ChatCompletionContentPartRefusalParam,
ChatCompletionContentPartTextParam,
ChatCompletionMessageFunctionToolCallParam,
ChatCompletionMessageParam,
ChatCompletionSystemMessagePara... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/llm/openai/serializer.py",
"license": "MIT License",
"lines": 137,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use: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... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/llm/openrouter/chat.py",
"license": "MIT License",
"lines": 175,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use: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 ... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/llm/openrouter/serializer.py",
"license": "MIT License",
"lines": 19,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
browser-use/browser-use: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... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/llm/schema.py",
"license": "MIT License",
"lines": 178,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use: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... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/llm/tests/test_anthropic_cache.py",
"license": "MIT License",
"lines": 296,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
browser-use/browser-use: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 ... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/llm/tests/test_chat_models.py",
"license": "MIT License",
"lines": 236,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
browser-use/browser-use: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,
... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/llm/tests/test_gemini_image.py",
"license": "MIT License",
"lines": 72,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
browser-use/browser-use: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():... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/llm/tests/test_groq_loop.py",
"license": "MIT License",
"lines": 40,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
browser-use/browser-use: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... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/llm/tests/test_single_step.py",
"license": "MIT License",
"lines": 200,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
browser-use/browser-use: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... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/llm/views.py",
"license": "MIT License",
"lines": 32,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
browser-use/browser-use:browser_use/mcp/__main__.py | """Entry point for running MCP server as a module.
Usage:
python -m browser_use.mcp
"""
import asyncio
from browser_use.mcp.server import main
if __name__ == '__main__':
asyncio.run(main())
| {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/mcp/__main__.py",
"license": "MIT License",
"lines": 8,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
browser-use/browser-use:browser_use/mcp/client.py | """MCP (Model Context Protocol) client integration for browser-use.
This module provides integration between external MCP servers and browser-use's action registry.
MCP tools are dynamically discovered and registered as browser-use actions.
Example usage:
from browser_use import Tools
from browser_use.mcp.cli... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/mcp/client.py",
"license": "MIT License",
"lines": 450,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:browser_use/mcp/controller.py | """MCP (Model Context Protocol) tool wrapper for browser-use.
This module provides integration between MCP tools and browser-use's action registry system.
MCP tools are dynamically discovered and registered as browser-use actions.
"""
import asyncio
import logging
from typing import Any
from pydantic import Field, c... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/mcp/controller.py",
"license": "MIT License",
"lines": 204,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:browser_use/mcp/server.py | """MCP Server for browser-use - exposes browser automation capabilities via Model Context Protocol.
This server provides tools for:
- Running autonomous browser tasks with an AI agent
- Direct browser control (navigation, clicking, typing, etc.)
- Content extraction from web pages
- File system operations
Usage:
... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/mcp/server.py",
"license": "MIT License",
"lines": 1075,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:browser_use/observability.py | # @file purpose: Observability module for browser-use that handles optional lmnr integration with debug mode support
"""
Observability module for browser-use
This module provides observability decorators that optionally integrate with lmnr (Laminar) for tracing.
If lmnr is not installed, it provides no-op wrappers tha... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/observability.py",
"license": "MIT License",
"lines": 162,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:browser_use/screenshots/service.py | """
Screenshot storage service for browser-use agents.
"""
import base64
from pathlib import Path
import anyio
from browser_use.observability import observe_debug
class ScreenshotService:
"""Simple screenshot storage service that saves screenshots to disk"""
def __init__(self, agent_directory: str | Path):
""... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/screenshots/service.py",
"license": "MIT License",
"lines": 37,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:browser_use/sync/auth.py | """
OAuth2 Device Authorization Grant flow client for browser-use.
"""
import asyncio
import json
import os
import shutil
import time
from datetime import datetime
import httpx
from pydantic import BaseModel
from uuid_extensions import uuid7str
from browser_use.config import CONFIG
# Temporary user ID for pre-auth ... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/sync/auth.py",
"license": "MIT License",
"lines": 289,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:browser_use/sync/service.py | """
Cloud sync service for sending events to the Browser Use cloud.
"""
import logging
import httpx
from bubus import BaseEvent
from browser_use.config import CONFIG
from browser_use.sync.auth import TEMP_USER_ID, DeviceAuthClient
logger = logging.getLogger(__name__)
class CloudSync:
"""Service for syncing event... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/sync/service.py",
"license": "MIT License",
"lines": 133,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use: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... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/tokens/service.py",
"license": "MIT License",
"lines": 473,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use: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... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/tokens/tests/test_cost.py",
"license": "MIT License",
"lines": 100,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
browser-use/browser-use: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... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/tokens/views.py",
"license": "MIT License",
"lines": 74,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use: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... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/tools/registry/service.py",
"license": "MIT License",
"lines": 516,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:browser_use/tools/views.py | from typing import Generic, TypeVar
from pydantic import BaseModel, ConfigDict, Field
from pydantic.json_schema import SkipJsonSchema
# Action Input Models
class ExtractAction(BaseModel):
query: str
extract_links: bool = Field(
default=False, description='Set True to true if the query requires links, else false ... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/tools/views.py",
"license": "MIT License",
"lines": 119,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:examples/browser/parallel_browser.py | import asyncio
from browser_use import Agent, Browser, ChatOpenAI
# NOTE: This is still experimental, and agents might conflict each other.
async def main():
# Create 3 separate browser instances
browsers = [
Browser(
user_data_dir=f'./temp-profile-{i}',
headless=False,
)
for i in range(3)
]
# Crea... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/browser/parallel_browser.py",
"license": "MIT License",
"lines": 36,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:examples/browser/playwright_integration.py | """
Key features:
1. Browser-Use and Playwright sharing the same Chrome instance via CDP
2. Take actions with Playwright and continue with Browser-Use actions
3. Let the agent call Playwright functions like screenshot or click on selectors
"""
import asyncio
import os
import subprocess
import sys
import tempfile
from... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/browser/playwright_integration.py",
"license": "MIT License",
"lines": 298,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:examples/cloud/01_basic_task.py | """
Cloud Example 1: Your First Browser Use Cloud Task
==================================================
This example demonstrates the most basic Browser Use Cloud functionality:
- Create a simple automation task
- Get the task ID
- Monitor completion
- Retrieve results
Perfect for first-time cloud users to understa... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/cloud/01_basic_task.py",
"license": "MIT License",
"lines": 143,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:examples/cloud/02_fast_mode_gemini.py | """
Cloud Example 2: Ultra-Fast Mode with Gemini Flash ⚡
====================================================
This example demonstrates the fastest and most cost-effective configuration:
- Gemini 2.5 Flash model ($0.01 per step)
- No proxy (faster execution, but no captcha solving)
- No element highlighting (better pe... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/cloud/02_fast_mode_gemini.py",
"license": "MIT License",
"lines": 210,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:examples/cloud/03_structured_output.py | """
Cloud Example 3: Structured JSON Output 📋
==========================================
This example demonstrates how to get structured, validated JSON output:
- Define Pydantic schemas for type safety
- Extract structured data from websites
- Validate and parse JSON responses
- Handle different data types and neste... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/cloud/03_structured_output.py",
"license": "MIT License",
"lines": 279,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:examples/cloud/04_proxy_usage.py | """
Cloud Example 4: Proxy Usage 🌍
===============================
This example demonstrates reliable proxy usage scenarios:
- Different country proxies for geo-restrictions
- IP address and location verification
- Region-specific content access (streaming, news)
- Search result localization by country
- Mobile/resid... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/cloud/04_proxy_usage.py",
"license": "MIT License",
"lines": 247,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:examples/cloud/05_search_api.py | """
Cloud Example 5: Search API (Beta) 🔍
=====================================
This example demonstrates the Browser Use Search API (BETA):
- Simple search: Search Google and extract from multiple results
- URL search: Extract specific content from a target URL
- Deep navigation through websites (depth parameter)
- R... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/cloud/05_search_api.py",
"license": "MIT License",
"lines": 275,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:examples/custom-functions/2fa.py | import os
import sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
from dotenv import load_dotenv
load_dotenv()
from browser_use import Agent
secret_key = os.environ.get('OTP_SECRET_KEY')
if not secret_key:
# For this example copy the code from the website https://... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/custom-functions/2fa.py",
"license": "MIT License",
"lines": 19,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:examples/custom-functions/cua.py | """
OpenAI Computer Use Assistant (CUA) Integration
This example demonstrates how to integrate OpenAI's Computer Use Assistant as a fallback
action when standard browser actions are insufficient to achieve the desired goal.
The CUA can perform complex computer interactions that might be difficult to achieve
through re... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/custom-functions/cua.py",
"license": "MIT License",
"lines": 288,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:examples/features/add_image_context.py | """
Show how to use sample_images to add image context for your task
"""
import asyncio
import base64
from pathlib import Path
from typing import Any
from dotenv import load_dotenv
from browser_use import Agent
from browser_use.llm import ChatOpenAI
from browser_use.llm.messages import ContentPartImageParam, Content... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/features/add_image_context.py",
"license": "MIT License",
"lines": 90,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:examples/features/multi_tab.py | """
Simple try of the agent.
@dev You need to add OPENAI_API_KEY to your environment variables.
"""
import asyncio
import os
import sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
from dotenv import load_dotenv
load_dotenv()
from browser_use import Agent, ChatOpen... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/features/multi_tab.py",
"license": "MIT License",
"lines": 20,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:examples/features/process_agent_output.py | import asyncio
import os
import sys
from pprint import pprint
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
from dotenv import load_dotenv
load_dotenv()
from browser_use import Agent, ChatOpenAI
from browser_use.agent.views import AgentHistoryList
from browser_use.bro... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/features/process_agent_output.py",
"license": "MIT License",
"lines": 42,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:examples/features/scrolling_page.py | # Goal: Automates webpage scrolling with various scrolling actions, including element-specific scrolling.
import asyncio
import os
import sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
from dotenv import load_dotenv
load_dotenv()
from browser_use import Agent, Cha... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/features/scrolling_page.py",
"license": "MIT License",
"lines": 74,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:examples/features/secure.py | """
Azure OpenAI example with data privacy and high-scale configuration.
Environment Variables Required:
- AZURE_OPENAI_KEY (or AZURE_OPENAI_API_KEY)
- AZURE_OPENAI_ENDPOINT
- AZURE_OPENAI_DEPLOYMENT (optional)
DATA PRIVACY WITH AZURE OPENAI:
✅ Good News: No Training on Your Data by Default
Azure OpenAI Service alre... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/features/secure.py",
"license": "MIT License",
"lines": 56,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
browser-use/browser-use:examples/features/video_recording.py | import asyncio
from pathlib import Path
from browser_use import Agent, Browser, ChatOpenAI
# NOTE: To use this example, install imageio[ffmpeg], e.g. with uv pip install "browser-use[video]"
async def main():
browser_session = Browser(record_video_dir=Path('./tmp/recordings'))
agent = Agent(
task='Go to github... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/features/video_recording.py",
"license": "MIT License",
"lines": 16,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:examples/file_system/alphabet_earnings.py | import asyncio
import os
import pathlib
import shutil
from dotenv import load_dotenv
from browser_use import Agent, ChatOpenAI
load_dotenv()
SCRIPT_DIR = pathlib.Path(os.path.dirname(os.path.abspath(__file__)))
agent_dir = SCRIPT_DIR / 'alphabet_earnings'
agent_dir.mkdir(exist_ok=True)
task = """
Go to https://abc... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/file_system/alphabet_earnings.py",
"license": "MIT License",
"lines": 27,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:examples/file_system/excel_sheet.py | import asyncio
import os
import sys
from browser_use.llm.openai.chat import ChatOpenAI
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from dotenv import load_dotenv
load_dotenv()
from browser_use import Agent
llm = ChatOpenAI(model='o4-mini')
task = (
'Find current stock price of ... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/file_system/excel_sheet.py",
"license": "MIT License",
"lines": 23,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:examples/file_system/file_system.py | import asyncio
import os
import pathlib
import shutil
from dotenv import load_dotenv
from browser_use import Agent, ChatOpenAI
load_dotenv()
SCRIPT_DIR = pathlib.Path(os.path.dirname(os.path.abspath(__file__)))
agent_dir = SCRIPT_DIR / 'file_system'
agent_dir.mkdir(exist_ok=True)
conversation_dir = agent_dir / 'co... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/file_system/file_system.py",
"license": "MIT License",
"lines": 35,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:examples/getting_started/01_basic_search.py | """
Setup:
1. Get your API key from https://cloud.browser-use.com/new-api-key
2. Set environment variable: export BROWSER_USE_API_KEY="your-key"
"""
import asyncio
import os
import sys
# Add the parent directory to the path so we can import browser_use
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(o... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/getting_started/01_basic_search.py",
"license": "MIT License",
"lines": 20,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:examples/getting_started/02_form_filling.py | """
Getting Started Example 2: Form Filling
This example demonstrates how to:
- Navigate to a website with forms
- Fill out input fields
- Submit forms
- Handle basic form interactions
This builds on the basic search example by showing more complex interactions.
Setup:
1. Get your API key from https://cloud.browser-... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/getting_started/02_form_filling.py",
"license": "MIT License",
"lines": 40,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
browser-use/browser-use:examples/getting_started/03_data_extraction.py | """
Getting Started Example 3: Data Extraction
This example demonstrates how to:
- Navigate to a website with structured data
- Extract specific information from the page
- Process and organize the extracted data
- Return structured results
This builds on previous examples by showing how to get valuable data from web... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/getting_started/03_data_extraction.py",
"license": "MIT License",
"lines": 39,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
browser-use/browser-use:examples/getting_started/04_multi_step_task.py | """
Getting Started Example 4: Multi-Step Task
This example demonstrates how to:
- Perform a complex workflow with multiple steps
- Navigate between different pages
- Combine search, form filling, and data extraction
- Handle a realistic end-to-end scenario
This is the most advanced getting started example, combining... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/getting_started/04_multi_step_task.py",
"license": "MIT License",
"lines": 42,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
browser-use/browser-use:examples/getting_started/05_fast_agent.py | import asyncio
import os
import sys
# Add the parent directory to the path so we can import browser_use
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
from dotenv import load_dotenv
load_dotenv()
from browser_use import Agent, BrowserProfile
# Speed optimization inst... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/getting_started/05_fast_agent.py",
"license": "MIT License",
"lines": 48,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:examples/integrations/agentmail/2fa.py | import asyncio
import os
import sys
from agentmail import AsyncAgentMail # type: ignore
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
from dotenv import load_dotenv
load_dotenv()
from browser_use import Agent, Browser, ChatBrowserUse
from examples.integrations.agentm... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/integrations/agentmail/2fa.py",
"license": "MIT License",
"lines": 28,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:examples/integrations/agentmail/email_tools.py | """
Email management to enable 2fa.
"""
import asyncio
import logging
# run `pip install agentmail` to install the library
from agentmail import AsyncAgentMail, Message, MessageReceivedEvent, Subscribe # type: ignore
from agentmail.inboxes.types.inbox import Inbox # type: ignore
from agentmail.inboxes.types.inbox_i... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/integrations/agentmail/email_tools.py",
"license": "MIT License",
"lines": 152,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:examples/integrations/gmail_2fa_integration.py | """
Gmail 2FA Integration Example with Grant Mechanism
This example demonstrates how to use the Gmail integration for handling 2FA codes
during web automation with a robust credential grant and re-authentication system.
Features:
- Automatic credential validation and setup
- Interactive OAuth grant flow when credentia... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/integrations/gmail_2fa_integration.py",
"license": "MIT License",
"lines": 271,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:examples/models/aws.py | """
AWS Bedrock Examples
This file demonstrates how to use AWS Bedrock models with browser-use.
We provide two classes:
1. ChatAnthropicBedrock - Convenience class for Anthropic Claude models
2. ChatAWSBedrock - General AWS Bedrock client supporting all providers
Requirements:
- AWS credentials configured via environ... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/models/aws.py",
"license": "MIT License",
"lines": 75,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:examples/models/deepseek-chat.py | import asyncio
import os
from browser_use import Agent
from browser_use.llm import ChatDeepSeek
# Add your custom instructions
extend_system_message = """
Remember the most important rules:
1. When performing a search task, open https://www.google.com/ first for search.
2. Final output.
"""
deepseek_api_key = os.ge... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/models/deepseek-chat.py",
"license": "MIT License",
"lines": 29,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:examples/models/gpt-4.1.py | """
Simple try of the agent.
@dev You need to add OPENAI_API_KEY to your environment variables.
"""
import asyncio
from dotenv import load_dotenv
from browser_use import Agent, ChatOpenAI
load_dotenv()
# All the models are type safe from OpenAI in case you need a list of supported models
llm = ChatOpenAI(model='g... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/models/gpt-4.1.py",
"license": "MIT License",
"lines": 18,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:examples/models/gpt-5-mini.py | """
Simple try of the agent.
@dev You need to add OPENAI_API_KEY to your environment variables.
"""
import asyncio
from dotenv import load_dotenv
from browser_use import Agent, ChatOpenAI
load_dotenv()
# All the models are type safe from OpenAI in case you need a list of supported models
llm = ChatOpenAI(model='g... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/models/gpt-5-mini.py",
"license": "MIT License",
"lines": 18,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:examples/models/langchain/chat.py | from dataclasses import dataclass
from typing import TYPE_CHECKING, TypeVar, overload
from pydantic import BaseModel
from browser_use.llm.base import BaseChatModel
from browser_use.llm.exceptions import ModelProviderError
from browser_use.llm.messages import BaseMessage
from browser_use.llm.views import ChatInvokeCom... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/models/langchain/chat.py",
"license": "MIT License",
"lines": 157,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:examples/models/langchain/example.py | """
Example of using LangChain models with browser-use.
This example demonstrates how to:
1. Wrap a LangChain model with ChatLangchain
2. Use it with a browser-use Agent
3. Run a simple web automation task
@file purpose: Example usage of LangChain integration with browser-use
"""
import asyncio
from langchain_opena... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/models/langchain/example.py",
"license": "MIT License",
"lines": 41,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:examples/models/langchain/serializer.py | import json
from typing import overload
from langchain_core.messages import ( # pyright: ignore
AIMessage,
HumanMessage,
SystemMessage,
)
from langchain_core.messages import ( # pyright: ignore
ToolCall as LangChainToolCall,
)
from langchain_core.messages.base import BaseMessage as LangChainBaseMessage # pyrigh... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/models/langchain/serializer.py",
"license": "MIT License",
"lines": 124,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:examples/models/llama4-groq.py | import asyncio
import os
import sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from dotenv import load_dotenv
load_dotenv()
from browser_use import Agent
from browser_use.llm import ChatGroq
groq_api_key = os.environ.get('GROQ_API_KEY')
llm = ChatGroq(
model='meta-llama/llama-4-... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/models/llama4-groq.py",
"license": "MIT License",
"lines": 27,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:examples/models/openrouter.py | """
Simple try of the agent.
@dev You need to add OPENAI_API_KEY to your environment variables.
"""
import asyncio
import os
from dotenv import load_dotenv
from browser_use import Agent, ChatOpenAI
load_dotenv()
# All the models are type safe from OpenAI in case you need a list of supported models
llm = ChatOpenA... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/models/openrouter.py",
"license": "MIT License",
"lines": 24,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:examples/observability/openLLMetry.py | import asyncio
import os
from dotenv import load_dotenv
# test if traceloop is installed
try:
from traceloop.sdk import Traceloop # type: ignore
except ImportError:
print('Traceloop is not installed')
exit(1)
from browser_use import Agent
load_dotenv()
api_key = os.getenv('TRACELOOP_API_KEY')
Traceloop.init(api... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/observability/openLLMetry.py",
"license": "MIT License",
"lines": 17,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:examples/use-cases/extract_pdf_content.py | #!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.11"
# dependencies = ["browser-use", "mistralai"]
# ///
import os
import sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
from dotenv import load_dotenv
load_dotenv()
import asyncio
import loggi... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/use-cases/extract_pdf_content.py",
"license": "MIT License",
"lines": 26,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:tests/ci/evaluate_tasks.py | """
Runs all agent tasks in parallel (up to 10 at a time) using separate subprocesses.
Each task gets its own Python process, preventing browser session interference.
Fails with exit code 1 if 0% of tasks pass.
"""
import argparse
import asyncio
import glob
import json
import logging
import os
import sys
import warnin... | {
"repo_id": "browser-use/browser-use",
"file_path": "tests/ci/evaluate_tasks.py",
"license": "MIT License",
"lines": 310,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
browser-use/browser-use:tests/ci/test_tools.py | import asyncio
import json
import os
import tempfile
import time
import anyio
import pytest
from pydantic import BaseModel, Field
from pytest_httpserver import HTTPServer
from browser_use.agent.views import ActionResult
from browser_use.browser import BrowserSession
from browser_use.browser.profile import BrowserProf... | {
"repo_id": "browser-use/browser-use",
"file_path": "tests/ci/test_tools.py",
"license": "MIT License",
"lines": 535,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.