Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python: #6499 Mistral AI Embedding Connector #7122

Conversation

nmoeller
Copy link
Contributor

@nmoeller nmoeller commented Jul 6, 2024

Motivation and Context

  1. Why is this changed required ?
    To enable Mistral Models with Semantic Kernel, there was the issue Python: Add Mistral AI Connector #6499 in the Backlog to add a MistralAI Connector
  2. What problem does it solve ?
    It solves the problem, that semantic kernel is not yet integrated with MistralAI
  3. What scenario does it contribute to?
    The scenario is to use different connector than HF,OpenAI or AzureOpenAI. When User's want to use Mistral they can easliy integrate it now
  4. If it fixes an open issue, please link to the issue here.
    Python: Add Mistral AI Connector #6499

Description

The changes made are designed by the open_ai connector, i tried to stay as close as possible to the structure.
For the integration i installed the mistral python package in the repository.

I added the following Classes :

  • MistralAITextEmbedding --> Responsible to generate the Embeddings

To test the changes with the tests please add MISTRALAI_API_KEY and MISTRALAI_EMBEDDING_ID as Enviorment Variable

What is integrated yet :

  • Integrate Mistral AI Embedding
  • Extended Testing including Unit Testing & More Integration Tests

Some Notes

  • Integration Tests are skipped when the environment variables are not to not break the current Integration Tests
  • an Additional Settings Class was not necessary because there are no settings in Mistral Embeddings

Contribution Checklist

@nmoeller nmoeller requested a review from a team as a code owner July 6, 2024 09:53
@markwallace-microsoft markwallace-microsoft added the python Pull requests for the Python Semantic Kernel label Jul 6, 2024
@github-actions github-actions bot changed the title #6499 Mistral AI Embedding Connector Python: #6499 Mistral AI Embedding Connector Jul 6, 2024
@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Jul 6, 2024

Py3.10 Test Coverage

Python 3.10 Test Coverage Report •
FileStmtsMissCoverMissing
TOTAL683341994% 
report-only-changed-files is enabled. No files were changed during this commit :)

Python 3.10 Unit Test Overview

Tests Skipped Failures Errors Time
1733 1 💤 0 ❌ 0 🔥 27.994s ⏱️

Copy link
Contributor

@moonbox3 moonbox3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you for doing this

@markwallace-microsoft
Copy link
Member

Python Test Coverage

Python Test Coverage Report
FileStmtsMissCoverMissing
semantic_kernel
   kernel.py157796%145, 156, 160, 310–313, 422
semantic_kernel/connectors/ai/azure_ai_inference/services
   azure_ai_inference_chat_completion.py149497%169, 312, 416, 430
semantic_kernel/connectors/ai/embeddings
   embedding_generator_base.py8188%50
semantic_kernel/connectors/ai/google
   shared_utils.py39295%100, 122
semantic_kernel/connectors/ai/google/google_ai/services
   google_ai_chat_completion.py145398%149, 251, 287
   utils.py62395%138, 156–161
semantic_kernel/connectors/ai/google/vertex_ai/services
   utils.py64395%140, 158–163
   vertex_ai_chat_completion.py145398%143, 244, 280
semantic_kernel/connectors/ai/hugging_face/services
   hf_text_completion.py54394%95, 103, 134
   hf_text_embedding.py32584%77–81
semantic_kernel/connectors/openapi_plugin
   openapi_manager.py58297%110–111
   openapi_parser.py88199%127
   openapi_runner.py105298%181–182
semantic_kernel/connectors/openapi_plugin/models
   rest_api_operation.py129199%240
semantic_kernel/functions
   kernel_function_decorator.py98199%102
   kernel_function_from_method.py96199%153
   kernel_function_from_prompt.py154795%165–166, 180, 201, 219, 239, 322
   kernel_plugin.py187299%472, 475
