-
Couldn't load subscription status.
- Fork 24
Google Gemini tool support #331
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.
This PR was merged into the main branch. Discussion ---------- feat: add Google Gemini tool support (#331) | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | Docs? | no | Issues | | License | MIT Cherry-Picking php-llm/llm-chain#331 > Add tool support to Google Gemini. > > Extracted from #320 with updates after #326 Commits ------- 2206f1e feat: add Google Gemini tool support (#331)
Add tool support to Google Gemini.
Extracted from #320 with updates after #326