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

Mistral Client #2892

Merged
merged 28 commits into from
Jun 21, 2024
Merged

Mistral Client #2892

merged 28 commits into from
Jun 21, 2024

Conversation

marklysze
Copy link
Collaborator

@marklysze marklysze commented Jun 8, 2024

This is a Mistral Client that provides a way to use the Mistral.AI API for an agent. It's available as 'MistralAIClient(similar toGeminiClient`).

This client provides some benefits over attempting to use the Mistral.AI API through the standard config as it can cater for some of the nuances of the Mistral.AI API such as not allowing the name key on a message or failing if a system role appears after an assistant role.

This client supports text generation and function/tool calling. Additionally, costs align with the Mistral.AI API costs.

This is my first client class, hopefully I've set everything up correctly. I based changes on the Gemini Client class.

Related issue number

Relates to PR #2748.

I haven't added any documentation at this stage, will do once it has been reviewed.

Checks

@marklysze marklysze added function/tool suggestion and execution of function/tool call alt-models Pertains to using alternate, non-GPT, models (e.g., local models, llama, etc.) labels Jun 8, 2024
@marklysze marklysze requested a review from ekzhu June 8, 2024 05:59
@marklysze marklysze self-assigned this Jun 8, 2024
Copy link

gitguardian bot commented Jun 8, 2024

⚠️ GitGuardian has uncovered 4 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
10493810 Triggered Generic Password 39b7c1e notebook/agentchat_pgvector_RetrieveChat.ipynb View secret
10493810 Triggered Generic Password 39b7c1e notebook/agentchat_pgvector_RetrieveChat.ipynb View secret
10493810 Triggered Generic Password 39b7c1e notebook/agentchat_pgvector_RetrieveChat.ipynb View secret
11616921 Triggered Generic High Entropy Secret 39b7c1e notebook/agentchat_agentops.ipynb View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@Hk669

This comment has been minimized.

@Hk669

This comment has been minimized.

Copy link
Collaborator

@Josephrp Josephrp left a comment

Choose a reason for hiding this comment

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

would be nice to make a toy notebook or app in examples and a short blog post about it , to accompany the next release : this is cool ! & thanks for the contribution !

@marklysze
Copy link
Collaborator Author

i think, instead of adding mistral into the autogen dependencies, let the user have it installed manually if working with non-openai models as mentioned in the https://microsoft.github.io/autogen/docs/topics/non-openai-models/about-using-nonopenai-models/

cc @ekzhu

Hey @Hk669, yes, you make a good point - my intention is to do that and have users choose it in the same way as the GeminiClient, whereby it will install Mistral's API library if you specify it:
pip install pyautogen[mistral]

So similar to what is shown here.

If I've not done that correctly, can you let me know.

@yiranwu0
Copy link
Collaborator

I did the following changes:

  • I changed the mock in test_create_response_with_tool_call, basically we want to mock only the line mistral_response = client.chat(**mistral_params) in create function, so all other parts in your create function will still be run.
  • Did some cleaning in mistral.py, just moving things around.
  • I also remove the try catch around mistral_response = client.chat(**mistral_params), catch the error and then throw it is not necessary.

I have two minor questions, other than that I am good!

@marklysze
Copy link
Collaborator Author

marklysze commented Jun 21, 2024

I did the following changes:

  • I changed the mock in test_create_response_with_tool_call, basically we want to mock only the line mistral_response = client.chat(**mistral_params) in create function, so all other parts in your create function will still be run.
  • Did some cleaning in mistral.py, just moving things around.
  • I also remove the try catch around mistral_response = client.chat(**mistral_params), catch the error and then throw it is not necessary.

I have two minor questions, other than that I am good!

Brilliant, thanks so much for your help on that! I've just been testing and it's working with the sample AutoGen workflows I tried before.

Let me check those two questions out now.

Sorry, @yiranwu0, would you be able to link me to the two questions you had? I can't find them.

@qingyun-wu qingyun-wu added this pull request to the merge queue Jun 21, 2024
Merged via the queue into main with commit 27e3690 Jun 21, 2024
101 of 120 checks passed
@qingyun-wu qingyun-wu deleted the mistral_client branch June 21, 2024 05:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
alt-models Pertains to using alternate, non-GPT, models (e.g., local models, llama, etc.) function/tool suggestion and execution of function/tool call
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants