Class GoogleMapsTool
java.lang.Object
com.google.adk.tools.BaseTool
com.google.adk.tools.GoogleMapsTool
A built-in tool that is automatically invoked by Gemini 2 models to retrieve search results from
Google Maps.
This tool operates internally within the model and does not require or perform local code execution.
Usage example in an LlmAgent:
LlmAgent agent = LlmAgent.builder()
.addTool(new GoogleMapsTool())
.build();
You can pass specific latitude and longitude coordinates, via the
generateContentConfig() method of the `LlmAgent` build:
LlmAgent agent = LlmAgent.builder()
.addTool(new GoogleMapsTool())
.generateContentConfig(GenerateContentConfig.builder()
.toolConfig(ToolConfig.builder()
.retrievalConfig(RetrievalConfig.builder()
.latLng(LatLng.builder()
.latitude(latitude)
.longitude(longitude)
.build())
.build())
.build())
.build())
.build();
-
Nested Class Summary
Nested classes/interfaces inherited from class BaseTool
BaseTool.ToolArgsConfig, BaseTool.ToolConfigModifier and TypeClassDescriptionstatic classConfiguration class for tool arguments that allows arbitrary key-value pairs.static classConfiguration class for a tool definition in YAML/JSON. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionio.reactivex.rxjava3.core.CompletableprocessLlmRequest(LlmRequest.Builder llmRequestBuilder, ToolContext toolContext) Processes the outgoingLlmRequest.Builder.Methods inherited from class BaseTool
customMetadata, declaration, description, fromConfig, longRunning, name, runAsync, runAsync, runAsync, runAsync, runAsync, runAsync, runAsync, setCustomMetadataModifier and TypeMethodDescriptionReturns a read-only view of the tool metadata.Optional<com.google.genai.types.FunctionDeclaration> Gets theFunctionDeclarationrepresentation of this tool.static BaseToolfromConfig(BaseTool.ToolConfig config, String configAbsPath) Creates a tool instance from a config.booleanname()final <I,O> io.reactivex.rxjava3.core.Single <O> runAsync(I args, ToolContext toolContext, com.fasterxml.jackson.core.type.TypeReference<? extends O> typeReference) Calls a tool with generic arguments, returning the results converted to a specified type reference.final <I,O> io.reactivex.rxjava3.core.Single <O> runAsync(I args, ToolContext toolContext, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.fasterxml.jackson.core.type.TypeReference<? extends O> typeReference) Calls a tool with generic arguments and a customObjectMapper, returning the results converted to a specified type reference.final <I,O> io.reactivex.rxjava3.core.Single <O> runAsync(I args, ToolContext toolContext, com.fasterxml.jackson.databind.ObjectMapper objectMapper, Class<? extends O> oClass) Calls a tool with generic arguments and a customObjectMapper, returning the results converted to a specified class.final <I,O> io.reactivex.rxjava3.core.Single <O> runAsync(I args, ToolContext toolContext, Class<? extends O> oClass) Calls a tool with generic arguments, returning the results converted to a specified class.runAsync(Map<String, Object> args, ToolContext toolContext) Calls a tool.runAsync(T args, ToolContext toolContext) Calls a tool with generic arguments and returns a map of results.runAsync(T args, ToolContext toolContext, com.fasterxml.jackson.databind.ObjectMapper objectMapper) Calls a tool with generic arguments using a customObjectMapperand returns a map of results.voidsetCustomMetadata(String key, Object value) Sets custom metadata to the tool associated with a key.
-
Field Details
-
INSTANCE
-
-
Constructor Details
-
GoogleMapsTool
public GoogleMapsTool()
-
-
Method Details
-
processLlmRequest
public io.reactivex.rxjava3.core.Completable processLlmRequest(LlmRequest.Builder llmRequestBuilder, ToolContext toolContext) Description copied from class:BaseToolProcesses the outgoingLlmRequest.Builder.This implementation adds the current tool's
BaseTool.declaration()to theGenerateContentConfigwithin the builder. If a tool with function declarations already exists, the current tool's declaration is merged into it. Otherwise, a new tool definition with the current tool's declaration is created. The current tool itself is also added to the builder's internal list of tools. Override this method for processing the outgoing request.- Overrides:
processLlmRequestin classBaseTool
-