fix: prepare messages for non-vision model in provider profile code path (#23733)#23904
Closed
LiWeny16 wants to merge 1 commit into
Closed
fix: prepare messages for non-vision model in provider profile code path (#23733)#23904LiWeny16 wants to merge 1 commit into
LiWeny16 wants to merge 1 commit into
Conversation
Collaborator
…le path The provider-profile branch of _build_chat_kwargs was forwarding raw image_url parts to text-only models, causing HTTP 400 errors. The legacy branch already handled this via _prepare_messages_for_non_vision_model but the profile branch bypassed it. Now both paths strip image parts before sending to non-vision providers. Fixes: NousResearch#23733
305feb8 to
4677f5f
Compare
Author
|
Thanks for the review. I've rebuilt the branches from latest main — each PR now contains only its single targeted fix instead of stacked commits. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When routing through a provider profile (non-legacy path), the code skips the
_prepare_messages_for_non_vision_modeltransformation that the legacy path applies. This causes image-containing messages to be passed unmodified to models that do not support vision, leading to crashes or incorrect behavior.Root cause
The provider profile branch of the routing logic was missing the
_prepare_messages_for_non_vision_model(api_messages)call that the legacy branch already performed.Fix
Added
_msgs_for_profile = self._prepare_messages_for_non_vision_model(api_messages)in the profile path and usedmessages=_msgs_for_profileinstead ofmessages=api_messageswhen calling the model.Fixes #23733