import os
from typing import Any
import yaml


def load_config() -> dict[str, Any]:
    """从配置文件加载配置

    Returns:
        dict[str, Any]: 应用配置字典

    Raises:
        ValueError: 配置文件加载错误
    """
    config_path = os.environ.get("CONFIG_PATH", "config.yaml")

    try:
        with open(config_path, "r", encoding="utf-8") as f:
            return yaml.safe_load(f)

    except Exception as e:
        raise ValueError(f"加载配置失败: {e}")
