Adding the embedding generator interface#46902
Open
aayush3011 wants to merge 4 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a public embedding-generation interface to azure-cosmos (sync + async) by introducing an EmbeddingProvider Protocol and an EmbeddingResult return type, enabling GenerateEmbeddings(...) query expressions to carry vectors plus optional usage metadata.
Changes:
- Added
EmbeddingProviderProtocols for sync and async clients. - Added
EmbeddingResultfrozen dataclass to return vectors plus optional token usage metadata. - Exported the new API surface via package
__init__files and documented it in the changelog.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/cosmos/azure-cosmos/azure/cosmos/aio/_embedding_provider.py | Adds async EmbeddingProvider Protocol contract for aio client usage |
| sdk/cosmos/azure-cosmos/azure/cosmos/aio/init.py | Exposes EmbeddingProvider / EmbeddingResult from azure.cosmos.aio |
| sdk/cosmos/azure-cosmos/azure/cosmos/_embedding_result.py | Adds EmbeddingResult dataclass used as the embedding return type |
| sdk/cosmos/azure-cosmos/azure/cosmos/_embedding_provider.py | Adds sync EmbeddingProvider Protocol contract |
| sdk/cosmos/azure-cosmos/azure/cosmos/init.py | Exposes EmbeddingProvider / EmbeddingResult from azure.cosmos |
| sdk/cosmos/azure-cosmos/CHANGELOG.md | Documents the new embedding interface feature |
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.
Description
Adds the EmbeddingProvider Protocol and EmbeddingResult dataclass to azure-cosmos (both sync and async), defining the contract the SDK will use to generate vector embeddings for GenerateEmbeddings(...) query expressions.
This PR is interface-only, no client wiring, no concrete implementation. A default Azure OpenAI implementation will ship in a future companion azure-cosmos-ai package.
EmbeddingResult is used as the return type instead of a plain List[List[float]] so the SDK can carry optional usage metadata (e.g. total_tokens) alongside the vectors for diagnostics later on without a breaking change to the Protocol.
All SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines