Skip to content

Commit 25be961

Browse files
OskarStarkchr-hertel
authored andcommitted
docs: Add comprehensive documentation for Google Gemini server tools (#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
1 parent 05c1650 commit 25be961

File tree

2 files changed

+106
-0
lines changed

2 files changed

+106
-0
lines changed
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
Google Gemini Server Tools
2+
==========================
3+
4+
Server tools are built-in capabilities provided by Google Gemini that allow the model to perform specific actions without requiring custom tool implementations. These tools run on Google's servers and provide access to external data and execution environments.
5+
6+
Overview
7+
--------
8+
9+
Google Gemini provides several server-side tools that can be enabled when calling the model:
10+
11+
- **URL Context** - Fetches and analyzes content from URLs
12+
- **Google Search** - Performs web searches using Google
13+
- **Code Execution** - Executes code in a sandboxed environment
14+
15+
Available Server Tools
16+
----------------------
17+
18+
**URL Context**
19+
20+
The URL Context tool allows Gemini to fetch and analyze content from web pages. This is useful for:
21+
22+
- Analyzing current web content
23+
- Extracting information from specific pages
24+
- Understanding context from external sources
25+
26+
::
27+
28+
$model = new Gemini('gemini-2.5-pro-preview-03-25', [
29+
'server_tools' => [
30+
'url_context' => true
31+
]
32+
]);
33+
34+
$messages = new MessageBag(
35+
Message::ofUser('What was the 12 month Euribor rate a week ago based on https://www.euribor-rates.eu/en/current-euribor-rates/4/euribor-rate-12-months/')
36+
);
37+
38+
$response = $platform->request($model, $messages);
39+
40+
41+
**Google Search**
42+
43+
The Google Search tool enables the model to search the web and incorporate search results into its responses::
44+
45+
$model = new Gemini('gemini-2.5-pro-preview-03-25', [
46+
'server_tools' => [
47+
'google_search' => true
48+
]
49+
]);
50+
51+
$messages = new MessageBag(
52+
Message::ofUser('What are the latest developments in quantum computing?')
53+
);
54+
55+
$response = $platform->request($model, $messages);
56+
57+
**Code Execution**
58+
59+
The Code Execution tool provides a sandboxed environment for running code::
60+
61+
$model = new Gemini('gemini-2.5-pro-preview-03-25', [
62+
'server_tools' => [
63+
'code_execution' => true
64+
]
65+
]);
66+
67+
$messages = new MessageBag(
68+
Message::ofUser('Calculate the factorial of 20 and show me the code')
69+
);
70+
71+
$response = $platform->request($model, $messages);
72+
73+
74+
## Using Multiple Server Tools
75+
76+
You can enable multiple server tools simultaneously::
77+
78+
$model = new Gemini('gemini-2.5-pro-preview-03-25', [
79+
'server_tools' => [
80+
'url_context' => true,
81+
'google_search' => true,
82+
'code_execution' => true
83+
]
84+
]);
85+
86+
Example
87+
-------
88+
89+
See `examples/google/server-tools.php`_ for a complete working example.
90+
91+
Limitations
92+
-----------
93+
94+
- API key must have appropriate permissions
95+
- Server tools may have usage quotas
96+
- Response times may vary based on the complexity of server tool operations
97+
- Not all Gemini model versions support all server tools
98+
99+
.. _`examples/google/server-tools.php`: https://github.com/symfony/ai/blob/main/examples/google/server-tools.php

src/platform/doc/index.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,13 @@ The standalone usage results in an ``Vector`` instance::
256256
* `Embeddings with Voyage`_
257257
* `Embeddings with Mistral`_
258258

259+
Server Tools
260+
------------
261+
262+
Some platforms provide built-in server-side tools for enhanced capabilities without custom implementations:
263+
264+
1. **[Google Gemini](google-gemini-server-tools.md)** - URL Context, Google Search, Code Execution
265+
259266
Parallel Platform Calls
260267
-----------------------
261268

0 commit comments

Comments
 (0)