feat: add OcrSettings scope configuration
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user