Skip to content

Commit 5303401

Browse files
committed
feat: allow chrome cdp in env
1 parent 4dbf564 commit 5303401

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ CHROME_DEBUGGING_PORT=9222
3737
CHROME_DEBUGGING_HOST=localhost
3838
# Set to true to keep browser open between AI tasks
3939
CHROME_PERSISTENT_SESSION=false
40-
40+
CHROME_CDP=http://localhost:9222
4141
# Display settings
4242
# Format: WIDTHxHEIGHTxDEPTH
4343
RESOLUTION=1920x1080x24

src/utils/deep_research.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ async def deep_research(task, llm, agent_state=None, **kwargs):
4444

4545
use_own_browser = kwargs.get("use_own_browser", False)
4646
extra_chromium_args = []
47+
cdp_url = None
4748
if use_own_browser:
49+
cdp_url = os.getenv("CHROME_CDP", None)
4850
# TODO: if use own browser, max query num must be 1 per iter, how to solve it?
4951
max_query_num = 1
5052
chrome_path = os.getenv("CHROME_PATH", None)
@@ -57,6 +59,7 @@ async def deep_research(task, llm, agent_state=None, **kwargs):
5759
browser = CustomBrowser(
5860
config=BrowserConfig(
5961
headless=kwargs.get("headless", False),
62+
cdp_url=cdp_url,
6063
disable_security=kwargs.get("disable_security", True),
6164
chrome_instance_path=chrome_path,
6265
extra_chromium_args=extra_chromium_args,

webui.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,9 @@ async def run_org_agent(
282282
_global_agent_state.clear_stop()
283283

284284
extra_chromium_args = [f"--window-size={window_w},{window_h}"]
285+
cdp_url = None
285286
if use_own_browser:
287+
cdp_url = os.getenv("CHROME_CDP", None)
286288
chrome_path = os.getenv("CHROME_PATH", None)
287289
if chrome_path == "":
288290
chrome_path = None
@@ -296,6 +298,7 @@ async def run_org_agent(
296298
_global_browser = Browser(
297299
config=BrowserConfig(
298300
headless=headless,
301+
cdp_url=cdp_url,
299302
disable_security=disable_security,
300303
chrome_instance_path=chrome_path,
301304
extra_chromium_args=extra_chromium_args,
@@ -379,7 +382,10 @@ async def run_custom_agent(
379382
_global_agent_state.clear_stop()
380383

381384
extra_chromium_args = [f"--window-size={window_w},{window_h}"]
385+
cdp_url = None
382386
if use_own_browser:
387+
cdp_url = os.getenv("CHROME_CDP", None)
388+
383389
chrome_path = os.getenv("CHROME_PATH", None)
384390
if chrome_path == "":
385391
chrome_path = None
@@ -397,6 +403,7 @@ async def run_custom_agent(
397403
config=BrowserConfig(
398404
headless=headless,
399405
disable_security=disable_security,
406+
cdp_url=cdp_url,
400407
chrome_instance_path=chrome_path,
401408
extra_chromium_args=extra_chromium_args,
402409
)
@@ -854,6 +861,15 @@ def update_llm_num_ctx_visibility(llm_provider):
854861
info="Browser window height",
855862
)
856863

864+
865+
save_recording_path = gr.Textbox(
866+
label="Recording Path",
867+
placeholder="e.g. ./tmp/record_videos",
868+
value=config['save_recording_path'],
869+
info="Path to save browser recordings",
870+
interactive=True, # Allow editing only if recording is enabled
871+
)
872+
857873
save_recording_path = gr.Textbox(
858874
label="Recording Path",
859875
placeholder="e.g. ./tmp/record_videos",

0 commit comments

Comments
 (0)