Skip to content

Conversation

@nmoeller
Copy link
Contributor

@nmoeller nmoeller commented Jul 2, 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 :

  • MistrealAIChatPromptExcecutionSettings --> Responsible to administrate the Prompt Execution against MistralAI
  • MistralAIChatCompletion --> Responsible to coordinate the Classes and for Content parsing
  • MistralAISettings --> Basic Settings to work with the MistralAIClient

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

From a design decision i moved the processing of Functions from Connectors to the ChatCompletionClientBaseClass

What is integrated yet :

  • Integrate Mistral AI ChatCompletion Models without Streaming
  • Integrate Mistral AI Chat Completion Models with Streaming
  • Simple Integration Test to test Streaming and non Streaming
  • Extended Testing including Unit Testing & More Integration Tests

Contribution Checklist

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

markwallace-microsoft commented Jul 2, 2024

Py3.10 Test Coverage

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

Python 3.10 Unit Test Overview

Tests Skipped Failures Errors Time
1558 1 💤 0 ❌ 0 🔥 27.281s ⏱️

@nmoeller
Copy link
Contributor Author

nmoeller commented Jul 2, 2024

As commented on #6921, i decided to split the PR's into a more Lightweight PR and then increase the connector.

@moonbox3
Copy link
Collaborator

moonbox3 commented Jul 2, 2024

Hi @nmoeller, we just merged a PR that messed with the python/tests/conftest.py, so please have a look to resolve conflicts. Thanks.

@nmoeller
Copy link
Contributor Author

nmoeller commented Jul 2, 2024

Hi @nmoeller, we just merged a PR that messed with the python/tests/conftest.py, so please have a look to resolve conflicts. Thanks.

@moonbox3 I merged with the latest changes of the main Branch

Copy link
Collaborator

@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. Thanks for working on this!

Copy link
Contributor

@juliomenendez juliomenendez left a comment

Choose a reason for hiding this comment

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

Looks good! Just a few minor comments.

Copy link
Member

@eavanvalkenburg eavanvalkenburg left a comment

Choose a reason for hiding this comment

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

Lgtm!

@moonbox3 moonbox3 enabled auto-merge July 4, 2024 11:44
@moonbox3 moonbox3 added this pull request to the merge queue Jul 4, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 4, 2024
@moonbox3 moonbox3 enabled auto-merge July 4, 2024 12:34
@moonbox3 moonbox3 added this pull request to the merge queue Jul 4, 2024
Merged via the queue into microsoft:main with commit ca7a58e Jul 4, 2024
@nmoeller nmoeller deleted the issue-6499-Mistral-Ai-Connector-chat-completion branch July 5, 2024 07:36
github-merge-queue bot pushed a commit that referenced this pull request Jul 11, 2024
### Motivation and Context
1. I saw that you are having spikes regarding enabling MyPy
2. On ##7049  i had the Liskov Principle commented
3. In #7144 is saw how you plan to solve this so i decided to adjust the
mistral connector to this

### Description

The PR contains changes to be compliant to MyPy in Mistral AI Connector.
Changes input Parameter for MistralAIChatCompletion from
MistralAIPromptExecutionSettings to PromptExecutionSettings.
Adding Test Cases for MistralAIPromptExecutionSettings and
PromptExecutionSettings.


![image](https://github.com/microsoft/semantic-kernel/assets/23048106/5822896e-17d1-4d68-9348-da6765ac3527)


### Tasks

- [x] Changes input Parameter for Liskov
- [x] Settings conversion
- [x] Adjust TestCases to 100%

### 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 <nicomoller@microsoft.com>
Co-authored-by: Evan Mattson <35585003+moonbox3@users.noreply.github.com>
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 :
- MistrealAIChatPromptExcecutionSettings --> Responsible to administrate
the Prompt Execution against MistralAI
- MistralAIChatCompletion --> Responsible to coordinate the Classes and
for Content parsing
- MistralAISettings --> Basic Settings to work with the MistralAIClient

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

From a design decision i moved the processing of Functions from
Connectors to the ChatCompletionClientBaseClass

What is integrated yet :

- [X] Integrate Mistral AI ChatCompletion Models without Streaming
- [X] Integrate Mistral AI Chat Completion Models with Streaming
- [X] Simple Integration Test to test Streaming and non Streaming
- [x] Extended Testing including Unit Testing & More Integration Tests

### 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 <nicomoller@microsoft.com>
LudoCorporateShark pushed a commit to LudoCorporateShark/semantic-kernel that referenced this pull request Aug 25, 2024
### Motivation and Context
1. I saw that you are having spikes regarding enabling MyPy
2. On #microsoft#7049  i had the Liskov Principle commented
3. In microsoft#7144 is saw how you plan to solve this so i decided to adjust the
mistral connector to this

### Description

The PR contains changes to be compliant to MyPy in Mistral AI Connector.
Changes input Parameter for MistralAIChatCompletion from
MistralAIPromptExecutionSettings to PromptExecutionSettings.
Adding Test Cases for MistralAIPromptExecutionSettings and
PromptExecutionSettings.


![image](https://github.com/microsoft/semantic-kernel/assets/23048106/5822896e-17d1-4d68-9348-da6765ac3527)


### Tasks

- [x] Changes input Parameter for Liskov
- [x] Settings conversion
- [x] Adjust TestCases to 100%

### 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 <nicomoller@microsoft.com>
Co-authored-by: Evan Mattson <35585003+moonbox3@users.noreply.github.com>
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.

6 participants