Files
leaudit-platform-backend/fastapi_admin/config/_settings.py
T
wren 535d97a70c chore: initial commit — leaudit-platform project skeleton
17-table PostgreSQL schema with full Chinese column comments,
FastAPI project structure (admin/common/modules),
DSL rule files, and schema migration scripts.
2026-04-27 16:48:22 +08:00

103 lines
2.3 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 = ""
class OssSettings(_Base):
"""OSS 对象存储配置 [OSS]。"""
OSS_ENDPOINT: str = ""
OSS_ACCESS_KEY: str = ""
OSS_SECRET_KEY: str = ""
OSS_BUCKET: str = "leaudit"
OSS_REGION: str = ""
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 = ""
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()