Python: Add Mistral AI embedding client package#5480
Open
daric93 wants to merge 3 commits intomicrosoft:mainfrom
Open
Python: Add Mistral AI embedding client package#5480daric93 wants to merge 3 commits intomicrosoft:mainfrom
daric93 wants to merge 3 commits intomicrosoft:mainfrom
Conversation
Signed-off-by: Daria Korenieva <daric2612@gmail.com>
Author
|
@eavanvalkenburg please review when you have time — this implements the Mistral AI embedding client from #4171. |
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.
Motivation and Context
Adds Mistral AI embedding support to the Python agent framework, as part of the Phase 9 additional embedding implementations tracked in #4171.
Mistral AI provides embedding models via their Python SDK. This PR adds a new agent-framework-mistral package with an embedding client that follows the same patterns established by the Ollama and OpenAI embedding clients.
Description
New package:
python/packages/mistral/MistralEmbeddingClient— embedding client with OpenTelemetry telemetry supportRawMistralEmbeddingClient— raw client without telemetry layerMistralEmbeddingOptions—TypedDictextendingEmbeddingGenerationOptionsfor Mistral-specific optionsMistralEmbeddingSettings—TypedDictfor env var resolution (MISTRAL_API_KEY,MISTRAL_EMBEDDING_MODEL,MISTRAL_SERVER_URL)Uses the
mistralaiSDK v2 (>=2.0.0,<3) withcreate_async()for async embedding generation. Maps Mistral's output_dimension parameter to the framework's dimensions option, and normalizes usage fields to input_token_count / total_token_count.Tests: 14 unit tests (100% coverage) + 1 integration test (skipped without API key).
CI: Added Mistral to the
python-tests-misc-integrationjob in bothpython-integration-tests.ymlandpython-merge-tests.yml. Integration tests will skip untilMISTRAL_API_KEY(secret) andMISTRAL_EMBEDDING_MODEL_ID(var) are provisioned in the GitHub integration environment.Dependency note:
mistralaipinsopentelemetry-semantic-conventions<0.61, but the workspace dev dependencyopentelemetry-sdk==1.40.0requires0.61b0. Resolved via override-dependencies inpyproject.toml. Safe at runtime; removable once mistralai relaxes the bound.
Contribution Checklist