"""
应用全局配置 - 从 .env 读取环境变量
"""

from pydantic_settings import BaseSettings, SettingsConfigDict


class Settings(BaseSettings):
    model_config = SettingsConfigDict(
        env_file=".env",
        env_file_encoding="utf-8",
        case_sensitive=False,
    )

    # Database
    DATABASE_URL: str = "postgresql+asyncpg://postgres:postgres@localhost:5432/crm_erp"

    # JWT
    JWT_SECRET_KEY: str = "super-secret-key-change-in-production-please"
    JWT_ALGORITHM: str = "HS256"
    JWT_ACCESS_TOKEN_EXPIRE_MINUTES: int = 1440  # 24h

    # App
    APP_NAME: str = "润滑油CRM/ERP系统"
    APP_VERSION: str = "0.1.0"
    DEBUG: bool = True

    # Dify AI 中枢配置
    DIFY_API_BASE_URL: str = ""        # 例如 http://192.168.1.88
    DIFY_API_KEY: str = ""
    DIFY_APP_ID: str = ""
    DIFY_TIMEOUT_MS: int = 30000       # 30s
    DIFY_WORKFLOW_PERSONA_KEY: str = "" # 销售日志→客户画像 Workflow
    DIFY_WORKFLOW_REPORT_KEY: str = ""  # 周报自动生成 Workflow

    # Ollama / vLLM 算力节点
    OLLAMA_4060_BASE_URL: str = "http://192.168.1.88:11435"   # 4060: Qwen3.5-4B + BGE-M3
    OLLAMA_4060_MODEL: str = "qwen3.5:4b"                     # 意图分类用
    OLLAMA_3090_BASE_URL: str = "http://192.168.1.88:11434"   # 3090: Qwen3.5-27B (with vision)
    OLLAMA_3090_MODEL: str = "qwen3.5:27b"                    # OCR / 视觉理解用


settings = Settings()
