-
Notifications
You must be signed in to change notification settings - Fork 359
Samuel100/sdkv2 rust #836
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Samuel Kemp (samuel100)
wants to merge
23
commits into
main
Choose a base branch
from
samuel100/sdkv2-rust
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Samuel100/sdkv2 rust #836
Changes from 9 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
91eb27e
initial commit of rust v2 sdk
samuel100 3dcb833
bug fixes
samuel100 b76c4bd
WebGpu error fix
samuel100 d92a1e5
Make FoundryLocalManager a shared (Arc) resettable singleton
samuel100 8ef0679
Tie native handle lifetimes to the manager; serialize native create/r…
samuel100 3891878
Merge remote-tracking branch 'origin/main' into samuel100/sdkv2-rust
samuel100 ee7082c
Realign Rust FFI item vtable with new speech result types in C ABI
samuel100 c631717
Read speech result items in live audio transcription
samuel100 f129168
Address PR #836 review comments (sdk_v2/rust)
samuel100 f754f7d
Merge remote-tracking branch 'origin/main' into samuel100/sdkv2-rust
samuel100 bb939b1
Add idiomatic Session/Item/Request/Response inference API to Rust SDK
samuel100 c1c7793
Fix OpenAI direct chat request JSON and deprecate OpenAI direct clien…
samuel100 e06ff9e
samples(rust): migrate SDK examples to the Session API
samuel100 9de7fe0
fix(rust): resolve Copilot PR review comments
samuel100 2d8203b
Fix manager singleton lifetime when derived handles outlive the outer…
samuel100 fc497a9
Align Rust SDK to unified single runtime package (drop WinML flavor)
samuel100 a9df530
Add sdk_v2 Rust SDK CI/CD pipeline (build/test/pack parity)
samuel100 1dc1670
Fix Rust toolchain setup in v2 pipeline
samuel100 008a51a
Merge main into Rust SDK branch
samuel100 51fcd6c
Update Rust SDK for current ORT packages
samuel100 0eee006
Stabilize Rust SDK integration tests
samuel100 65ed610
Release Rust test manager before process teardown
samuel100 4e03bb6
Fix stale Rust model cache metadata
samuel100 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| # Clippy configuration for Foundry Local Rust SDK | ||
| msrv = "1.70" |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| edition = "2021" | ||
| max_width = 100 | ||
| use_field_init_shorthand = true |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| [package] | ||
| name = "foundry-local-sdk" | ||
| version = "2.0.0" | ||
| edition = "2021" | ||
| license = "MIT" | ||
| readme = "README.md" | ||
| description = "Local AI model inference powered by the Foundry Local Core engine" | ||
| homepage = "https://www.foundrylocal.ai/" | ||
| repository = "https://github.com/microsoft/Foundry-Local" | ||
| documentation = "https://github.com/microsoft/Foundry-Local/blob/main/sdk_v2/rust/docs/api.md" | ||
| include = ["src/**", "build.rs", "Cargo.toml", "README.md", "LICENSE.txt", "deps_versions.json"] | ||
|
|
||
| [features] | ||
| default = [] | ||
| winml = [] | ||
| nightly = [] | ||
|
|
||
| [dependencies] | ||
| libloading = "0.8" | ||
| serde = { version = "1", features = ["derive"] } | ||
| serde_json = "1" | ||
| thiserror = "2" | ||
| tokio = { version = "1", features = ["rt-multi-thread", "macros", "sync"] } | ||
| tokio-stream = "0.1" | ||
| tokio-util = "0.7" | ||
| futures-core = "0.3" | ||
| reqwest = { version = "0.12", features = ["json"] } | ||
| urlencoding = "2" | ||
| async-openai = { version = "=0.33.1", default-features = false, features = ["chat-completion-types", "embedding-types"] } | ||
|
|
||
| [build-dependencies] | ||
| ureq = "3" | ||
| zip = "2" | ||
| serde_json = "1" | ||
| serde = { version = "1", features = ["derive"] } | ||
|
|
||
| [[example]] | ||
| name = "chat_completion" | ||
| path = "examples/chat_completion.rs" | ||
|
|
||
| [[example]] | ||
| name = "tool_calling" | ||
| path = "examples/tool_calling.rs" | ||
|
|
||
| [[example]] | ||
| name = "interactive_chat" | ||
| path = "examples/interactive_chat.rs" | ||
|
|
||
| [lints.clippy] | ||
| all = { level = "warn", priority = -1 } | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| # Generating API Reference Docs | ||
|
|
||
| The Rust SDK uses `cargo doc` to generate API documentation from `///` doc comments in the source code. | ||
|
|
||
| ## Viewing Docs Locally | ||
|
|
||
| To generate and open the API docs in your browser: | ||
|
|
||
| ```bash | ||
| cd sdk_v2/rust | ||
| cargo doc --no-deps --open | ||
| ``` | ||
|
|
||
| This generates HTML documentation at `target/doc/foundry_local_sdk/index.html`. | ||
|
|
||
| ## Public API Surface | ||
|
|
||
| The SDK re-exports all public types from the crate root. Key modules: | ||
|
|
||
| | Module / Type | Description | | ||
| |---|---| | ||
| | `FoundryLocalManager` | Entry point — SDK initialisation, web service lifecycle | | ||
| | `FoundryLocalConfig` | Configuration (app name, log level, service endpoint) | | ||
| | `Catalog` | Model discovery and lookup | | ||
| | `Model` | Grouped model (alias → best variant) | | ||
| | `DownloadBuilder` | Builder for model downloads (progress, cancellation) | | ||
| | `ChatClient` | OpenAI-compatible chat completions (sync + streaming) | | ||
| | `AudioClient` | OpenAI-compatible audio transcription (sync + streaming) | | ||
| | `CreateChatCompletionResponse` | Typed chat completion response (from `async-openai`) | | ||
| | `CreateChatCompletionStreamResponse` | Typed streaming chat chunk (from `async-openai`) | | ||
| | `AudioTranscriptionResponse` | Typed audio transcription response | | ||
| | `FoundryLocalError` | Error enum with variants for all failure modes | | ||
|
|
||
| ## Notes | ||
|
|
||
| - Unlike the C# and JS SDKs which commit generated markdown docs, Rust's convention is to generate HTML docs on demand with `cargo doc`. | ||
| - Once the crate is published to crates.io, docs will be automatically hosted at [docs.rs](https://docs.rs). | ||
| - Use `--document-private-items` to include internal/private API in the generated docs: | ||
| ```bash | ||
| cargo doc --no-deps --document-private-items --open | ||
| ``` |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| MIT License | ||
|
|
||
| Copyright (c) Microsoft Corporation | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.