Repository navigation
refactor(platform): extract model-file downloads from internal/audio - #1259
Merged
Merged
Conversation
Move the atomic download and progress reader to internal/platform/download, and the Hugging Face URL shape plus the ensure-cached sequence to internal/platform/huggingface. internal/audio keeps which files a model is and the auto_download policy with its error text. No behaviour change. Refs #1258
edenreich
marked this pull request as ready for review
September 21, 2026 22:02
edenreich
commented
Sep 21, 2026
edenreich
commented
Sep 21, 2026
Contributor
|
🎉 This PR is included in version 0.205.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
Summary
Moves model-file downloading out of
internal/audiointointernal/platform, so a capability that is not audio can fetch models from Hugging Face without importing the speech package. Pure refactor: same URLs requested, same cache paths, same progress messages, same error strings. Prerequisite for #1257.Closes #1258
Changes
internal/platform/download(moved frominternal/audio/download.gowith its tests, history preserved):ToFile(atomic temp file + rename, Content-Length check) andNewProgressReader. It is its own package becauseBinaryManageruses the progress reader for GitHub release assets, which have nothing to do with Hugging Face.internal/platform/huggingface(new):Repo{ID, Revision},Client{BaseURL, HTTP},EnsureFileandErrNotCached. It is now the only non-test file containinghuggingface.coor/resolve/. An emptyRevisionresolves tomain; a commit SHA pins the files.internal/audio/model.goandttsmodel.go: the hardcodedhuggingFaceWhisperBase/qwen3TTSBaseURLs and the duplicated stat,auto_downloadcheck, mkdir, download sequence are gone. They keep what is speech knowledge:modelFileName,ttsModelFilesand its quant-suffix rule,modelsDir, and thespeech_to_text.auto_download is disabled/text_to_speech.auto_download is disabledmessages, produced by wrappingErrNotCached. Public types, constructors and methods are unchanged.internal/audio/binary.go: usesdownload.NewProgressReader; otherwise untouched.model_test.goandsynthesizer_test.goonly change their wiring (m.hub = &huggingface.Client{BaseURL: srv.URL, HTTP: srv.Client()}), and their test servers now assert the full/<repo>/resolve/main/<file>path, so the requested URLs are pinned by tests. Newhuggingfacetests cover: cached file makes no request, missing without download returnsErrNotCachedand does not create the dir, download lands indir/file, empty revision resolves tomain, a non-200 leaves nothing behind.Dependency direction:
internal/platform/*does not importinternal/audio.task precommit:run(0 lint issues, imports check) andtask test(94 packages) pass.Not in this PR: resume or retry for large downloads, moving
BinaryManager, any avatar code.no docs ticket: internal-only refactor