config.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # Copyright (C) 2025 AIDC-AI
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. # http://www.apache.org/licenses/LICENSE-2.0
  7. # Unless required by applicable law or agreed to in writing, software
  8. # distributed under the License is distributed on an "AS IS" BASIS,
  9. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. # See the License for the specific language governing permissions and
  11. # limitations under the License.
  12. """
  13. API Configuration
  14. """
  15. from typing import Optional
  16. from pydantic import BaseModel
  17. class APIConfig(BaseModel):
  18. """API configuration"""
  19. # Server settings
  20. host: str = "0.0.0.0"
  21. port: int = 8000
  22. reload: bool = False
  23. # CORS settings
  24. cors_enabled: bool = True
  25. cors_origins: list[str] = ["*"]
  26. # Task settings
  27. max_concurrent_tasks: int = 5
  28. task_cleanup_interval: int = 3600 # Clean completed tasks every hour
  29. task_retention_time: int = 86400 # Keep task results for 24 hours
  30. # File upload settings
  31. max_upload_size: int = 100 * 1024 * 1024 # 100MB
  32. # API settings
  33. api_prefix: str = "/api"
  34. docs_url: Optional[str] = "/docs"
  35. redoc_url: Optional[str] = "/redoc"
  36. openapi_url: Optional[str] = "/openapi.json"
  37. # Global config instance
  38. api_config = APIConfig()