Added embedding API to C#, JS, Python and Rust SDKs#639
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
d394dfa to
013d790
Compare
There was a problem hiding this comment.
Pull request overview
Adds OpenAI-compatible embeddings support across the Foundry Local SDKs (C#, JS, Python, Rust) by introducing embedding clients that call the native embeddings interop command, plus tests, samples, and documentation updates.
Changes:
- Introduces
EmbeddingClient/OpenAIEmbeddingClientand model factory methods in Rust/JS/Python/C#. - Adds integration/unit tests for embedding generation and batch behavior across SDKs.
- Adds new embeddings samples and updates SDK READMEs / API docs; updates Rust dependency features for embedding types.
Reviewed changes
Copilot reviewed 54 out of 55 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/rust/tests/integration/main.rs | Registers Rust embedding integration test module. |
| sdk/rust/tests/integration/embedding_client_test.rs | Adds Rust integration coverage for single/batch embeddings + normalization/determinism checks. |
| sdk/rust/tests/integration/common/mod.rs | Adds embedding model alias constant for integration tests. |
| sdk/rust/src/openai/mod.rs | Exposes Rust EmbeddingClient + settings from the OpenAI module. |
| sdk/rust/src/openai/embedding_client.rs | Implements Rust embedding client + settings + response patching for async_openai types. |
| sdk/rust/src/detail/model_variant.rs | Adds create_embedding_client() factory on Rust ModelVariant. |
| sdk/rust/src/detail/model.rs | Adds public create_embedding_client() factory on Rust Model. |
| sdk/rust/docs/api.md | Documents the new Rust embeddings client API. |
| sdk/rust/README.md | Adds Rust README section describing embeddings usage + settings. |
| sdk/rust/Cargo.toml | Enables async-openai embedding types via embedding-types feature. |
| sdk/python/test/openai/test_embedding_client.py | Adds Python embedding tests mirroring C# suite (single/batch/normalization/determinism/validation). |
| sdk/python/test/conftest.py | Adds Python embedding model alias constant for tests. |
| sdk/python/src/openai/embedding_client.py | Implements Python EmbeddingClient + settings + response patching for OpenAI SDK types. |
| sdk/python/src/openai/init.py | Exports Python EmbeddingClient / EmbeddingSettings. |
| sdk/python/src/imodel.py | Adds Python IModel.get_embedding_client() abstract method. |
| sdk/python/src/detail/model_variant.py | Implements Python get_embedding_client() on ModelVariant. |
| sdk/python/src/detail/model.py | Implements Python get_embedding_client() on Model. |
| sdk/python/README.md | Adds Python README section for embeddings usage + settings. |
| sdk/js/test/testUtils.ts | Adds JS embedding model alias constant for tests. |
| sdk/js/test/openai/embeddingClient.test.ts | Adds JS embedding tests for single/batch/normalization/determinism. |
| sdk/js/src/openai/embeddingClient.ts | Implements JS EmbeddingClient + settings + input validation + shared request executor. |
| sdk/js/src/index.ts | Exports JS EmbeddingClient / EmbeddingClientSettings. |
| sdk/js/src/imodel.ts | Adds JS IModel.createEmbeddingClient() factory signature. |
| sdk/js/src/detail/modelVariant.ts | Implements createEmbeddingClient() on JS ModelVariant. |
| sdk/js/src/detail/model.ts | Implements createEmbeddingClient() on JS Model. |
| sdk/js/docs/README.md | Adds embeddings classes to JS docs index. |
| sdk/js/README.md | Adds JS README section for embeddings usage + settings. |
| sdk/cs/test/FoundryLocal.Tests/EmbeddingClientTests.cs | Adds C# embeddings test suite. |
| sdk/cs/src/OpenAI/EmbeddingRequestResponseTypes.cs | Adds C# embedding request DTO helpers + response parsing extensions. |
| sdk/cs/src/OpenAI/EmbeddingClient.cs | Adds C# OpenAIEmbeddingClient using native interop. |
| sdk/cs/src/IModel.cs | Adds C# IModel.GetEmbeddingClientAsync() API. |
| sdk/cs/src/Detail/ModelVariant.cs | Implements C# GetEmbeddingClientAsync() on model variants. |
| sdk/cs/src/Detail/Model.cs | Implements C# GetEmbeddingClientAsync() on models. |
| sdk/cs/src/Detail/JsonSerializationContext.cs | Registers embedding request/response types for source-gen JSON serialization (AOT). |
| sdk/cs/docs/api/microsoft.ai.foundry.local.openaiembeddingclient.md | Adds generated API doc page for C# embedding client. |
| sdk/cs/docs/api/microsoft.ai.foundry.local.modelvariant.md | Documents new C# GetEmbeddingClientAsync() on ModelVariant. |
| sdk/cs/docs/api/microsoft.ai.foundry.local.model.md | Documents new C# GetEmbeddingClientAsync() on Model. |
| sdk/cs/docs/api/microsoft.ai.foundry.local.imodel.md | Documents new C# IModel.GetEmbeddingClientAsync() method. |
| sdk/cs/docs/api/index.md | Adds OpenAIEmbeddingClient to C# docs index. |
| sdk/cs/README.md | Adds C# README section for embeddings usage + settings. |
| samples/rust/embeddings/src/main.rs | Adds Rust embeddings sample (single + batch) with model lifecycle. |
| samples/rust/embeddings/Cargo.toml | Adds Cargo manifest for Rust embeddings sample. |
| samples/rust/README.md | Lists the new Rust embeddings sample. |
| samples/rust/Cargo.toml | Adds embeddings sample to Rust samples workspace. |
| samples/python/embeddings/src/app.py | Adds Python embeddings sample (single + batch) with model lifecycle. |
| samples/python/embeddings/requirements.txt | Adds Python sample requirements including WinML variant on Windows. |
| samples/python/README.md | Lists the new Python embeddings sample. |
| samples/js/embeddings/package.json | Adds JS embeddings sample package manifest. |
| samples/js/embeddings/app.js | Adds JS embeddings sample (single + batch) with model lifecycle. |
| samples/js/README.md | Lists the new JS embeddings sample. |
| samples/cs/embeddings/Program.cs | Adds C# embeddings sample (single + batch) with model lifecycle. |
| samples/cs/embeddings/Embeddings.csproj | Adds C# sample project file with Win/non-Win targeting. |
| samples/cs/README.md | Lists the new C# embeddings sample. |
| samples/README.md | Updates top-level samples README to include embeddings and updated sample counts. |
| .gitignore | Ignores .vscode/ directory. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
f9e0033 to
2c781dc
Compare
2c781dc to
4ad28f6
Compare
prathikr
left a comment
There was a problem hiding this comment.
main has changes to remove reliance on PATs for fetching neutron-server/test-data-shared, need to merge with main and resolve any conflicts
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 55 out of 56 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Added null checks Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* updated js sdk * updated python sdk * updated rust sdk * Updated embedding model test aliases * Updated ordering on readme --------- Co-authored-by: Raja Phanindra Chava <rchava@microsoft.com>
…s as input (#3) Co-authored-by: Raja Phanindra Chava <rchava@microsoft.com>
e73cef7 to
cf0d34d
Compare
Summary
Adds embedding support to all four Foundry Local SDKs (C#, JavaScript, Python, Rust), enabling text embedding generation through the
OpenAIEmbeddingClientvia the FoundryLocalCore native interop layer. Supports both single and batch input.Changes
C# SDK
OpenAIEmbeddingClient— Client withGenerateEmbeddingAsync(string)for single input andGenerateEmbeddingsAsync(IEnumerable<string>)for batch.EmbeddingRequestResponseTypes.cs— Request DTO extending Betalgo'sEmbeddingCreateRequestwithFromUserInput()factory for both single and batch. Response deserialization with null-check and error handling.IModel.GetEmbeddingClientAsync()— New interface method, implemented inModelandModelVariant.JsonSerializationContext— RegisteredEmbeddingCreateRequestExtendedandEmbeddingCreateResponsefor AOT.JavaScript SDK
EmbeddingClient— Client withgenerateEmbedding(string)andgenerateEmbeddings(string[]). SharedexecuteRequest()for both paths.IModel.createEmbeddingClient()— Factory method in interface,Model, andModelVariant.index.ts.Python SDK
EmbeddingClient— Client withgenerate_embedding(str)andgenerate_embeddings(List[str]). Uses OpenAI SDK types (EmbeddingCreateParamsfor request,CreateEmbeddingResponsefor response). Patches server response to add missingobjectandusagefields required by the OpenAI SDK type.IModel.get_embedding_client()— Abstract method, implemented inModelandModelVariant.openai/__init__.py.Rust SDK
EmbeddingClient— Client withgenerate_embedding(&str)andgenerate_embeddings(&[&str]). Usesasync_openai::types::embeddings::CreateEmbeddingResponseas return type. Patches server response for missingobjectandusagefields.Model.create_embedding_client()— Factory method inModelandModelVariant."embedding-types"feature toasync-openaidependency.Tests
All SDKs include tests for:
Samples
New
embeddingssample in each SDK (samples/{cs,js,python,rust}/embeddings/) demonstrating:Documentation
index.md,imodel.md,model.md,modelvariant.md,openaiembeddingclient.md).README.mdclass index).docs/api.mdwithEmbeddingClient,EmbeddingResponse,EmbeddingDatareference).Test plan
Dependencies
This PR depends on the FoundryLocalCore (neutron-server) PR that adds the
"embeddings"NativeInterop command,/v1/embeddingsendpoint, and batch support:https://microsoft.visualstudio.com/windows.ai.toolkit/_git/neutron-server/pullrequest/15212502