Skip to content

Bedrock pixtral fix #10439

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

ajac-zero
Copy link

Title

Fix support for Pixtral Large (25.02) from Amazon Bedrock provider.

Relevant issues

Fixes #10360

Pre-Submission checklist

  • [ x] I have added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • [ x] I have added a screenshot of my new test passing locally
Screenshot 2025-04-30 at 8 27 15 a m - [ x] My PR passes all unit tests on [`make test-unit`](https://docs.litellm.ai/docs/extras/contributing_code) - [ x] My PR's scope is as isolated as possible; It only solves 1 specific problem

Type

🐛 Bug Fix

Changes

'transform_response' in 'base_invoke_transformation.py' expected Mistral models from Bedrock to produce responses with the 'outputs' key; However, Pixtral Large (25.02) responds in a different structure with the 'choices' key. The changes made aim to accommodate this variation:

  1. Added a new "get_outputText" static method to "AmazonMistralConfig". This method extracts the string response from the LLM differently based on the structure of the model response. If the response holds a "choices" key, that will take priority; Otherwise, it will search for the "outputs" key. If no adequate keys are found, a Bedrock error will be raised.
  2. Replaced the Mistral route for 'transform_response' in 'base_invoke_transformation.py' with this static method.
  3. Added a new test file under "/bedrock/chat" to test this static method.

The reasoning behind abstracting this logic behind a static method is to facilitate unit testing in an isolated manner away from the rest of the "transform_response" method. The "AmazonMistralConfig" class was chosen to follow a similar pattern established by the use of "AmazonInvokeNovaConfig" and "AmazonAnthropicClaude3Config" within the method.

Copy link

vercel bot commented Apr 30, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
litellm ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 30, 2025 2:47pm

@CLAassistant
Copy link

CLAassistant commented Apr 30, 2025

CLA assistant check
All committers have signed the CLA.

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.

[Bug]: Pixtral with bedrock == error 400
2 participants