[Cosmos]: Adding Semantic Reranker API#42991
Merged
aayush3011 merged 26 commits intoAzure:mainfrom Oct 2, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds semantic reranking functionality to the Azure Cosmos DB Python SDK, enabling developers to leverage document reranking capabilities directly from their Cosmos DB containers by integrating with Azure's inference service.
- Implements a new
semantic_rerank()method on theContainerProxyclass for performing semantic reranking operations - Creates a dedicated inference pipeline with custom authentication to communicate with Azure's inference service
- Adds comprehensive test coverage for the new semantic reranking functionality
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| azure/cosmos/container.py | Adds the public semantic_rerank() method to ContainerProxy class |
| azure/cosmos/_semantic_reranker.py | Core implementation of semantic reranking client with inference pipeline |
| azure/cosmos/_inference_auth_policy.py | Custom Bearer token authentication policy for inference service |
| azure/cosmos/_cosmos_client_connection.py | Integrates semantic reranker into client connection infrastructure |
| tests/test_semantic_reranker.py | Test suite for semantic reranking functionality |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
API Change CheckAPIView identified API level changes in this PR and created the following API reviews |
Pilchie
reviewed
Sep 12, 2025
raj-shah14
reviewed
Sep 12, 2025
raj-shah14
reviewed
Sep 12, 2025
Member
Author
|
/azp run python - cosmos - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
tvaron3
reviewed
Sep 22, 2025
simorenoh
requested changes
Sep 22, 2025
Member
simorenoh
left a comment
There was a problem hiding this comment.
Just some small questions and changes, thanks Aayush!
simorenoh
approved these changes
Sep 26, 2025
raj-shah14
reviewed
Oct 1, 2025
raj-shah14
reviewed
Oct 1, 2025
Member
Author
|
/azp run python - cosmos - ci |
|
Azure Pipelines successfully started running 1 pipeline(s). |
simorenoh
approved these changes
Oct 1, 2025
simorenoh
approved these changes
Oct 2, 2025
Member
|
@sdkReviewAgent-2 |
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
This PR adds semantic reranking functionality to the Azure Cosmos DB Python SDK, enabling developers to leverage document reranking capabilities directly from their Cosmos DB containers.
Core Implementation
semantic_rerank()method onContainerProxyclass for performing semantic reranking operationsInferenceServiceBearerTokenPolicythat preserves standard Bearer token format needed for Inference service.API Design
ContainerProxy.semantic_rerank()- Developer-facing APICosmosClientConnection.SemanticRerank()- Handles pipeline communication_SemanticRerankerclass manages endpoint construction and pipeline setupExample usage
Result
All SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines