feat(models): improve Hugging Face source ergonomics#146
Conversation
Support revision query syntax for hf:// sources with slash-containing refs, encode Hugging Face resolve URLs safely, and document current hf:// behavior, private-token guidance, and non-goals. Verification: dart analyze; dart analyze lib/src/core/models/model_source.dart test/unit/core/models/model_source_test.dart; dart test test/unit/core/models/model_source_test.dart; dart test test/unit/core/models; npm ci && npm run build (website).
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #146 +/- ##
==========================================
+ Coverage 78.25% 78.32% +0.07%
==========================================
Files 75 75
Lines 9715 9764 +49
==========================================
+ Hits 7602 7648 +46
- Misses 2113 2116 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR improves Hugging Face model source handling by adding query-based revision parsing, safer URL/canonical identity encoding for slash-containing refs, and updated user-facing documentation around hf:// usage and limitations.
Changes:
- Adds
?revision=parsing for Hugging Face refs and regression tests for slash refs, plus signs, invalid query syntax, and cache identity behavior. - Updates Hugging Face URL construction and canonical key generation for slash-containing revisions.
- Expands README, website docs, and changelog entries for
hf://, private/gated repos,mmproj, and sharded GGUF limitations.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
lib/src/core/models/model_source.dart |
Adds query revision parsing, validation, URL encoding, and canonical key updates. |
test/unit/core/models/model_source_test.dart |
Adds regression coverage for new Hugging Face parsing and identity cases. |
README.md |
Documents hf:// reference forms and limitations. |
CHANGELOG.md |
Adds unreleased changelog entry for Hugging Face ergonomics. |
website/docs/guides/model-lifecycle.md |
Adds detailed hf:// usage, auth guidance, and limitations. |
website/docs/getting-started/finding-models.md |
Adds concise guidance for using hf:// sources. |
website/docs/changelog/recent-releases.md |
Adds website release-note summary for the feature. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
hf://...?revision=parsing for slash-containing Hugging Face refs while keeping simple@revisionshorthand.hf://behavior, private/gated repo token guidance, and current limitations around single-file sources,mmproj, file listing, and sharded GGUFs.Closes #136
Production-readiness scope
ModelSource.parse('hf://owner/repo/path/to/model.gguf').@revision, and slash-containing refs such asrefs/pr/12with?revision=refs/pr/12.ModelLoadOptionscredentials.hf://identifies one file only, separatemmprojassets require separate sources/load steps, sharded GGUF manifests are not expanded automatically, and llamadart does not list or choose Hugging Face files.Changes
?revision=onhf://sources and reject ambiguous@revision+?revision=combinations.+in revision queries and reject invalid percent-encoding / unsafe decoded revision strings before they enter metadata or logs./resolve/{revision}/...segment.Test Plan
dart format --output=none --set-exit-if-changed lib/src/core/models/model_source.dart test/unit/core/models/model_source_test.dartdart analyze lib/src/core/models/model_source.dart test/unit/core/models/model_source_test.dartdart analyzedart test test/unit/core/models/model_source_test.dartdart test test/unit/core/modelsdart test(cd website && npm run build)git diff --check origin/main...HEADReview notes
+query decoding, and unsafe decoded revision strings.