rust sdk: change download progress callback from &str to f64#608
Merged
baijumeswani merged 6 commits intomainfrom Apr 8, 2026
Merged
rust sdk: change download progress callback from &str to f64#608baijumeswani merged 6 commits intomainfrom
baijumeswani merged 6 commits intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the Rust SDK’s model download progress reporting to use a numeric percentage callback (f64) instead of a string, aligning Rust with the Python/JS/C# SDK APIs.
Changes:
- Change
Model::download/ModelVariant::downloadprogress callback type fromFnMut(&str)toFnMut(f64). - Parse progress chunks into
f64insidemodel_variant.rsbefore invoking the user callback. - Update Rust SDK docs and examples to use the new numeric progress callback.
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 |
|---|---|
| sdk/rust/src/detail/model.rs | Public API change: download progress callback now receives f64 percent. |
| sdk/rust/src/detail/model_variant.rs | Adds a wrapper callback that parses streaming chunks into f64 before forwarding. |
| sdk/rust/README.md | Updates documentation example to print numeric progress with formatting. |
| sdk/rust/examples/tool_calling.rs | Updates example to use f64 progress callback formatting. |
| sdk/rust/examples/interactive_chat.rs | Updates example to use f64 progress callback formatting. |
| sdk/rust/examples/chat_completion.rs | Updates example to use f64 progress callback formatting. |
| sdk/rust/docs/api.md | Updates API docs to reflect FnMut(f64) progress callback and percent semantics. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
nenad1002
previously approved these changes
Apr 8, 2026
Change the public download progress callback type from FnMut(&str) to FnMut(f64) for cross-SDK consistency. Python, JS, and C# SDKs all expose a numeric float type for download progress. The string-to-float parsing now happens inside model_variant.rs (using chunk.parse::<f64>()), matching the pattern already used by download_and_register_eps_with_progress. Unparseable chunks are silently TryParse). The internal core_interop streaming infrastructure remains unchanged since it is shared with chat/audio streaming. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The .cargo/config.toml was replacing all of crates.io with the ORT-Nightly Cargo index, causing all non-ORT crates (reqwest, async-openai, tokio, etc.) to fail resolution. The Foundry Local Core, ORT, and GenAI native packages are NuGet packages downloaded via HTTP in build.rs — they are not Cargo crates and do not need a Cargo registry override. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Update all 9 download progress callback sites across 8 sample files to use f64 instead of &str, matching the SDK API change. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Handle cases where native core sends chunks with whitespace, newlines, or multiple values in a single callback. Tokenize with split_whitespace() before parsing each token as f64, matching how other SDKs handle this (JS parseFloat ignores trailing junk, Python float() strips whitespace). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Align Rust SDK with Python/C#/JS SDKs where select_variant accepts a typed model variant object rather than a raw string ID. The string-based selection is preserved as select_variant_by_id for convenience. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
7ed6f52 to
c245f2a
Compare
nenad1002
approved these changes
Apr 8, 2026
baijumeswani
pushed a commit
that referenced
this pull request
Apr 8, 2026
Change the public download progress callback type from FnMut(&str) to FnMut(f64) for cross-SDK consistency. Python, JS, and C# SDKs all expose a numeric float type for download progress. The string-to-float parsing now happens inside model_variant.rs (using chunk.parse::<f64>()), matching the pattern already used by download_and_register_eps_with_progress. Unparseable chunks are silently TryParse). The internal core_interop streaming infrastructure remains unchanged since it is shared with chat/audio streaming. --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
rui-ren
pushed a commit
that referenced
this pull request
Apr 8, 2026
- Sample: update download progress callback from &str to f64 to match upstream API change (PR #608) - Apply cargo fmt to all SDK and sample files for CI compliance Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Change the public download progress callback type from FnMut(&str) to FnMut(f64) for cross-SDK consistency. Python, JS, and C# SDKs all expose a numeric float type for download progress.
The string-to-float parsing now happens inside model_variant.rs (using chunk.parse::()), matching the pattern already used by download_and_register_eps_with_progress. Unparseable chunks are silently TryParse). The internal core_interop streaming infrastructure remains unchanged since it is shared with chat/audio streaming.