-
Notifications
You must be signed in to change notification settings - Fork 637
Feature/mistral ai integration #1755
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for opening a PR @yasteven! There are a few things to change, in particular to ensure consistency with the other models.
Robin, In order to further ensure consistency with other models, I have added support for async, completed streaming functionality, fixed multi-modal inputs (allowing for image processing), and addressed the issues you identified for the prior PR commits above. I have also nearly doubled the number of tests to account for these updates, including adding a real image processing test; all of them are passing (though occasionally the mistral image model makes a mistake, thinking 🟥 is the same as 🐈 ) I also updated the mistral.md to reflect the changes, and ran pycodestyle to catch any formatting issues that the pre-commit checks miss. This is a first-draft, I believe there are issues in the async code as it is presented here which are not captured by the tests (generate_stream needs response format), so I will still need to address that soon. There may still be lingering comments around to eliminate, and there is always room for improvement (especially in the tests and handling mistral SDK errors); but this is now very close to being the same quality as the other models. Enjoy! R/ Steven E |
I identified and fixed a bug where the new token streaming async implementation for the mistral model was not forwarding the structured output constraints, and since this bug wasn't captured by the tests I created a test for coverage over it. I switched from Mistrals' pixtral model to its small 3.1 for better image test reliability. The rest of the effort for this pull request on my end is:
Steven E ᵉ - I may make a demo of outlines in the future where it retrieves the model list with capabilities enumerated, and generates that section of the documentation. |
@RobinPicard , I believe I’ve successfully completed the initial effort to make this feature branch ready for merging into main. Please review when you have a chance. |
It looks like you forgot some of the comments that have been set as resolved without having been treated @yasteven. Could you also reorganize the commits and force push please? |
My apologies Robin, I thought the API based models were supposed to emulate native enum support when I reviewed other implementations. I believe my most recent commit addresses those lingering issues, and I pulled in this comment thread and the diff of daf8fdb and 3e4a7dd into some LLMs who inform me that the mistral.py file issues you have raised are in fact resolved. My most recent commit also reduces the tests to a core set of integration tests. I have to move onto another task at the moment so I'll force push in the next day. |
daf8fdb
to
0de7238
Compare
@RobinPicard I squashed it down into 0de7238 I don’t have push access to your repository, so I pushed the cleaned-up branch to my fork. The PR is now updated with a single commit on top of main. I have found this project useful, I have replaced the resume I have been using, with a tool I wrote in a day which takes my personal biography and a job description and generates a tailored resume and cover letter, using outlines for some of the workflow. |
PR: Add Mistral AI integration via
mistralai
This PR introduces full support for Mistral AI models in Outlines through the official
mistralai
SDK. It provides a thin wrapper aroundmistralai.Mistral
, handling prompt formatting, structured outputs, and streaming.Key Features
Mistral
wrapper andMistralTypeAdapter
for prompt formatting and structured outputs (Pydantic, JSON Schema, Literals).Image
inputs for Pixtral and other compatible endpoints.Chat
objects (system
,user
,assistant
roles).temperature
,max_tokens
,top_p
, andn
.RuntimeError
,TypeError
, andValueError
for common failure cases.Tests
Documentation
mistral.md
with:Demos
FinancialData
,FinancialRow
) from 10-K filings successfully.✅ I believe this feature branch is now in good shape for merging into
main
. Feedback and review are welcome!— SEE