-
Notifications
You must be signed in to change notification settings - Fork 19
Google Gemini tool support #331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@valtzu thanks for the extraction! It's kinda hard to keep up with the updates here, as I can only contribute in my free time and I'm kinda busy lately. Hopefully this gets merged soon |
Added tool calls for streams too |
return [ | ||
['text' => $data->content], | ||
array_filter( | ||
[ | ||
'text' => $data->content, | ||
'functionCall' => ($data->toolCalls[0] ?? null) ? [ | ||
'id' => $data->toolCalls[0]->id, | ||
'name' => $data->toolCalls[0]->name, | ||
'args' => $data->toolCalls[0]->arguments ?: new \ArrayObject(), | ||
] : null, | ||
], | ||
static fn ($content) => null !== $content, | ||
), | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't this the same like
$normalized = [];
if (null !== $data->content) {
$normalized['text'] = $data->content;
}
if (isset($data->toolCalls[0])) {
$normalized['functionCall'] = [
'id' => $data->toolCalls[0]->id,
'name' => $data->toolCalls[0]->name,
'args' => $data->toolCalls[0]->arguments ?: new \ArrayObject(),
];
}
return [$normalized];
at least that's more readable to me
could also have a separate ToolCallNormalizer
but that might be overkill
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this - looks great already.
Can you please have a look at my comment and fix phpstan?
Oh, and would be great if you could add |
Co-authored-by: Vin Souza <[email protected]>
Should be good now |
public function normalize(mixed $data, ?string $format = null, array $context = []): array | ||
{ | ||
$parameters = $data->parameters; | ||
unset($parameters['additionalProperties']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why/if this is needed, but it was included in the original implementation by @tryvin
Nevermind the commit pipeline thingy ... 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add tool support to Google Gemini.
Extracted from #320 with updates after #326