Skip to content
This repository was archived by the owner on Jul 16, 2025. It is now read-only.

feat: Google Gemini server tools #356

Merged
merged 1 commit into from
Jun 28, 2025

Conversation

valtzu
Copy link
Contributor

@valtzu valtzu commented Jun 28, 2025

Add support for Google server-side tools like Google search, URL context & Code execution


I thought of using Tool classes for this but didn't find any solution I was happy with, so went the easy way for now.

Ideally no changes would've been required for this approach at all, but there were 2 issues:

  1. Gemini API insist on providing empty object, and IMO it's not feasible to expect end-user to provide new \ArrayObject()
  2. If you provide tools in call's $options, then all toolbox tools go away – hence the new server_tools (open to better naming – remote_tools?)

If someone has already given this a thought, please share your thoughts / if there is some clear better approach

@chr-hertel
Copy link
Member

Yes, another good one :) came across that with Claude as well - also called "server tools" there - so i guess the naming is good 👍
https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/overview#server-tools

);

// Available server-side tools as of 2025-06-28: url_context, google_search, code_execution
$response = $chain->call($messages, ['server_tools' => ['url_context' => true]]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you think about enabling those server tools on the model class instead? feels a bit more like a feature of that model than of the chain to me

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean just set the $options on the model instead of the call? Sure, I'll adjust the example

@valtzu valtzu force-pushed the google-server-tools branch from f0da350 to cde1175 Compare June 28, 2025 21:09
@valtzu valtzu changed the title feat: Google server-side tools feat: Google Gemini server tools Jun 28, 2025
@chr-hertel
Copy link
Member

tested that all other toolcall examples still work with the new serializer setting - but with that server-tool example i always get a 429 response - guess that's due to my google setup atm

Copy link
Member

@chr-hertel chr-hertel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @valtzu :)

@chr-hertel chr-hertel merged commit 6356789 into php-llm:main Jun 28, 2025
7 checks passed
OskarStark added a commit that referenced this pull request Jul 1, 2025
- Created detailed documentation explaining URL Context, Google Search, and Code Execution tools
- Added usage examples, configuration options, and best practices
- Updated README.md to reference the new documentation
- Covers implementation from PR #356
OskarStark added a commit to symfony/ai that referenced this pull request Jul 1, 2025
This PR was merged into the main branch.

Discussion
----------

feat: Google Gemini server tools

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| Docs?         | no
| Issues        |
| License       | MIT

Cherry picking php-llm/llm-chain#356

Commits
-------

88ca18a feat: Google Gemini server tools (#356)
chr-hertel pushed a commit that referenced this pull request Jul 4, 2025
…370)

- Created detailed documentation explaining URL Context, Google Search,
and Code Execution tools
- Added usage examples, configuration options, and best practices
- Updated README.md to reference the new documentation
- Covers implementation from PR #356

cc @valtzu
symfony-splitter pushed a commit to symfony/ai-platform that referenced this pull request Jul 11, 2025
This PR was merged into the main branch.

Discussion
----------

feat: Google Gemini server tools

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| Docs?         | no
| Issues        |
| License       | MIT

Cherry picking php-llm/llm-chain#356

Commits
-------

88ca18a feat: Google Gemini server tools (#356)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants