2 Commits
v1.4.1 ... main

Author SHA1 Message Date
z3st
b3b52848c2 fix: verifyResult can be None, ensure dict return 2026-07-22 01:39:33 +08:00
z3st
d6e9f2e7a0 fix: page_size limit 50 for ModelScope API 2026-07-22 01:13:26 +08:00

View File

@@ -121,12 +121,12 @@ def init_db():
# ModelScope 搜索 # ModelScope 搜索
# ============================================================ # ============================================================
def search_models(keyword: str, limit: int = 100) -> list: def search_models(keyword: str, limit: int = 50) -> list:
"""从 ModelScope 搜索模型""" """从 ModelScope 搜索模型"""
url = "https://modelscope.cn/openapi/v1/models" url = "https://modelscope.cn/openapi/v1/models"
params = { params = {
'search': keyword, 'search': keyword,
'page_size': limit, 'page_size': min(limit, 50), # API 上限 50
'page_number': 1, 'page_number': 1,
'sort': 'downloads', 'sort': 'downloads',
} }
@@ -195,7 +195,8 @@ def check_platform_verify(model_id: str) -> dict:
resp = requests.get(url, headers=headers, params={'modelId': model_id}, timeout=10) resp = requests.get(url, headers=headers, params={'modelId': model_id}, timeout=10)
data = resp.json() data = resp.json()
if data.get('code') == 0: if data.get('code') == 0:
return data.get('data', {}).get('verifyResult', {}) result = data.get('data', {}).get('verifyResult', {})
return result if isinstance(result, dict) else {}
except Exception: except Exception:
pass pass
return {} return {}