deploy Nous v22 update
This commit is contained in:
@@ -98,9 +98,15 @@ def investigate_websites(
|
||||
model: str,
|
||||
user_agent: str,
|
||||
log_callback: Callable[[str, str, dict[str, Any]], Any] | None = None,
|
||||
enabled: bool | None = None,
|
||||
max_steps: int | None = None,
|
||||
timeout_seconds: int | None = None,
|
||||
llm_timeout_seconds: int | None = None,
|
||||
) -> list[dict[str, Any]]:
|
||||
"""Run one bounded Browser Use investigation and return candidates."""
|
||||
if os.environ.get("BROWSER_USE_ENABLED", "1").strip().lower() in {"0", "false", "no", "off"}:
|
||||
if enabled is None:
|
||||
enabled = os.environ.get("BROWSER_USE_ENABLED", "1").strip().lower() not in {"0", "false", "no", "off"}
|
||||
if not enabled:
|
||||
raise RuntimeError("browser_use_disabled")
|
||||
if not base_url or not model:
|
||||
raise RuntimeError("browser_use_requires_ai_provider_and_model")
|
||||
@@ -189,6 +195,10 @@ Confidence must be an integer from 0 to 100. Include only plausible official web
|
||||
enable_default_extensions=False,
|
||||
captcha_solver=False,
|
||||
)
|
||||
try:
|
||||
llm_timeout = max(10, min(300, int(llm_timeout_seconds if llm_timeout_seconds is not None else os.environ.get("BROWSER_USE_LLM_TIMEOUT_SECONDS", "90"))))
|
||||
except (TypeError, ValueError):
|
||||
llm_timeout = 45
|
||||
llm = LoggedChatOpenAI(
|
||||
model=model,
|
||||
api_key=api_key,
|
||||
@@ -198,7 +208,7 @@ Confidence must be an integer from 0 to 100. Include only plausible official web
|
||||
frequency_penalty=None,
|
||||
max_completion_tokens=900,
|
||||
max_retries=1,
|
||||
timeout=45,
|
||||
timeout=llm_timeout,
|
||||
)
|
||||
agent = Agent(
|
||||
task=task,
|
||||
@@ -212,16 +222,16 @@ Confidence must be an integer from 0 to 100. Include only plausible official web
|
||||
register_new_step_callback=on_step,
|
||||
)
|
||||
try:
|
||||
max_steps = int(os.environ.get("BROWSER_USE_MAX_STEPS", "10"))
|
||||
resolved_steps = int(max_steps if max_steps is not None else os.environ.get("BROWSER_USE_MAX_STEPS", "10"))
|
||||
except (TypeError, ValueError):
|
||||
max_steps = 10
|
||||
return await agent.run(max_steps=max(3, min(15, max_steps)))
|
||||
resolved_steps = 10
|
||||
return await agent.run(max_steps=max(3, min(50, resolved_steps)))
|
||||
|
||||
try:
|
||||
timeout = int(os.environ.get("BROWSER_USE_TIMEOUT_SECONDS", "120"))
|
||||
timeout = int(timeout_seconds if timeout_seconds is not None else os.environ.get("BROWSER_USE_TIMEOUT_SECONDS", "600"))
|
||||
except (TypeError, ValueError):
|
||||
timeout = 120
|
||||
timeout = max(30, min(300, timeout))
|
||||
timeout = 600
|
||||
timeout = max(30, min(1800, timeout))
|
||||
try:
|
||||
history = asyncio.run(asyncio.wait_for(run(), timeout=timeout))
|
||||
except asyncio.TimeoutError as exc:
|
||||
|
||||
Reference in New Issue
Block a user