From 6e87366d21244d6cb537cd47a49b7e7f880862e1 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Sat, 31 Oct 2026 08:55:46 +0900 Subject: [PATCH] refac --- README.md | 2 ++ cptr/utils/ai.py | 6 +++--- cptr/utils/chat_task.py | 1 - 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 55cb78d..48cf63d 100644 --- a/README.md +++ b/README.md @@ -176,6 +176,8 @@ Then open the URL printed in the logs, usually `http://localhost:8000/?token=... Open WebUI Computer stores its state in `/data`. Mount your project into the container, like `-v "$PWD:/workspace"`, so Open WebUI Computer can access it. The default image includes Git and GitHub CLI (`gh`). Use `ghcr.io/open-webui/computer:browser` when agent browser automation needs Chromium. +Non-streaming utility tasks also use the `CPTR_STREAM_*` timeout settings. For slow models, increase `CPTR_STREAM_READ_TIMEOUT` (default: 300 seconds), for example with `-e CPTR_STREAM_READ_TIMEOUT=14400` in `docker run`. Restart Computer after changing this setting; Open WebUI and reverse proxies may have their own timeouts. + If you bind-mount a host directory to `/data`, make sure that directory is writable by the container user. SQLite needs to create and update `/data/app.db`, and host directory permissions take precedence over the image's built-in `/data` ownership. To connect a host-running OpenCode server from Docker, start OpenCode on a host-reachable interface and set the OpenCode agent Server URL to the Docker host address: diff --git a/cptr/utils/ai.py b/cptr/utils/ai.py index c1986f7..2484556 100644 --- a/cptr/utils/ai.py +++ b/cptr/utils/ai.py @@ -133,7 +133,7 @@ async def chat_completion( Works with Anthropic, OpenAI Chat Completions, and OpenAI Responses API. Useful for lightweight tasks like title/summary generation. """ - async with httpx.AsyncClient(timeout=httpx.Timeout(15)) as client: + async with httpx.AsyncClient(timeout=_STREAM_TIMEOUT) as client: if provider == "anthropic": body: dict = { "model": model, @@ -241,7 +241,7 @@ async def generate_text( active_connection: dict | None = None, active_model: str = "", request_params: dict | None = None, - timeout_seconds: float = 20, + timeout_seconds: float = STREAM_READ_TIMEOUT_SECONDS, ) -> str | None: """Generate text; model_id None inherits active/default.""" from cptr.models import Config @@ -313,7 +313,7 @@ async def generate_json( active_connection: dict | None = None, active_model: str = "", request_params: dict | None = None, - timeout_seconds: float = 20, + timeout_seconds: float = STREAM_READ_TIMEOUT_SECONDS, ) -> dict | None: from cptr.utils.json_parser import extract_json diff --git a/cptr/utils/chat_task.py b/cptr/utils/chat_task.py index 4937ba6..bae026e 100644 --- a/cptr/utils/chat_task.py +++ b/cptr/utils/chat_task.py @@ -836,7 +836,6 @@ async def review_tool_approval( ], system=TOOL_APPROVAL_REVIEW_PROMPT, max_tokens=150, - timeout_seconds=20, ) decision = str((parsed or {}).get("decision") or "").strip().lower() reason = str((parsed or {}).get("reason") or "").strip()