Files
leaudit-platform-backend/fastapi_admin/config/_settings.py
T
wren 246c0e5ded feat: complete M1-M3 infrastructure — OSS client, native execution chain, rule lifecycle API, system docs
- M1: unified OSS client (upload/download/presign) + path utils + config
- M2: rule service with validate/create/publish/rollback + binding CRUD endpoints
- M3: native AuditCtx runner, file/rule resolvers, storage adapter with full persistence
- docs: SYSTEM_OVERVIEW.md as comprehensive architecture reference
- fix: double finalize — terminal state now written once by finalize_run
2026-04-28 11:49:55 +08:00

108 lines
2.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Pydantic Settings 定义。
每个 Settings 类对应 app.toml 中的一个 [SECTION]。
字段名 = SECTION_KEYTOML 展平后的环境变量名)。
"""
from __future__ import annotations
from pydantic_settings import BaseSettings
class _Base(BaseSettings):
"""所有 Settings 的基类。"""
model_config = {"env_file": None, "extra": "ignore"}
class AppSettings(_Base):
"""应用基础配置 [APP]。"""
APP_NAME: str = "LeAudit Platform"
APP_HOST: str = "0.0.0.0"
APP_PORT: int = 8000
APP_CORS_ORIGINS: str = "*"
class JwtSettings(_Base):
"""JWT 配置 [JWT]。"""
JWT_SECRET_KEY: str = ""
JWT_ACCESS_TOKEN_EXPIRE_HOURS: int = 24
JWT_ALGORITHM: str = "HS256"
class DbSettings(_Base):
"""数据库配置 [DB]。"""
DB_HOST: str = "localhost"
DB_PORT: int = 5432
DB_NAME: str = "leaudit"
DB_USER: str = "postgres"
DB_PASSWORD: str = ""
@property
def ASYNCPG_DATABASE_URL(self) -> str:
"""动态构建 asyncpg 连接 URL。"""
return (
f"postgresql+asyncpg://{self.DB_USER}:{self.DB_PASSWORD}"
f"@{self.DB_HOST}:{self.DB_PORT}/{self.DB_NAME}"
)
class RedisSettings(_Base):
"""Redis 配置 [REDIS]。"""
REDIS_HOST: str = "localhost"
REDIS_PORT: int = 6379
REDIS_DB: int = 0
REDIS_PASSWORD: str = ""
REDIS_KEY_PREFIX: str = "leaudit"
class OssSettings(_Base):
"""OSS 对象存储配置 [OSS]。"""
OSS_ENDPOINT: str = ""
OSS_BASE_URL: str = ""
OSS_ACCESS_KEY: str = ""
OSS_SECRET_KEY: str = ""
OSS_BUCKET: str = "leaudit"
OSS_REGION: str = ""
OSS_USE_SSL: bool = True
OSS_PRESIGN_EXPIRE_SECONDS: int = 3600
class LlmSettings(_Base):
"""LLM 配置 [LLM]。"""
LLM_BASE_URL: str = ""
LLM_MODEL: str = ""
LLM_API_KEY: str = ""
class VlmSettings(_Base):
"""VLM 配置 [VLM]。"""
VLM_BASE_URL: str = ""
VLM_MODEL: str = ""
VLM_API_KEY: str = ""
class OcrSettings(_Base):
"""OCR 配置 [OCR]。"""
OCR_BASE_URL: str = ""
OCR_TIMEOUT: int = 300
class LeauditSettings(_Base):
"""LeAudit 引擎配置 [LEAUDIT]。"""
LEAUDIT_RULES_DIR: str = "rules"
LEAUDIT_RESCUE_MODE: str = "auto"
LEAUDIT_LLM_MAX_CONCURRENCY: int = 5
LEAUDIT_VLM_MAX_CONCURRENCY: int = 3
# 实例化所有 Settings
app = AppSettings()
jwt = JwtSettings()
db = DbSettings()
redis = RedisSettings()
oss = OssSettings()
llm = LlmSettings()
vlm = VlmSettings()
ocr = OcrSettings()
leaudit = LeauditSettings()