| 1234567891011121314151617181920212223242526 |
- from pathlib import Path
- from typing import Any
- from app.config import get_settings
- from app.core.logging import logger
- settings = get_settings()
- async def download_model(model_id: str, use_modelscope: bool = False) -> dict[str, Any]:
- """从 HF 或 ModelScope 下载模型到本地缓存。"""
- logger.info(f"Downloading model {model_id} (modelscope={use_modelscope})")
- return {"model_id": model_id, "status": "downloading"}
- def list_cached_models() -> list[dict[str, Any]]:
- """列出本地已缓存的模型。"""
- models_dir = settings.models_dir
- if not models_dir.exists():
- return []
- return [{"id": d.name, "path": str(d)} for d in models_dir.iterdir() if d.is_dir()]
- def get_model_info(model_id: str) -> dict[str, Any] | None:
- """获取已缓存模型的元数据。"""
- return None
|