|
|
@@ -43,15 +43,9 @@ async def download_model(model_id: str, use_modelscope: bool = False) -> dict[st
|
|
|
"""从 HF 或 ModelScope 下载模型到本地缓存。"""
|
|
|
try:
|
|
|
if use_modelscope:
|
|
|
- import asyncio
|
|
|
from modelscope import snapshot_download as ms_download
|
|
|
|
|
|
- download_dir = str(settings.models_dir / model_id.replace("/", "_"))
|
|
|
-
|
|
|
- # 在线程池中同步执行,避免与 asyncio 事件循环冲突
|
|
|
- local_path = await asyncio.to_thread(
|
|
|
- ms_download, model_id, cache_dir=download_dir
|
|
|
- )
|
|
|
+ local_path = ms_download(model_id, cache_dir=str(settings.models_dir))
|
|
|
else:
|
|
|
from huggingface_hub import snapshot_download
|
|
|
|