初始化提交
This commit is contained in:
commit
887c1f449e
963 files changed
+166869
No files matched your search
@@ -0,0 +1,53 @@
|
||||
"""应用基础配置:运行环境、端口、CORS、默认模型提示等。"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Literal
|
||||
|
||||
from pydantic_settings import BaseSettings
|
||||
|
||||
|
||||
class AppConfig(BaseSettings):
|
||||
"""应用基础配置。"""
|
||||
|
||||
# ==================== 基础配置 ====================
|
||||
app_name: str = "魂镜后端" # 应用名称
|
||||
app_env: Literal["dev", "prod"] = "dev" # 运行环境:dev(开发) / prod(生产)
|
||||
debug: bool = False # 调试模式
|
||||
timezone: str = "Asia/Shanghai" # 时区
|
||||
api_prefix: str = "/api/v1" # API 路由前缀
|
||||
backend_host: str = "0.0.0.0" # 监听地址
|
||||
backend_port: int = 8000 # 监听端口
|
||||
cors_allow_origins: str = "http://localhost:3000" # CORS 允许的源,逗号分隔
|
||||
|
||||
# ==================== 业务默认值 ====================
|
||||
default_owner_scope: str = "local-user" # 默认所有者作用域
|
||||
default_model_hint: str = "deepseek-v4-flash" # 默认真实远程逻辑模型提示
|
||||
|
||||
# ==================== 默认人物模板配置 ====================
|
||||
character_templates_path: str = (
|
||||
"../config/character_templates.yaml" # 人物模板配置文件路径(相对 backend)
|
||||
)
|
||||
|
||||
# ==================== 文件存储 ====================
|
||||
avatar_dir: str = "../db/avatars" # 角色头像文件存储目录(相对 backend)
|
||||
|
||||
# ==================== 默认管理员用户 ====================
|
||||
default_admin_username: str = "admin" # 种子默认管理员用户名
|
||||
default_admin_email: str = "admin@hunjing.local" # 种子默认管理员邮箱
|
||||
default_admin_password: str = "admin123" # 种子默认管理员密码(引导用,生产立即修改)
|
||||
|
||||
@property
|
||||
def cors_origins(self) -> list[str]:
|
||||
"""解析 CORS 允许的源为列表。"""
|
||||
return [origin.strip() for origin in self.cors_allow_origins.split(",") if origin.strip()]
|
||||
|
||||
@property
|
||||
def is_development(self) -> bool:
|
||||
"""是否为开发环境。"""
|
||||
return self.app_env == "dev"
|
||||
|
||||
@property
|
||||
def is_production(self) -> bool:
|
||||
"""是否为生产环境。"""
|
||||
return self.app_env == "prod"
|
||||
Reference in new issue
Block a user