semantic_kernel/planners
   plan.py2344581%52, 161–163, 195, 212–225, 262, 267, 275–276, 286–289, 306, 311, 327, 330–335, 353, 358, 361, 363, 370, 384–386, 391–395
semantic_kernel/planners/function_calling_stepwise_planner
   function_calling_stepwise_planner.py116497%143, 187–188, 196
semantic_kernel/planners/sequential_planner
   sequential_planner.py64691%69, 73, 107, 123, 132–133
   sequential_planner_extensions.py50982%29–30, 52, 106–120
   sequential_planner_parser.py771284%64–72, 91, 115–118
semantic_kernel/schema
   kernel_json_schema_builder.py119596%48, 82, 204, 208–209
semantic_kernel/template_engine/blocks
   code_block.py77199%119
   named_arg_block.py43198%98
semantic_kernel/utils/telemetry
   decorators.py113496%232, 240, 243, 252
   user_agent.py16288%18–19
TOTAL860014098% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
2101 1 💤 0 ❌ 0 🔥 52.711s ⏱️

@eavanvalkenburg eavanvalkenburg added this pull request to the merge queue Aug 5, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 5, 2024
@eavanvalkenburg eavanvalkenburg added this pull request to the merge queue Aug 5, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 5, 2024
@eavanvalkenburg eavanvalkenburg added this pull request to the merge queue Aug 5, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 5, 2024
@eavanvalkenburg eavanvalkenburg added this pull request to the merge queue Aug 5, 2024
Merged via the queue into microsoft:main with commit ddb9812 Aug 5, 2024
25 checks passed
Bryan-Roe added a commit to Bryan-Roe/semantic-kernel that referenced this pull request Aug 6, 2024
@nmoeller nmoeller deleted the issue-6499-Mistral-Ai-Connector-embeddings branch August 7, 2024 07:25
LudoCorporateShark pushed a commit to LudoCorporateShark/semantic-kernel that referenced this pull request Aug 25, 2024
### Motivation and Context

<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
  1. Why is this change required?
  2. What problem does it solve?
  3. What scenario does it contribute to?
  4. If it fixes an open issue, please link to the issue here.
-->

 1. Why is this changed required ?
To enable Mistral Models with Semantic Kernel, there was the issue microsoft#6499
in the Backlog to add a MistralAI Connector
2. What problem does it solve ?
It solves the problem, that semantic kernel is not yet integrated with
MistralAI
3. What scenario does it contribute to?
The scenario is to use different connector than HF,OpenAI or
AzureOpenAI. When User's want to use Mistral they can easliy integrate
it now
4. If it fixes an open issue, please link to the issue here.
microsoft#6499 

### Description

The changes made are designed by the open_ai connector, i tried to stay
as close as possible to the structure.
For the integration i installed the mistral python package in the
repository.

I added the following Classes :
- MistralAITextEmbedding --> Responsible to generate the Embeddings

**To test the changes with the tests please add MISTRALAI_API_KEY and
MISTRALAI_EMBEDDING_ID as Enviorment Variable**

What is integrated yet :

- [X] Integrate Mistral AI Embedding
- [x] Extended Testing including Unit Testing & More Integration Tests


### Some Notes

- Integration Tests are skipped when the environment variables are not
to not break the current Integration Tests
- an Additional Settings Class was not necessary because there are no
settings in [Mistral
Embeddings](https://github.com/mistralai/client-python/blob/c2bfb767f2222f4efc798f3cb9c19c9ab20b9029/src/mistralai/async_client.py#L290)

### Contribution Checklist

<!-- Before submitting this PR, please make sure: -->

- [X] The code builds clean without any errors or warnings
- [X] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [X] All unit tests pass, and I have added new tests where possible
- [X] I didn't break anyone 😄

---------

Co-authored-by: Nico Möller <[email protected]>
Co-authored-by: Eduard van Valkenburg <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
python Pull requests for the Python Semantic Kernel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants