refactor(browser): migrate browser config to use BrowserProfile API
This commit is contained in:
1 parent
0fab25c80f
commit
b35b66ad90
2 files changed
+5
-6
No files matched your search
Binary file not shown.
@@ -7,9 +7,8 @@ import asyncio
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
from fastapi import FastAPI, HTTPException
|
from fastapi import FastAPI, HTTPException
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from browser_use import Agent, Browser, ChatOpenAI
|
from browser_use import Agent, Browser, BrowserProfile, ChatOpenAI
|
||||||
from browser_use.agent.views import AgentHistoryList
|
from browser_use.agent.views import AgentHistoryList
|
||||||
from browser_use.browser.context import BrowserContextConfig, BrowserConfig
|
|
||||||
import uvicorn
|
import uvicorn
|
||||||
from fastapi.responses import HTMLResponse
|
from fastapi.responses import HTMLResponse
|
||||||
|
|
||||||
@@ -72,8 +71,8 @@ async def run_browser_task(task_id: str, task: str, max_steps: int, model: str):
|
|||||||
api_key=api_key
|
api_key=api_key
|
||||||
)
|
)
|
||||||
|
|
||||||
# Настройки браузера
|
# Настройки браузера через BrowserProfile
|
||||||
browser_config = BrowserConfig(
|
browser_profile = BrowserProfile(
|
||||||
user_data_dir="/app/browser-data",
|
user_data_dir="/app/browser-data",
|
||||||
profile_directory="Default",
|
profile_directory="Default",
|
||||||
headless=True,
|
headless=True,
|
||||||
@@ -81,12 +80,12 @@ async def run_browser_task(task_id: str, task: str, max_steps: int, model: str):
|
|||||||
|
|
||||||
# Добавляем remote debugging если включено
|
# Добавляем remote debugging если включено
|
||||||
if REMOTE_DEBUGGING_ENABLED:
|
if REMOTE_DEBUGGING_ENABLED:
|
||||||
browser_config.extra_chromium_args = [
|
browser_profile.extra_chromium_args = [
|
||||||
f"--remote-debugging-port={REMOTE_DEBUGGING_PORT}",
|
f"--remote-debugging-port={REMOTE_DEBUGGING_PORT}",
|
||||||
"--remote-debugging-address=0.0.0.0"
|
"--remote-debugging-address=0.0.0.0"
|
||||||
]
|
]
|
||||||
|
|
||||||
browser = Browser(config=browser_config)
|
browser = Browser(browser_profile=browser_profile)
|
||||||
|
|
||||||
# Создание агента
|
# Создание агента
|
||||||
agent = Agent(
|
agent = Agent(
|
||||||
|
|||||||
Reference in new issue
Block a user