| 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 | """ |
| 14 | API Configuration |
| 15 | """ |
| 16 | |
| 17 | from typing import Optional |
| 18 | from pydantic import BaseModel |
| 19 | |
| 20 | |
| 21 | class APIConfig(BaseModel): |
| 22 | """API configuration""" |
| 23 | |
| 24 | # Server settings |
| 25 | host: str = "0.0.0.0" |
| 26 | port: int = 8000 |
| 27 | reload: bool = False |
| 28 | |
| 29 | # CORS settings |
| 30 | cors_enabled: bool = True |
| 31 | cors_origins: list[str] = ["*"] |
| 32 | |
| 33 | # Task settings |
| 34 | max_concurrent_tasks: int = 5 |
| 35 | task_cleanup_interval: int = 3600 # Clean completed tasks every hour |
| 36 | task_retention_time: int = 86400 # Keep task results for 24 hours |
| 37 | |
| 38 | # File upload settings |
| 39 | max_upload_size: int = 100 * 1024 * 1024 # 100MB |
| 40 | |
| 41 | # API settings |
| 42 | api_prefix: str = "/api" |
| 43 | docs_url: Optional[str] = "/docs" |
| 44 | redoc_url: Optional[str] = "/redoc" |
| 45 | openapi_url: Optional[str] = "/openapi.json" |
| 46 | |
| 47 | |
| 48 | # Global config instance |
| 49 | api_config = APIConfig() |
| 50 | |
| 51 |