config.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. """应用配置管理"""
  2. try:
  3. from pydantic_settings import BaseSettings
  4. except ImportError:
  5. from pydantic import BaseSettings
  6. from typing import Optional
  7. import os
  8. class Settings(BaseSettings):
  9. """应用设置"""
  10. app_name: str = "AI写标书助手"
  11. app_version: str = "2.0.0"
  12. debug: bool = False
  13. enable_file_logging: bool = False
  14. # CORS设置
  15. cors_origins: list = [
  16. "http://localhost:3000",
  17. "http://127.0.0.1:3000",
  18. "http://localhost:3001",
  19. "http://127.0.0.1:3001",
  20. "http://localhost:3002",
  21. "http://127.0.0.1:3002",
  22. "http://localhost:3003",
  23. "http://127.0.0.1:3003",
  24. "http://localhost:3004",
  25. "http://127.0.0.1:3004",
  26. ]
  27. # 文件上传设置
  28. max_file_size: int = 10 * 1024 * 1024 # 10MB
  29. upload_dir: str = "uploads"
  30. # OpenAI默认设置
  31. default_model: str = "gpt-3.5-turbo"
  32. class Config:
  33. env_file = ".env"
  34. # 全局设置实例
  35. settings = Settings()
  36. # 确保上传目录存在
  37. os.makedirs(settings.upload_dir, exist_ok=True)