fix(transcriber): 模型下载失败时透传错误到前端并提示 (#402)#414
Closed
JefferyHcool wants to merge 1 commit into
Closed
Conversation
issue #402 衍生问题:whisper 模型后台下载失败时,/transcriber_models_status 只回传 downloading/downloaded 两个布尔,failed 态被直接丢弃,于是前端表现为 「点了下载没反应、状态一直未下载、且无任何错误提示」。 后端:新增轻量模块 model_download_state 统一维护下载状态(downloading/done/ failed)与失败原因,config.py 的下载触发与状态查询共享同一份内存态;状态接口 新增 failed 字段,失败时附带 error(仓库 404、网络中断、本地路径缺 model.bin 等)。 前端:模型管理列表新增「下载失败」红色徽标 + 错误详情,按钮在失败后变为「重试」; 自定义模型项同样展示失败图标与原因;并对「本次新出现的失败」弹一次 toast 主动提示。 测试:新增 test_model_download_state 覆盖状态流转(downloading/done/failed、 失败原因透传、downloaded 覆盖 failed、重下清错、mlx key 隔离)。 已用 docker compose 启动整套栈验证:触发本地路径缺失与 HF 仓库 404 两种失败, /transcriber_models_status 均正确回传 failed:true + error。 Refs #402 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Owner
Author
|
已通过 hotfix v2.4.3 合并进 master 与 develop(cherry-pick 自 commit 4a87c5b),故关闭此 PR。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
issue #402 的根因(
large-v3-turbo仓库 404)已由 #413 修复。但还有一个衍生问题没解决:当 whisper 模型后台下载因任何原因失败时,前端完全没有反馈。/transcriber_models_status此前每个模型只回传downloading/downloaded两个布尔,后台_do_download_whisper把失败状态写进_downloading[size] = "failed"后就被状态接口直接丢弃。于是用户看到的就是 issue 里描述的:「点了下载没反应、状态一直『未下载』、且无任何错误提示」。本 PR 把失败态 + 失败原因一路透传到前端。
改动
后端
app/transcriber/model_download_state.py:统一维护下载状态(downloading/done/failed)与失败原因,把原先散落在config.py多处的字符串状态赋值收敛到一处。仅依赖logger,可被单测隔离加载(与whisper_models.py同款模式)。config.py:下载触发与状态查询共享这份内存态;/transcriber_models_status每个模型新增failed字段,失败时附带error。downloaded=True时一律不回传failed/error(避免「先失败后又下好」残留旧错误)。前端
toast(首次进页面只建立基线、不对历史失败弹窗,避免噪音)。测试
新增
backend/tests/test_model_download_state.py(8 例)覆盖:状态流转、失败原因透传、downloaded覆盖failed、重新下载清除旧错误、mlx key 与 whisper 同名档位互不影响。```
$ pytest tests/test_model_download_state.py tests/test_whisper_models.py -q
21 passed
```
Docker 实测验证
docker compose up -d起整套栈(nginx→backend),分别触发两种失败并轮询状态接口:{"model_size":"ci-fail-test","downloaded":false,"downloading":false,"failed":true,"error":"本地模型路径 /tmp/__bilinote_missing_model__ 下没有 model.bin,无法使用"}failed:true+error为401 Client Error ... Repository Not Found ...(正是 issue 日志里那段错误)。前端构建产物也已确认包含新增的「下载失败」「重试」文案。
Refs #402
🤖 Generated with Claude Code