Added embedding API to C++ SDK#668
Open
phanindraraja wants to merge 9 commits intomainfrom
Open
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an OpenAI-compatible embeddings client to the C++ SDK and aligns surrounding SDK/sample code to support embedding usage consistently across languages.
Changes:
- Introduces
OpenAIEmbeddingClient(C++), including JSON parsing for embedding responses and CMake integration. - Adds C++ unit tests + disabled E2E coverage for embeddings; updates the C++ sample to demonstrate single and batch embeddings.
- Minor cleanups/alignments in Rust/Python/C# embedding clients/tests/docs and updates samples to use the newer embedding alias and to download/register execution providers before running.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/rust/src/openai/embedding_client.rs | Simplifies/clarifies response “patching” before deserializing into async_openai types. |
| sdk/rust/docs/api.md | Removes outdated TOC entry for an embedding response type. |
| sdk/python/src/openai/embedding_client.py | Simplifies empty-input check (if not inputs). |
| sdk/cs/test/FoundryLocal.Tests/Utils.cs | Removes the model-config max_length patch helper (no longer used). |
| sdk/cs/test/FoundryLocal.Tests/EmbeddingClientTests.cs | Removes max_length patch usage; minor variable rename/cleanup. |
| sdk/cs/src/OpenAI/EmbeddingClient.cs | Avoids multiple enumeration by materializing inputs once and validating the list. |
| sdk/cpp/test/e2e_test.cpp | Adds disabled E2E test for downloading/loading/unloading and generating embeddings (single + batch). |
| sdk/cpp/test/client_test.cpp | Adds unit tests validating request format, response parsing, and input/core-error handling for embeddings. |
| sdk/cpp/src/parser.h | Adds from_json parsers for embedding response structs. |
| sdk/cpp/src/openai_embedding_client.cpp | Implements the C++ embeddings client over the native embeddings command. |
| sdk/cpp/sample/main.cpp | Adds a runnable embeddings example (single + batch). |
| sdk/cpp/include/openai/openai_embedding_client.h | New public C++ header exposing embedding client + response types. |
| sdk/cpp/include/model.h | Grants embedding client access to IModel::CoreAccess (friend + forward decl). |
| sdk/cpp/include/foundry_local.h | Exposes embeddings client via umbrella header include. |
| sdk/cpp/CMakeLists.txt | Enables /EHsc on MSVC and adds the new embeddings source file to the static library. |
| samples/rust/embeddings/src/main.rs | Updates embedding alias and adds EP discovery + download/register with progress output. |
| samples/python/embeddings/src/app.py | Updates embedding alias and adds EP discovery + download/register with progress output. |
| samples/js/embeddings/app.js | Updates embedding alias and adds EP discovery + download/register with progress output. |
| samples/cs/embeddings/Program.cs | Updates embedding alias and adds EP discovery + download/register with progress output. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
1130a6f to
43ba738
Compare
43ba738 to
13f297c
Compare
13f297c to
23950d3
Compare
23950d3 to
0c9f4e6
Compare
6bcaee9 to
e56468b
Compare
e56468b to
7197ae5
Compare
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
Adds embedding support to the C++ SDK and aligns the embedding samples across all SDK languages to a consistent initialization sequence. Includes optimizations to the existing embedding client implementations.
Changes
C++ SDK — embedding client
Public
OpenAIEmbeddingClientexposingGenerateEmbedding(single input) andGenerateEmbeddings(batch input). Empty and whitespace-only inputs are rejected client-side. Responses parse into strongly-typedEmbeddingCreateResponse/EmbeddingObject/EmbeddingUsagestructs via nlohmann/json.sdk/cpp/sample/main.cppgains an embeddings example. Manager initialization uses aConfigurationobject that supports passing core-level settings such asAzureCatalogFilter.samples/cpp/embeddings/{main.cpp,README.md}provides a top-level entry point for the embeddings demo./EHscis enabled globally so thewilexception-based APIs used bycore.hresolve correctly.Embedding sample alignment
Every embedding sample runs the same seven-step sequence: create the manager → discover execution providers (prints a table) → download and register execution providers → get the catalog → get the model → download the model → load the model. The model alias is
qwen3-embedding-0.6bacross all samples.Optimizations to existing embedding clients
Testing
ctest --preset x64-debug.--gtest_also_run_disabled_tests.