Skip to content

Commit 0b822fa

Browse files
committed
add webui and readme
1 parent 2024ad3 commit 0b822fa

File tree

6 files changed

+391
-9
lines changed

6 files changed

+391
-9
lines changed

.env.example

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,7 @@ AZURE_OPENAI_API_KEY=
1212
ANONYMIZED_TELEMETRY=true
1313

1414
# LogLevel: Set to debug to enable verbose logging, set to result to get results only. Available: result | debug | info
15-
BROWSER_USE_LOGGING_LEVEL=info
15+
BROWSER_USE_LOGGING_LEVEL=info
16+
17+
CHROME_PATH=
18+
CHROME_USER_DATA=

README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Browser-Use WebUI
2+
3+
## Background
4+
5+
This project builds upon the foundation of the [browser-use](https://github.com/browser-use/browser-use), which is designed to make websites accessible for AI agents. We have enhanced the original capabilities by providing:
6+
7+
1. **A Brand New WebUI:** We offer a comprehensive web interface that supports a wide range of `browser-use` functionalities. This UI is designed to be user-friendly and enables easy interaction with the browser agent.
8+
9+
2. **Expanded LLM Support:** We've integrated support for various Large Language Models (LLMs), including: Gemini, OpenAI, Azure OpenAI, Anthropic etc. And we plan to add support for even more models in the future.
10+
11+
3. **Custom Browser Support:** You can use your own browser with our tool, eliminating the need to re-login to sites or deal with other authentication challenges. This feature also supports high-definition screen recording.
12+
13+
4. **Customized Agent:** We've implemented a custom agent that enhances `browser-use` with Optimized prompts.
14+
15+
<video src="https://github.com/user-attachments/assets/cc4ca59f-e4a5-43d8-86db-bb0e6edbedef" controls="controls" width="500" height="300" >Your browser does not support playing this video!</video>
16+
17+
## Environment Installation
18+
19+
1. **Python Version:** Ensure you have Python 3.11 or higher installed.
20+
2. **Install `browser-use`:**
21+
```bash
22+
pip install browser-use
23+
```
24+
3. **Install Playwright:**
25+
```bash
26+
playwright install
27+
```
28+
4. **Install Dependencies:**
29+
```bash
30+
pip install -r requirements.txt
31+
```
32+
5. **Configure Environment Variables:**
33+
- Copy `.env.example` to `.env` and set your environment variables, including API keys for the LLM.
34+
- **If using your own browser:**
35+
- Set `CHROME_PATH` to the executable path of your browser (e.g., `C:\Program Files\Google\Chrome\Application\chrome.exe` on Windows).
36+
- Set `CHROME_USER_DATA` to the user data directory of your browser (e.g.,`C:\Users\<YourUsername>\AppData\Local\Google\Chrome\User Data`).
37+
38+
## Usage
39+
40+
1. **Run the WebUI:**
41+
```bash
42+
python webui.py --ip 127.0.0.1 --port 7788
43+
```
44+
2. **Access the WebUI:** Open your web browser and navigate to `http://127.0.0.1:7788`.
45+
3. **Using Your Own Browser:**
46+
- Open the WebUI in a non-Chrome browser, such as Firefox or Edge. This is important because the persistent browser context will use the Chrome data when running the agent.
47+
- Check the "Use Own Browser" option within the Browser Settings.

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
browser-use
22
langchain-google-genai
33
pyperclip
4+
gradio

src/utils/utils.py

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
# @FileName: utils.py
77

88
import base64
9+
import os
10+
911
from langchain_openai import ChatOpenAI, AzureChatOpenAI
1012
from langchain_anthropic import ChatAnthropic
1113
from langchain_google_genai import ChatGoogleGenerativeAI
@@ -19,32 +21,64 @@ def get_llm_model(provider: str, **kwargs):
1921
:return:
2022
"""
2123
if provider == 'anthropic':
24+
if not kwargs.get("base_url", ""):
25+
base_url = "https://api.anthropic.com"
26+
else:
27+
base_url = kwargs.get("base_url")
28+
29+
if not kwargs.get("api_key", ""):
30+
api_key = os.getenv("ANTHROPIC_API_KEY", "")
31+
else:
32+
api_key = kwargs.get("api_key")
33+
2234
return ChatAnthropic(
2335
model_name=kwargs.get("model_name", 'claude-3-5-sonnet-20240620'),
2436
temperature=kwargs.get("temperature", 0.0),
25-
base_url=kwargs.get("base_url", "https://api.anthropic.com"),
26-
api_key=kwargs.get("api_key", None)
37+
base_url=base_url,
38+
api_key=api_key
2739
)
2840
elif provider == 'openai':
41+
if not kwargs.get("base_url", ""):
42+
base_url = "https://api.openai.com/v1"
43+
else:
44+
base_url = kwargs.get("base_url")
45+
46+
if not kwargs.get("api_key", ""):
47+
api_key = os.getenv("OPENAI_API_KEY", "")
48+
else:
49+
api_key = kwargs.get("api_key")
50+
2951
return ChatOpenAI(
3052
model=kwargs.get("model_name", 'gpt-4o'),
3153
temperature=kwargs.get("temperature", 0.0),
32-
base_url=kwargs.get("base_url", "https://api.openai.com/v1/"),
33-
api_key=kwargs.get("api_key", None)
54+
base_url=base_url,
55+
api_key=api_key
3456
)
3557
elif provider == 'gemini':
58+
if not kwargs.get("api_key", ""):
59+
api_key = os.getenv("GOOGLE_API_KEY", "")
60+
else:
61+
api_key = kwargs.get("api_key")
3662
return ChatGoogleGenerativeAI(
3763
model=kwargs.get("model_name", 'gemini-2.0-flash-exp'),
3864
temperature=kwargs.get("temperature", 0.0),
39-
google_api_key=kwargs.get("api_key", None),
65+
google_api_key=api_key,
4066
)
4167
elif provider == "azure_openai":
68+
if not kwargs.get("base_url", ""):
69+
base_url = os.getenv("AZURE_OPENAI_ENDPOINT", "")
70+
else:
71+
base_url = kwargs.get("base_url")
72+
if not kwargs.get("api_key", ""):
73+
api_key = os.getenv("AZURE_OPENAI_API_KEY", "")
74+
else:
75+
api_key = kwargs.get("api_key")
4276
return AzureChatOpenAI(
4377
model=kwargs.get("model_name", 'gpt-4o'),
4478
temperature=kwargs.get("temperature", 0.0),
4579
api_version="2024-05-01-preview",
46-
azure_endpoint=kwargs.get("base_url", ""),
47-
api_key=kwargs.get("api_key", None)
80+
azure_endpoint=base_url,
81+
api_key=api_key
4882
)
4983
else:
5084
raise ValueError(f'Unsupported provider: {provider}')

tests/test_browser_use.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ async def test_browser_use_custom():
106106
)
107107

108108
controller = CustomController()
109-
use_own_browser = True
109+
use_own_browser = False
110110
disable_security = True
111111
playwright = None
112112
browser_context_ = None

0 commit comments

Comments
 (0)