mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-03 09:12:55 +00:00
docsgpt/core/settings.py had grown to 258 fields in one 600-line class, touched by about two commits a week, with related settings scattered (GitHub ingest caps inside the embeddings block, API keys in four places, the OpenAI Responses knobs 100 lines from the other OpenAI fields). It is now a package: one module per domain (auth, llm, embeddings, retrieval, vectorstores, database, workers, ingestion, ocr, storage, connectors, server, events, agents, guardrails, scheduler, sandbox, speech), each a SettingsGroup owning its fields and validators, composed by multiple inheritance into the same flat Settings class. Every attribute name, type, default, alias and constraint is unchanged, so settings.NAME reads, .env files and test monkeypatches all keep working; the import path docsgpt.core.settings is the package. Settings.normalize_api_key is kept as a classmethod for callers that reuse it. The comment above or beside each field became its Field(description=...), so the definitions are visible to tooling; the next commit generates the docs reference from them. Pitfall recorded for future groups: pydantic collects validators by method name across the MRO, so two groups naming a validator the same would silently keep only one. Each group's validator has a unique name.
40 lines
1.5 KiB
Python
40 lines
1.5 KiB
Python
"""The API process itself."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Optional
|
|
|
|
from pydantic import Field
|
|
|
|
from docsgpt.core.settings._shared import SettingsGroup
|
|
|
|
|
|
class ServerSettings(SettingsGroup):
|
|
"""Serving the UI, public URLs, and process-level knobs of the API server."""
|
|
|
|
SERVE_UI: bool = Field(
|
|
default=True, description="Serve the web UI shipped in the package (docsgpt/static) from the API process."
|
|
)
|
|
FLASK_DEBUG_MODE: bool = Field(default=False, description="Run Flask in debug mode.")
|
|
VERSION_CHECK: bool = Field(default=True, description="Anonymous startup version check for security issues.")
|
|
PUBLIC_API_BASE_URL: Optional[str] = Field(
|
|
default=None, description="Public base URL for user-facing endpoint references in prompts."
|
|
)
|
|
GRACEFUL_SHUTDOWN_TIMEOUT_SECONDS: int = Field(
|
|
default=30,
|
|
description=(
|
|
"Bounds uvicorn's shutdown drain (uvicorn_worker doesn't forward --graceful-timeout). Keep below the "
|
|
"gunicorn --timeout (180) watchdog. Used by BoundedDrainUvicornWorker."
|
|
),
|
|
)
|
|
WSGI_THREADPOOL_WORKERS: int = Field(
|
|
default=96, description="Threads serving the WSGI (Flask) part of the app under the ASGI server."
|
|
)
|
|
V1_SESSION_TTL_SECONDS: int = Field(
|
|
default=24 * 60 * 60,
|
|
description=(
|
|
"Lets OpenAI-compatible clients identify a logical chat by session header, which chat-completions "
|
|
"itself has no field for; TTL of that session mapping."
|
|
),
|
|
)
|