PMFlow/backend/app/core/config.py

46 lines
1.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.

"""
核心配置
集中管理环境变量和应用配置,遵循 12-factor 原则。
"""
import os
from typing import Optional
from dotenv import load_dotenv
load_dotenv()
class Settings:
"""应用配置(从环境变量读取)"""
# 应用
app_name: str = os.getenv("APP_NAME", "Neural Sync API")
debug: bool = os.getenv("DEBUG", "false").lower() in ("true", "1", "yes")
# 数据库
database_url: str = os.getenv("DATABASE_URL", "sqlite+aiosqlite:///./neural_sync.db")
# JWT
secret_key: str = os.getenv("SECRET_KEY", "your-secret-key-change-in-production")
algorithm: str = os.getenv("JWT_ALGORITHM", "HS256")
access_token_expire_minutes: int = int(os.getenv("ACCESS_TOKEN_EXPIRE_MINUTES", str(60 * 24 * 7)))
# CORS
cors_origins: str = os.getenv("CORS_ORIGINS", "*")
# LLM
llm_provider: str = os.getenv("LLM_PROVIDER", "ollama").lower()
ollama_host: str = os.getenv("OLLAMA_HOST", "http://127.0.0.1:11434")
business_context: Optional[str] = os.getenv("BUSINESS_CONTEXT")
# Redis(可选,用于 AI 结果缓存)
redis_url: Optional[str] = os.getenv("REDIS_URL")
# 多租户(预留)
default_tenant_id: str = os.getenv("DEFAULT_TENANT_ID", "default")
# 全局配置实例
settings = Settings()