Skip to content

Commit 7836255

Browse files
committed
docs: Add documentation for Spanner similarity_search tool
1 parent 7773037 commit 7836255

File tree

2 files changed

+45
-21
lines changed

2 files changed

+45
-21
lines changed

docs/tools/built-in-tools.md

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ The following requirements must be met to successfully deploy your ADK project
7474
with the GKE Code Executor tool:
7575

7676
- GKE cluster with a **gVisor-enabled node pool**.
77-
- Agent's service account requires specific **RBAC permissions**, which allow it to:
77+
- Agent\'s service account requires specific **RBAC permissions**, which allow it to:
7878
- Create, watch, and delete **Jobs** for each execution request.
79-
- Manage **ConfigMaps** to inject code into the Job's pod.
79+
- Manage **ConfigMaps** to inject code into the Job\'s pod.
8080
- List **Pods** and read their **logs** to retrieve the execution result
8181
- Install the client library with GKE extras: `pip install google-adk[gke]`
8282

@@ -153,6 +153,18 @@ They are packaged in the toolset `BigQueryToolset`.
153153
--8<-- "examples/python/snippets/tools/built-in-tools/bigquery.py"
154154
```
155155

156+
### Spanner
157+
158+
These are a set of tools aimed to provide integration with Spanner, namely:
159+
160+
* **`similarity_search`**: Performs vector similarity searches in Spanner.
161+
162+
They are packaged in the toolset `SpannerToolset`.
163+
164+
```py
165+
--8<-- "examples/python/snippets/tools/built-in-tools/spanner.py"
166+
```
167+
156168
## Use Built-in tools with other tools
157169

158170
The following code sample demonstrates how to use multiple built-in tools or how
@@ -168,18 +180,18 @@ to use built-in tools with other tools by using multiple agents:
168180

169181

170182
search_agent = Agent(
171-
model='gemini-2.0-flash',
172-
name='SearchAgent',
183+
model=\'gemini-2.0-flash\',
184+
name=\'SearchAgent\',
173185
instruction="""
174-
You're a specialist in Google Search
186+
You\'re a specialist in Google Search
175187
""",
176188
tools=[google_search],
177189
)
178190
coding_agent = Agent(
179-
model='gemini-2.0-flash',
180-
name='CodeAgent',
191+
model=\'gemini-2.0-flash\',
192+
name=\'CodeAgent\',
181193
instruction="""
182-
You're a specialist in Code Execution
194+
You\'re a specialist in Code Execution
183195
""",
184196
code_executor=BuiltInCodeExecutor(),
185197
)
@@ -212,7 +224,7 @@ to use built-in tools with other tools by using multiple agents:
212224
LlmAgent.builder()
213225
.model(MODEL_ID)
214226
.name("SearchAgent")
215-
.instruction("You're a specialist in Google Search")
227+
.instruction("You\'re a specialist in Google Search")
216228
.tools(new GoogleSearchTool()) // Instantiate GoogleSearchTool
217229
.build();
218230

@@ -222,7 +234,7 @@ to use built-in tools with other tools by using multiple agents:
222234
LlmAgent.builder()
223235
.model(MODEL_ID)
224236
.name("CodeAgent")
225-
.instruction("You're a specialist in Code Execution")
237+
.instruction("You\'re a specialist in Code Execution")
226238
.tools(new BuiltInCodeExecutionTool()) // Instantiate BuiltInCodeExecutionTool
227239
.build();
228240

@@ -239,7 +251,7 @@ to use built-in tools with other tools by using multiple agents:
239251
.build();
240252

241253
// Note: This sample only demonstrates the agent definitions.
242-
// To run these agents, you'd need to integrate them with a Runner and SessionService,
254+
// To run these agents, you\'d need to integrate them with a Runner and SessionService,
243255
// similar to the previous examples.
244256
System.out.println("Agents defined successfully:");
245257
System.out.println(" Root Agent: " + rootAgent.name());
@@ -279,7 +291,7 @@ to use built-in tools with other tools by using multiple agents:
279291
LlmAgent.builder()
280292
.model(MODEL_ID)
281293
.name("SearchAgent")
282-
.instruction("You're a specialist in Google Search")
294+
.instruction("You\'re a specialist in Google Search")
283295
.tools(new GoogleSearchTool(), new YourCustomTool()) // <-- not supported
284296
.build();
285297
```
@@ -295,18 +307,18 @@ is **not** currently supported:
295307

296308
```py
297309
search_agent = Agent(
298-
model='gemini-2.0-flash',
299-
name='SearchAgent',
310+
model=\'gemini-2.0-flash\',
311+
name=\'SearchAgent\',
300312
instruction="""
301-
You're a specialist in Google Search
313+
You\'re a specialist in Google Search
302314
""",
303315
tools=[google_search],
304316
)
305317
coding_agent = Agent(
306-
model='gemini-2.0-flash',
307-
name='CodeAgent',
318+
model=\'gemini-2.0-flash\',
319+
name=\'CodeAgent\',
308320
instruction="""
309-
You're a specialist in Code Execution
321+
You\'re a specialist in Code Execution
310322
""",
311323
code_executor=BuiltInCodeExecutor(),
312324
)
@@ -328,15 +340,15 @@ is **not** currently supported:
328340
LlmAgent.builder()
329341
.model("gemini-2.0-flash")
330342
.name("SearchAgent")
331-
.instruction("You're a specialist in Google Search")
343+
.instruction("You\'re a specialist in Google Search")
332344
.tools(new GoogleSearchTool())
333345
.build();
334346

335347
LlmAgent codingAgent =
336348
LlmAgent.builder()
337349
.model("gemini-2.0-flash")
338350
.name("CodeAgent")
339-
.instruction("You're a specialist in Code Execution")
351+
.instruction("You\'re a specialist in Code Execution")
340352
.tools(new BuiltInCodeExecutionTool())
341353
.build();
342354

@@ -348,4 +360,4 @@ is **not** currently supported:
348360
.description("Root Agent")
349361
.subAgents(searchAgent, codingAgent) // Not supported, as the sub agents use built in tools.
350362
.build();
351-
```
363+
```
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from google.adk.tools.spanner import SpannerToolset
2+
# TODO: Add credentials
3+
# from google.auth import default
4+
# credentials, project_id = default()
5+
6+
# Initialize the toolset
7+
spanner_toolset = SpannerToolset(
8+
credentials=credentials,
9+
)
10+
11+
# The toolset can be added to an agent's tools
12+
# tools = spanner_toolset.get_tools()

0 commit comments

Comments
 (0)