refactor(settings): split Settings into per-domain modules

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.
This commit is contained in:
arc53-machine committed 2026-09-17 11:04:01 +01:00
1 parent fbcf320458
commit c17b23378e
28 files changed
+1355 -603

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
"""Text-to-speech and speech-to-text."""
from __future__ import annotations
from typing import Optional
from pydantic import Field, field_validator
from docsgpt.core.settings._shared import SettingsGroup, normalize_secret
class SpeechSettings(SettingsGroup):
"""Voice providers and transcription options."""
TTS_PROVIDER: str = Field(
default="google_tts", description="Text-to-speech provider: google_tts, elevenlabs, or none to switch it off."
)
ELEVENLABS_API_KEY: Optional[str] = Field(default=None, description="ElevenLabs API key.")
STT_PROVIDER: str = Field(
default="openai", description="Speech-to-text provider: openai, faster_whisper, or none to switch it off."
)
OPENAI_STT_MODEL: str = Field(default="gpt-4o-mini-transcribe", description="OpenAI transcription model.")
STT_LANGUAGE: Optional[str] = Field(default=None, description="Language hint for transcription; unset auto-detects.")
STT_MAX_FILE_SIZE_MB: int = Field(default=50, description="Cap on an audio file accepted for transcription.")
STT_ENABLE_TIMESTAMPS: bool = Field(default=False, description="Return word/segment timestamps.")
STT_ENABLE_DIARIZATION: bool = Field(default=False, description="Label speakers in the transcript.")
@field_validator("ELEVENLABS_API_KEY", mode="before")
@classmethod
def _normalize_speech_secrets(cls, v):
return normalize_secret(v)