Skip to content

Pass image parts of user messages through in tool calling - #52

Open
tim-baecker wants to merge 1 commit into
b13:mainfrom
tim-baecker:feature/multimodal-user-message
Open

tim-baecker wants to merge 1 commit into
b13:mainfrom
tim-baecker:feature/multimodal-user-message

Conversation

@tim-baecker

Copy link
Copy Markdown

Problem

UserMessage accepts array content "for multimodal input (e.g. text + image for vision requests)", but
SymfonyAiPlatformAdapter::buildMessageBag() keeps only string content
($content = is_string($msg->content) ? $msg->content : ''). A user message with an image in a
tool-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

  • UserMessage documents 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 into Message::ofUser(Text…, Image…)
    (new private toUserContent()); string content behaves as before.
  • Unit test buildMessageBagPassesTextAndImagePartsOfAUserMessage (fails without the change: the
    image 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.

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

No deployments
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.

1 participant