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 Support #173

Merged
merged 104 commits into from
Dec 14, 2024
Merged

Mistral Support #173

merged 104 commits into from
Dec 14, 2024

Conversation

YanSte
Copy link
Contributor

@YanSte YanSte commented Dec 7, 2024

This pull request introduces integration with the Mistral model for Pydantic AI.

The MistralModel class leverages the Mistral Python client to interact with the Mistral API, enabling both streaming and non-streaming requests and Structured Responses.

This integration supports various modes of operation, including function calling, JSON mode, and stream mode, based on the presence of function and result tools.


Note: Mistral does not support Streaming on Function Calling or Structured Responses.
Even when using stream_async, the behavior is not truly streaming. After discussions on the Mistral Discord, I use json_mode to stream only the structured output.


Sample Notebook


Test: >> Working on it. <<

  • Tests

@YanSte YanSte changed the title Mistral implementation (In Progress) Mistral Support (In Progress) Dec 7, 2024
@YanSte YanSte changed the title Mistral Support (In Progress) WIP: Mistral Support Dec 7, 2024
@samuelcolvin samuelcolvin marked this pull request as draft December 8, 2024 15:29
Copy link
Member

@samuelcolvin samuelcolvin left a comment

Choose a reason for hiding this comment

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

otherwise looks like a good start.

pydantic_ai_examples/mistral.ipynb Outdated Show resolved Hide resolved
pydantic_ai_slim/pydantic_ai/models/mistral.py Outdated Show resolved Hide resolved
@YanSte YanSte force-pushed the mistral branch 2 times, most recently from c460987 to 3b1ad11 Compare December 12, 2024 23:11
@dmontagu
Copy link
Contributor

I've got this merged with main, just let me merge it with your latest pushes

@dmontagu
Copy link
Contributor

dmontagu commented Dec 14, 2024

You should definitely check the changes I made, in particular commenting out # created=1704067200, # 2024-01-01 in the tests.models.test_mistral.chunk function. I dropped it to get the tests passing but if you want to confirm the timestamp setting is correct you might want to tweak that.

But I figured I would probably be faster to set up the model settings stuff and deal with the refactor to the new unified ModelResponse type, and that you'd appreciate the help. If you don't, feel free to revert my push!

@YanSte YanSte requested a review from samuelcolvin December 14, 2024 02:46
Copy link
Contributor

@hyperlint-ai hyperlint-ai bot left a comment

Choose a reason for hiding this comment

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

The style guide flagged several spelling errors that seemed like false positives. We skipped posting inline suggestions for the following words:

  • Groq

@samuelcolvin samuelcolvin merged commit 592a88c into pydantic:main Dec 14, 2024
14 checks passed
@samuelcolvin
Copy link
Member

Thanks so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants