| | |
| | | from typing import Any, Dict, Optional |
| | | |
| | | import yaml |
| | | from dotenv import load_dotenv |
| | | |
| | | logger = logging.getLogger(__name__) |
| | | |
| | | BASE_DIR = Path(__file__).resolve().parent |
| | | load_dotenv(BASE_DIR / ".env") |
| | | |
| | | CONFIG_PATH = BASE_DIR / "config.yaml" |
| | | CONFIG_EXAMPLE_PATH = BASE_DIR / "config.yaml.example" |
| | | |
| | |
| | | "models": { |
| | | "llm": "ark-code-latest", |
| | | "vlm": "ark-code-latest", |
| | | "image_it2i": "doubao-seedream-5-0-260128", |
| | | "image_t2i": "doubao-seedream-5-0-260128", |
| | | "video": "wan2.7-i2v", |
| | | "video_first_frame": "wan2.7-i2v", |
| | | "image_it2i": "ep-20260510144546-hwrtr", |
| | | "image_t2i": "ep-20260510144546-hwrtr", |
| | | "video": "doubao-seedance-2-0-mini-260615", |
| | | "video_first_frame": "doubao-seedance-2-0-mini-260615", |
| | | "video_start_end": "wan2.7-i2v", |
| | | "video_reference": "wan2.7-r2v", |
| | | }, |
| | |
| | | |
| | | def _coerce_config(data: Dict[str, Any]) -> Dict[str, Any]: |
| | | clean = _deep_merge(DEFAULT_CONFIG, data) |
| | | |
| | | # 允许使用环境变量(如 .env)来覆盖 API 秘钥配置 |
| | | if "api_providers" in clean: |
| | | for provider, values in clean["api_providers"].items(): |
| | | if provider == "common" or not isinstance(values, dict): |
| | | continue |
| | | for key in values.keys(): |
| | | env_key = f"{provider.upper()}_{key.upper()}" |
| | | if os.getenv(env_key): |
| | | values[key] = os.getenv(env_key) |
| | | clean.pop("llm", None) |
| | | raw_server = data.get("server", {}) if isinstance(data, dict) else {} |
| | | |