Skip to content

Commit 7871ffb

Browse files
authored
fix(Mistral): default tool call type to function for Mistral compatibility (#744)
The Mistral API currently omits the `type` attribute in its tool call responses, which causes an `Undefined array key "type"` exception. This commit defaults the missing `type` to `'function'` (the standard supported type per OpenAI documentation) to prevent runtime errors and ensure broader compatibility with OpenAI-compatible APIs. Fixes #397
1 parent fae210e commit 7871ffb

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/Responses/Chat/CreateResponseToolCall.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ private function __construct(
1313
) {}
1414

1515
/**
16-
* @param array{id: string, type: string, function: array{name: string, arguments: string}} $attributes
16+
* @param array{id: string, type?: string, function: array{name: string, arguments: string}} $attributes
1717
*/
1818
public static function from(array $attributes): self
1919
{
2020
return new self(
2121
$attributes['id'],
22-
$attributes['type'],
22+
$attributes['type'] ?? 'function',
2323
CreateResponseToolCallFunction::from($attributes['function']),
2424
);
2525
}

0 commit comments

Comments
 (0)