Skip to content
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ RUN apt-get update && apt-get install -y \
fonts-dejavu-core \
fonts-dejavu-extra \
vim \
pipx \
&& rm -rf /var/lib/apt/lists/*

# Install noVNC
Expand All @@ -70,20 +71,28 @@ WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Playwright setup
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-browsers
RUN mkdir -p $PLAYWRIGHT_BROWSERS_PATH
# Install uv and uvx for browser-use
RUN pip install --no-cache-dir uv

# Install Chromium via Playwright without --with-deps
RUN PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=0 playwright install chromium
# Install Chromium browser for browser-use
RUN apt-get update \
&& apt-get install -y chromium chromium-driver \
&& rm -rf /var/lib/apt/lists/*

# Set Chrome path for browser-use
ENV CHROME_BIN=/usr/bin/chromium
ENV DISPLAY=:99

# Also create a symlink for uvx
RUN ln -s /usr/local/bin/uv /usr/local/bin/uvx || true

# Copy application code
COPY . .

# Set up supervisor configuration
RUN mkdir -p /var/log/supervisor
# Set up supervisor configuration and DBus
RUN mkdir -p /var/log/supervisor /run/dbus
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf

EXPOSE 7788 6080 5901 9222
EXPOSE 7788 6080 5901 9222 3000

CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
19 changes: 2 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,7 @@ Activate the virtual environment:
source .venv/bin/activate
```

#### Step 3: Install Dependencies
Install Python packages:
```bash
uv pip install -r requirements.txt
```

Install Browsers in playwright.
```bash
playwright install --with-deps
```
Or you can install specific browsers by running:
```bash
playwright install chromium --with-deps
```

#### Step 4: Configure Environment
#### Step 3: Configure Environment
1. Create a copy of the example environment file:
- Windows (Command Prompt):
```bash
Expand All @@ -82,7 +67,7 @@ cp .env.example .env
```
2. Open `.env` in your preferred text editor and add your API keys and other settings

#### Step 5: Enjoy the web-ui
#### Step 4: Enjoy the web-ui
1. **Run the WebUI:**
```bash
python webui.py --ip 127.0.0.1 --port 7788
Expand Down
3 changes: 0 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ services:

# Display Settings
- DISPLAY=:99
# This ENV is used by the Dockerfile during build time if playwright respects it.
# It's not strictly needed at runtime by docker-compose unless your app or scripts also read it.
- PLAYWRIGHT_BROWSERS_PATH=/ms-browsers # Matches Dockerfile ENV
- RESOLUTION=${RESOLUTION:-1920x1080x24}
- RESOLUTION_WIDTH=${RESOLUTION_WIDTH:-1920}
- RESOLUTION_HEIGHT=${RESOLUTION_HEIGHT:-1080}
Expand Down
11 changes: 3 additions & 8 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
browser-use==0.1.48
browser-use==0.9.4
pyperclip==1.9.0
gradio==5.27.0
json-repair
langchain-mistralai==0.2.4
gradio==5.49.1
json-repair==0.49.0
MainContentExtractor==0.0.4
langchain-ibm==0.3.10
langchain_mcp_adapters==0.0.9
langgraph==0.3.34
langchain-community
34 changes: 7 additions & 27 deletions src/agent/browser_use/browser_use_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@

# from lmnr.sdk.decorators import observe
from browser_use.agent.gif import create_history_gif
from browser_use.agent.service import Agent, AgentHookFunc
from browser_use import Agent
from browser_use.agent.service import AgentHookFunc
from browser_use.agent.views import (
ActionResult,
AgentHistory,
AgentHistoryList,
AgentStepInfo,
ToolCallingMethod,
)
from browser_use.browser.views import BrowserStateHistory
from browser_use.utils import time_execution_async
from dotenv import load_dotenv
from browser_use.agent.message_manager.utils import is_model_without_tool_support
# is_model_without_tool_support removed in browser_use 0.6.0

load_dotenv()
logger = logging.getLogger(__name__)
Expand All @@ -28,16 +28,13 @@


class BrowserUseAgent(Agent):
def _set_tool_calling_method(self) -> ToolCallingMethod | None:
def _set_tool_calling_method(self) -> str | None:
tool_calling_method = self.settings.tool_calling_method
if tool_calling_method == 'auto':
if is_model_without_tool_support(self.model_name):
return 'raw'
elif self.chat_model_library == 'ChatGoogleGenerativeAI':
# Simplified logic for browser_use 0.6.0
if self.chat_model_library == 'ChatGoogleGenerativeAI':
return None
elif self.chat_model_library == 'ChatOpenAI':
return 'function_calling'
elif self.chat_model_library == 'AzureChatOpenAI':
elif self.chat_model_library in ['ChatOpenAI', 'AzureChatOpenAI']:
return 'function_calling'
else:
return None
Expand Down Expand Up @@ -141,23 +138,6 @@ async def run(
# Unregister signal handlers before cleanup
signal_handler.unregister()

if self.settings.save_playwright_script_path:
logger.info(
f'Agent run finished. Attempting to save Playwright script to: {self.settings.save_playwright_script_path}'
)
try:
# Extract sensitive data keys if sensitive_data is provided
keys = list(self.sensitive_data.keys()) if self.sensitive_data else None
# Pass browser and context config to the saving method
self.state.history.save_as_playwright_script(
self.settings.save_playwright_script_path,
sensitive_data_keys=keys,
browser_config=self.browser.config,
context_config=self.browser_context.config,
)
except Exception as script_gen_err:
# Log any error during script generation/saving
logger.error(f'Failed to save Playwright script: {script_gen_err}', exc_info=True)

await self.close()

Expand Down
Loading