Skip to content

feat: Support multimodal function responses - #181

Merged
aydinfatih merged 3 commits into
mainfrom
feat/function-response-parts
Oct 12, 2026
Merged

aydinfatih merged 3 commits into
mainfrom
feat/function-response-parts

Conversation

@aydinfatih

Copy link
Copy Markdown
Member

Refs #163

Adds the FunctionResponse fields from the API reference, so a function can return images or documents to the model:

new FunctionResponse(
    name: 'get_product_image',
    response: ['image' => 'product.png'],
    id: $functionCall->id,
    parts: [
        new FunctionResponsePart(inlineData: new Blob(mimeType: MimeType::IMAGE_PNG, data: base64_encode($png))),
    ],
);

Changes

  • FunctionResponse::$parts: ordered FunctionResponsePart items with inline media. The existing Blob class is reused for the inline data.
  • FunctionResponse::$willContinue and FunctionResponse::$scheduling (FunctionResponseScheduling) for NON_BLOCKING function calls.

Backward compatibility

  • New constructor parameters are nullable and appended at the end.
  • Existing function responses serialize exactly as before (name, response, id); the new keys are only added when set.
  • An unknown scheduling value resolves to null.

Tests

  • toArray() without the new fields (unchanged payload) and with them
  • from() with all fields, without optional fields and with an unknown scheduling value
  • Part round trip with a multimodal function response

Add the FunctionResponse fields from the API reference:

- parts: ordered FunctionResponsePart items with inline media, so a
  function can return images or documents to the model
- willContinue and scheduling for NON_BLOCKING function calls

Existing function responses are serialized exactly as before.

Refs #163
The $ref form needs a matching display name, which FunctionResponseBlob
doesn't have, so the API rejects that payload.
@aydinfatih
aydinfatih merged commit 0ae5b7b into main Oct 12, 2026
20 checks passed
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