mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-03 20:12:55 +00:00
Review follow-up. The per-group secret validators normalised a hand-picked list of API keys, which left other optional credentials and overrides (OPEN_ROUTER_API_KEY, S3 and Daytona keys, ELASTIC_PASSWORD, the OIDC trio, connector client ids, MICROSOFT_AUTHORITY, MCP_OAUTH_REDIRECT_URI) holding the literal "None" or "" a .env file spells "unset" with, so truthiness checks and fallbacks downstream saw a value. One rule on the group base replaces those lists: every Optional[str] field maps "", "None" and whitespace to None and strips real values. Plain str fields are left alone. The OIDC required-settings check therefore also rejects those spellings. EMBEDDINGS_POOLING is Literal["cls", "mean"] with case-insensitive parsing; its consumer silently ignored anything else. Bounds added where the consumer rejects or misbehaves on the value: SCHEDULE_RUN_OUTPUT_RETENTION_DAYS and MESSAGE_EVENTS_RETENTION_DAYS (the cleanup repositories raise on <= 0), EMBEDDINGS_DELEGATE_TIMEOUT, the remote-device idle/pairing/invocation TTLs and CELERY_VISIBILITY_TIMEOUT (> 0), REMOTE_DEVICE_CMD_QUEUE_TTL_SECONDS (> 605, the documented drain deadline), GRAPHRAG_MAX_CHUNKS_FOR_EXTRACTION (>= 0; negative would slice the pending list from the end). The generated reference now renders generic type arguments (dict[str, int] rather than dict).
40 lines
1.6 KiB
Python
40 lines
1.6 KiB
Python
"""Celery broker, result backend and worker process limits."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pydantic import Field
|
|
|
|
from docsgpt.core.settings._shared import SettingsGroup
|
|
|
|
|
|
class WorkerSettings(SettingsGroup):
|
|
"""How background tasks are queued and how worker processes are recycled."""
|
|
|
|
CELERY_BROKER_URL: str = Field(default="redis://localhost:6379/0", description="Celery broker URL.")
|
|
CELERY_RESULT_BACKEND: str = Field(default="redis://localhost:6379/1", description="Celery result backend URL.")
|
|
CELERY_WORKER_PREFETCH_MULTIPLIER: int = Field(
|
|
default=1, description="Tasks prefetched per worker process; 1 caps SIGKILL loss to one task."
|
|
)
|
|
CELERY_VISIBILITY_TIMEOUT: int = Field(
|
|
default=3600,
|
|
gt=0,
|
|
description=(
|
|
"Broker visibility timeout in seconds. Must exceed the longest legitimate task runtime but stay "
|
|
"short enough that SIGKILLed tasks redeliver promptly."
|
|
),
|
|
)
|
|
CELERY_WORKER_MAX_MEMORY_PER_CHILD: int = Field(
|
|
default=4194304,
|
|
ge=0,
|
|
description=(
|
|
"Recycle a prefork child past this resident size in KB; backstops docling/torch heap growth. "
|
|
"Checked between tasks, so it does not bound the peak within one. 0 disables."
|
|
),
|
|
)
|
|
CELERY_WORKER_MAX_TASKS_PER_CHILD: int = Field(
|
|
default=0, ge=0, description="Recycle a worker child after N tasks; 0 disables."
|
|
)
|
|
API_URL: str = Field(
|
|
default="http://localhost:7091", description="Backend URL the Celery worker calls back into."
|
|
)
|