fix: list_models 循环取全部分页,修复模型目录缺失早期 ASR 模型
引擎 /api/models 按 id 倒序分页(默认 100/页),原实现只取第一页, 导致 qwen3-asr-flash-2026-02-10 / qwen-audio-3.0-asr-flash / fun-asr 等 早期 ASR 模型不在 /v1/models 目录中,语音转写页只能选到 realtime 变体 (走流式通道,HTTP 转写 404)。现循环拉取直至 total 取完。
This commit is contained in:
@@ -134,12 +134,28 @@ async def ensure_user(username: str) -> dict:
|
||||
|
||||
|
||||
async def list_models(status: int = 1) -> list[dict]:
|
||||
"""列出引擎 admin 模型(models 表)。返回分页 items 列表。"""
|
||||
data = await _request(
|
||||
method="GET", path=f"/api/models?status={status}&p=1&page_size=100",
|
||||
headers=_admin_headers(),
|
||||
)
|
||||
return (data.get("data") or {}).get("items") or []
|
||||
"""列出引擎 admin 模型(models 表)。
|
||||
|
||||
引擎侧模型按 id 倒序分页(默认 100/页),必须循环取全部分页,
|
||||
否则老模型(如 qwen3-asr-flash-2026-02-10 等早期 ASR 模型)会因
|
||||
排在最新 100 条之外而缺失,导致语音转写等模型目录不完整。
|
||||
"""
|
||||
page, page_size = 1, 100
|
||||
items: list[dict] = []
|
||||
while True:
|
||||
data = await _request(
|
||||
method="GET",
|
||||
path=f"/api/models?status={status}&p={page}&page_size={page_size}",
|
||||
headers=_admin_headers(),
|
||||
)
|
||||
page_data = data.get("data") or {}
|
||||
batch = page_data.get("items") or []
|
||||
items.extend(batch)
|
||||
total = int(page_data.get("total") or len(batch) or 0)
|
||||
if not batch or len(items) >= total or page * page_size >= total:
|
||||
break
|
||||
page += 1
|
||||
return items
|
||||
|
||||
|
||||
async def list_user_tokens(username: str) -> dict:
|
||||
|
||||
Reference in New Issue
Block a user