Skip to content

Commit 6c2c828

Browse files
authored
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 d4fe963 commit 6c2c828

File tree

2 files changed

+102
-0
lines changed

2 files changed

+102
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,12 @@ $response = $chain->call($messages, [
172172
To integrate LLMs with your application, LLM Chain supports [tool calling](https://platform.openai.com/docs/guides/function-calling) out of the box.
173173
Tools are services that can be called by the LLM to provide additional features or process data.
174174

175+
#### Server Tools
176+
177+
Some platforms provide built-in server-side tools for enhanced capabilities without custom implementations:
178+
179+
1. **[Google Gemini](docs/google-gemini-server-tools.md)** - URL Context, Google Search, Code Execution
180+
175181
Tool calling can be enabled by registering the processors in the chain:
176182

177183
```php

docs/google-gemini-server-tools.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Google Gemini Server Tools
2+
3+
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.
4+
5+
## Overview
6+
7+
Google Gemini provides several server-side tools that can be enabled when calling the model:
8+
9+
- **URL Context** - Fetches and analyzes content from URLs
10+
- **Google Search** - Performs web searches using Google
11+
- **Code Execution** - Executes code in a sandboxed environment
12+
13+
## Available Server Tools
14+
15+
### URL Context
16+
17+
The URL Context tool allows Gemini to fetch and analyze content from web pages. This is useful for:
18+
19+
- Analyzing current web content
20+
- Extracting information from specific pages
21+
- Understanding context from external sources
22+
23+
```php
24+
$llm = new Gemini('gemini-2.5-pro-preview-03-25', [
25+
'server_tools' => [
26+
'url_context' => true
27+
]
28+
]);
29+
30+
$messages = new MessageBag(
31+
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/')
32+
);
33+
34+
$response = $chain->call($messages);
35+
```
36+
37+
### Google Search
38+
39+
The Google Search tool enables the model to search the web and incorporate search results into its responses:
40+
41+
```php
42+
$llm = new Gemini('gemini-2.5-pro-preview-03-25', [
43+
'server_tools' => [
44+
'google_search' => true
45+
]
46+
]);
47+
48+
$messages = new MessageBag(
49+
Message::ofUser('What are the latest developments in quantum computing?')
50+
);
51+
52+
$response = $chain->call($messages);
53+
```
54+
55+
### Code Execution
56+
57+
The Code Execution tool provides a sandboxed environment for running code:
58+
59+
```php
60+
$llm = new Gemini('gemini-2.5-pro-preview-03-25', [
61+
'server_tools' => [
62+
'code_execution' => true
63+
]
64+
]);
65+
66+
$messages = new MessageBag(
67+
Message::ofUser('Calculate the factorial of 20 and show me the code')
68+
);
69+
70+
$response = $chain->call($messages);
71+
```
72+
73+
## Using Multiple Server Tools
74+
75+
You can enable multiple server tools simultaneously:
76+
77+
```php
78+
$llm = 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+
87+
## Example
88+
89+
See [examples/google/server-tools.php](../examples/google/server-tools.php) for a complete working example.
90+
91+
## Limitations
92+
93+
- API key must have appropriate permissions
94+
- Server tools may have usage quotas
95+
- Response times may vary based on the complexity of server tool operations
96+
- Not all Gemini model versions support all server tools

0 commit comments

Comments
 (0)