mirror of
https://github.com/browser-use/browser-use
synced 2026-04-22 17:45:09 +02:00
src -> browser_use
This commit is contained in:
@@ -16,7 +16,7 @@ Let LLMs interact with websites through a simple interface.
|
||||
## Short Example
|
||||
|
||||
```python
|
||||
from src import Agent
|
||||
from browser_use import Agent
|
||||
from langchain_openai import ChatOpenAI
|
||||
|
||||
agent = Agent(
|
||||
@@ -92,7 +92,7 @@ You can persist the browser across multiple agents and chain them together.
|
||||
|
||||
```python
|
||||
from langchain_anthropic import ChatAnthropic
|
||||
from src import Agent, Controller
|
||||
from browser_use import Agent, Controller
|
||||
|
||||
# Persist browser state across agents
|
||||
controller = Controller()
|
||||
|
||||
6
browser_use/__init__.py
Normal file
6
browser_use/__init__.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from browser_use.agent.service import AgentService as Agent
|
||||
from browser_use.browser.service import BrowserService as Browser
|
||||
from browser_use.controller.service import ControllerService as Controller
|
||||
from browser_use.dom.service import DomService
|
||||
|
||||
__all__ = ['Agent', 'Browser', 'Controller', 'DomService']
|
||||
@@ -1,6 +1,6 @@
|
||||
from langchain_core.messages import HumanMessage, SystemMessage
|
||||
|
||||
from src.controller.views import ControllerPageState
|
||||
from browser_use.controller.views import ControllerPageState
|
||||
|
||||
|
||||
class AgentSystemPrompt:
|
||||
@@ -5,17 +5,17 @@ from dotenv import load_dotenv
|
||||
from langchain_core.language_models.chat_models import BaseChatModel
|
||||
from langchain_core.messages import AIMessage, BaseMessage, HumanMessage
|
||||
|
||||
from src.agent.prompts import AgentMessagePrompt, AgentSystemPrompt
|
||||
from src.agent.views import (
|
||||
from browser_use.agent.prompts import AgentMessagePrompt, AgentSystemPrompt
|
||||
from browser_use.agent.views import (
|
||||
AgentHistory,
|
||||
AgentOutput,
|
||||
ClickElementControllerHistoryItem,
|
||||
InputTextControllerHistoryItem,
|
||||
Output,
|
||||
)
|
||||
from src.controller.service import ControllerService
|
||||
from src.controller.views import ControllerActionResult, ControllerActions, ControllerPageState
|
||||
from src.utils import time_execution_async
|
||||
from browser_use.controller.service import ControllerService
|
||||
from browser_use.controller.views import ControllerActionResult, ControllerActions, ControllerPageState
|
||||
from browser_use.utils import time_execution_async
|
||||
|
||||
load_dotenv()
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -2,7 +2,7 @@ from typing import Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
from src.controller.views import (
|
||||
from browser_use.controller.views import (
|
||||
ClickElementControllerAction,
|
||||
ControllerActions,
|
||||
InputTextControllerAction,
|
||||
@@ -20,9 +20,9 @@ from selenium.webdriver.support import expected_conditions as EC
|
||||
from selenium.webdriver.support.ui import WebDriverWait
|
||||
from webdriver_manager.chrome import ChromeDriverManager
|
||||
|
||||
from src.browser.views import BrowserState
|
||||
from src.dom.service import DomService
|
||||
from src.utils import time_execution_sync
|
||||
from browser_use.browser.views import BrowserState
|
||||
from browser_use.dom.service import DomService
|
||||
from browser_use.utils import time_execution_sync
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
@@ -1,7 +1,7 @@
|
||||
import base64
|
||||
import pytest
|
||||
|
||||
from src.browser.service import BrowserService
|
||||
from browser_use.browser.service import BrowserService
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -1,4 +1,4 @@
|
||||
from src.dom.views import ProcessedDomContent
|
||||
from browser_use.dom.views import ProcessedDomContent
|
||||
|
||||
|
||||
# Exceptions
|
||||
@@ -1,7 +1,7 @@
|
||||
from src.browser.service import BrowserService
|
||||
from src.browser.views import BrowserState
|
||||
from src.controller.views import ControllerActionResult, ControllerActions, ControllerPageState
|
||||
from src.utils import time_execution_sync
|
||||
from browser_use.browser.service import BrowserService
|
||||
from browser_use.browser.views import BrowserState
|
||||
from browser_use.controller.views import ControllerActionResult, ControllerActions, ControllerPageState
|
||||
from browser_use.utils import time_execution_sync
|
||||
|
||||
|
||||
class ControllerService:
|
||||
@@ -2,7 +2,7 @@ from typing import Literal, Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
from src.browser.views import BrowserState
|
||||
from browser_use.browser.views import BrowserState
|
||||
|
||||
|
||||
class SearchGoogleControllerAction(BaseModel):
|
||||
@@ -4,8 +4,8 @@ from bs4 import BeautifulSoup, NavigableString, PageElement, Tag
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.common.by import By
|
||||
|
||||
from src.dom.views import DomContentItem, ProcessedDomContent
|
||||
from src.utils import time_execution_sync
|
||||
from browser_use.dom.views import DomContentItem, ProcessedDomContent
|
||||
from browser_use.utils import time_execution_sync
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
@@ -1,8 +1,8 @@
|
||||
import time
|
||||
|
||||
from src.browser.service import BrowserService
|
||||
from src.dom.service import DomService
|
||||
from src.utils import time_execution_sync
|
||||
from browser_use.browser.service import BrowserService
|
||||
from browser_use.dom.service import DomService
|
||||
from browser_use.utils import time_execution_sync
|
||||
|
||||
|
||||
# @pytest.mark.skip("slow af")
|
||||
@@ -8,9 +8,7 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
||||
import asyncio
|
||||
|
||||
from langchain_anthropic import ChatAnthropic
|
||||
|
||||
from src import Agent, Controller
|
||||
from browser_use import Agent, Controller
|
||||
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@ import asyncio
|
||||
from langchain_anthropic import ChatAnthropic
|
||||
from langchain_openai import ChatOpenAI
|
||||
|
||||
from src.agent.service import AgentService
|
||||
from src.controller.service import ControllerService
|
||||
from browser_use.agent.service import AgentService
|
||||
from browser_use.controller.service import ControllerService
|
||||
|
||||
task = 'Go to kayak.com and find a one-way flight from Zürich to San Francisco on 12 January 2025.'
|
||||
controller = ControllerService()
|
||||
|
||||
@@ -7,8 +7,8 @@ import asyncio
|
||||
|
||||
from langchain_openai import ChatOpenAI
|
||||
|
||||
from src.agent.service import AgentService
|
||||
from src.controller.service import ControllerService
|
||||
from browser_use.agent.service import AgentService
|
||||
from browser_use.controller.service import ControllerService
|
||||
|
||||
people = ['Albert Einstein', 'Oprah Winfrey', 'Steve Jobs']
|
||||
task = f'Opening new tabs and searching for images for these people: {", ".join(people)}. Then ask me for further instructions.'
|
||||
|
||||
@@ -8,7 +8,7 @@ import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
from src.controller.service import ControllerService
|
||||
from browser_use.controller.service import ControllerService
|
||||
|
||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
||||
@@ -16,7 +16,7 @@ import asyncio
|
||||
|
||||
from langchain_openai import ChatOpenAI
|
||||
|
||||
from src import Agent
|
||||
from browser_use import Agent
|
||||
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import asyncio
|
||||
|
||||
from langchain_openai import ChatOpenAI
|
||||
|
||||
from src import Agent
|
||||
from browser_use import Agent
|
||||
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
import argparse
|
||||
import asyncio
|
||||
|
||||
from src import Agent
|
||||
from src.controller.service import ControllerService
|
||||
from browser_use import Agent
|
||||
from browser_use.controller.service import ControllerService
|
||||
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@ import asyncio
|
||||
|
||||
from langchain_anthropic import ChatAnthropic
|
||||
|
||||
from src.agent.service import AgentService
|
||||
from src.controller.service import ControllerService
|
||||
from browser_use.agent.service import AgentService
|
||||
from browser_use.controller.service import ControllerService
|
||||
|
||||
task = 'Open 3 wikipedia pages in different tabs and summarize the content of all pages.'
|
||||
controller = ControllerService()
|
||||
|
||||
@@ -4,6 +4,7 @@ version = "0.1.0"
|
||||
description = "Open-Source Web Automation with LLMs"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.11"
|
||||
|
||||
dependencies = []
|
||||
|
||||
[tool.ruff]
|
||||
|
||||
@@ -11,5 +11,4 @@ pytest-asyncio==0.24.0
|
||||
python-dotenv==1.0.1
|
||||
requests==2.32.3
|
||||
selenium==4.26.1
|
||||
webdriver-manager==4.0.2
|
||||
setuptools==75.3.0
|
||||
webdriver-manager==4.0.2
|
||||
@@ -1,5 +0,0 @@
|
||||
from src.agent.service import AgentService as Agent
|
||||
from src.browser.service import BrowserService as Browser
|
||||
from src.controller.service import ControllerService as Controller
|
||||
|
||||
__all__ = ['Agent', 'Browser', 'Controller']
|
||||
Reference in New Issue
Block a user