From a97c09086a382c8d90b7ac490ff51dc4d99ff0db Mon Sep 17 00:00:00 2001 From: Pine Date: Mon, 7 Sep 2026 15:24:26 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20list=5Fmodels=20=E5=BE=AA=E7=8E=AF?= =?UTF-8?q?=E5=8F=96=E5=85=A8=E9=83=A8=E5=88=86=E9=A1=B5=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E6=A8=A1=E5=9E=8B=E7=9B=AE=E5=BD=95=E7=BC=BA=E5=A4=B1?= =?UTF-8?q?=E6=97=A9=E6=9C=9F=20ASR=20=E6=A8=A1=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 引擎 /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 取完。 --- app/services/compute_client.py | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/app/services/compute_client.py b/app/services/compute_client.py index 8da21fc..f06887d 100644 --- a/app/services/compute_client.py +++ b/app/services/compute_client.py @@ -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: