Repository navigation
Pass image parts of user messages through in tool calling - #52
Open
tim-baecker wants to merge 1 commit into
Open
tim-baecker wants to merge 1 commit into
tim-baecker wants to merge 1 commit into
Conversation
UserMessage accepts array content for multimodal input, but buildMessageBag() kept only string content, so an image in a tool-calling request reached the model as empty text. A user message with array content now becomes Message::ofUser(Text..., Image...); string content behaves as before.
This branch has not been deployed
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.
Problem
UserMessageaccepts array content "for multimodal input (e.g. text + image for vision requests)", butSymfonyAiPlatformAdapter::buildMessageBag()keeps only string content(
$content = is_string($msg->content) ? $msg->content : ''). A user message with an image in atool-calling (or conversation) request therefore reaches the model as an empty text: the image is lost
without an error.
Use case: an editor pastes a screenshot into a backend chat assistant that works with tools and asks
it to rebuild the element. Today the only way is a separate vision request whose text answer is fed
into the conversation.
Change
UserMessagedocuments the array format: a list of parts, each['type' => 'text', 'text' => '…']or['type' => 'image', 'mimeType' => 'image/png', 'data' => '<base64>'].buildMessageBag()turns a user message with array content intoMessage::ofUser(Text…, Image…)(new private
toUserContent()); string content behaves as before.buildMessageBagPassesTextAndImagePartsOfAUserMessage(fails without the change: theimage part is dropped).
Request logging and smart routing already skip non-string content without error, so nothing else
changes. Models without vision support will reject such a request at the provider, as with any
vision request.
27 lines added, 1 changed in two classes, plus the test.