Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
56 changes: 40 additions & 16 deletions backend/app/webrover.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ def set_env_vars(var):

mark_page_path = os.path.join(current_dir, "static", "mark_page.js")

# Path to the local Chrome executable
chrome_path = os.getenv("CHROME_PATH")

# Path to the existing Chrome user data directory
user_data_dir = os.getenv("CHROME_USER_DATA")


class Bbox(TypedDict):
Expand Down Expand Up @@ -203,23 +208,42 @@ async def setup_browser_2(go_to_page: str):
"locale": 'en-US',
"timezone_id": 'America/Los_Angeles',
}

if chrome_path and user_data_dir:
browser = await playwright.chromium.launch_persistent_context(
user_data_dir=user_data_dir,
executable_path=chrome_path,
headless=False,
args=browser_args,
**context_options
)

page = await browser.new_page()

else:
if chrome_path:
browser = await playwright.chromium.launch(
headless=False,
executable_path=chrome_path,
args=browser_args
)
else:
browser = await playwright.chromium.launch(
headless=False,
args=browser_args
)

browser = await playwright.chromium.launch(
headless=False,
args=browser_args
)

# Create context with the specified options
context = await browser.new_context(**context_options)

# Enable JavaScript and cookies
await context.add_init_script("""
Object.defineProperty(navigator, 'webdriver', {
get: () => undefined
});
""")

page = await context.new_page()
# Create context with the specified options
context = await browser.new_context(**context_options)

# Enable JavaScript and cookies
await context.add_init_script("""
Object.defineProperty(navigator, 'webdriver', {
get: () => undefined
});
""")

page = await context.new_page()

try:
await page.goto(go_to_page, timeout=80000, wait_until="domcontentloaded")
Expand Down
19 changes: 17 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,22 @@ The agent comes equipped with several tools to interact with web pages:
LANGCHAIN_PROJECT="your_project_name"
```

5. Run the backend:
5. Using Your Own Browser(Optional):
- Set `CHROME_PATH` to the executable path of your browser and `CHROME_USER_DATA` to the user data directory of your browser.
- Windows
```env
CHROME_PATH="C:\Program Files\Google\Chrome\Application\chrome.exe"
CHROME_USER_DATA="C:\Users\YourUsername\AppData\Local\Google\Chrome\User Data"
```
> Note: Replace `YourUsername` with your actual Windows username for Windows systems.
- Mac
```env
CHROME_PATH="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
CHROME_USER_DATA="~/Library/Application Support/Google/Chrome/Profile 1"
```
- go to chrome://version/ in Chrome, find the path to your chrome executable and user data (Profile Path) directory.

6. Run the backend:

Make sure you are in the backend folder

Expand All @@ -172,7 +187,7 @@ The agent comes equipped with several tools to interact with web pages:
uvicorn app.main:app --port 8000
```

6. Access the API at `http://localhost:8000`
7. Access the API at `http://localhost:8000`

## Frontend Setup

Expand Down