feat: add OcrSettings scope configuration

This commit is contained in:
2026-07-21 22:45:12 -04:00
parent dfbb2f8f10
commit 1231226205
2 changed files with 71 additions and 0 deletions
+26
View File
@@ -407,3 +407,29 @@ class EmbeddingSettings:
normalize=bool(_cast(norm[1], "bool", norm[0])) if norm else False,
expected_dim=expected_dim,
)
@dataclass(frozen=True)
class OcrSettings:
"""OCR scope 装配配置(M3 设计 §3.4): 复用 GatewaySettings,无 OCR 专用键。
cache/structured/pricing 键对 OCR 无意义,装配时忽略;TPM 闸不启用
(tpm=0)、看门狗键不配(非流式)由源键缺省自然达成。api_key 惯例填
"none"(MonkeyOCR 无鉴权,SourceConfig 非空校验用占位)。
"""
gateway: GatewaySettings
@classmethod
def from_env(
cls,
scope: str = "OCR",
env: Mapping[str, str] | None = None,
*,
env_file: str = ".env",
) -> OcrSettings:
if env is None:
env = {
k: v for k, v in {**dotenv_values(env_file), **os.environ}.items() if v is not None
}
return cls(gateway=GatewaySettings.from_env(scope.upper(), env=env))