Class Tool
-
- All Implemented Interfaces:
public abstract class Tool extends JsonSerializable
Tool details of a tool that the model may use to generate a response.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public abstract classTool.BuilderBuilder for Tool.
-
Field Summary
Fields Modifier and Type Field Description public final static StringMAX_READ_LENGTH_PROPERTY
-
Constructor Summary
Constructors Constructor Description Tool()
-
Method Summary
Modifier and Type Method Description abstract Optional<Retrieval>retrieval()Optional. abstract Optional<List<Method>>functions()The java.lang.reflect.Method instance. abstract Optional<ComputerUse>computerUse()Optional. abstract Optional<FileSearch>fileSearch()Optional. abstract Optional<GoogleSearch>googleSearch()Optional. abstract Optional<GoogleMaps>googleMaps()Optional. abstract Optional<ToolCodeExecution>codeExecution()Optional. abstract Optional<EnterpriseWebSearch>enterpriseWebSearch()Optional. abstract Optional<List<FunctionDeclaration>>functionDeclarations()Optional. abstract Optional<GoogleSearchRetrieval>googleSearchRetrieval()Optional. abstract Optional<ToolParallelAiSearch>parallelAiSearch()Optional. abstract Optional<UrlContext>urlContext()Optional. abstract Optional<List<McpServer>>mcpServers()Optional. static Tool.Builderbuilder()Instantiates a builder for Tool. abstract Tool.BuildertoBuilder()Creates a builder with the same values as this instance. static ToolfromJson(String jsonString)Deserializes a JSON string to a Tool object. -
Methods inherited from class com.google.genai.JsonSerializable
fromJsonNode, fromJsonString, objectMapper, setMaxReadLength, stringToJsonNode, toJson, toJsonNode, toJsonString -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
retrieval
abstract Optional<Retrieval> retrieval()
Optional. Retrieval tool type. System will always execute the provided retrieval tool(s) to get external knowledge to answer the prompt. Retrieval results are presented to the model for generation. This field is not supported in Gemini API.
-
functions
abstract Optional<List<Method>> functions()
The java.lang.reflect.Method instance. If provided, it will to be parsed into a list of FunctionDeclaration instances, and be assigned to the functionDeclarations field.
-
computerUse
abstract Optional<ComputerUse> computerUse()
Optional. Tool to support the model interacting directly with the computer. If enabled, it automatically populates computer-use specific Function Declarations.
-
fileSearch
abstract Optional<FileSearch> fileSearch()
Optional. FileSearch tool type. Tool to retrieve knowledge from Semantic Retrieval corpora. This field is not supported in Vertex AI.
-
googleSearch
abstract Optional<GoogleSearch> googleSearch()
Optional. GoogleSearch tool type. Tool to support Google Search in Model. Powered by Google.
-
googleMaps
abstract Optional<GoogleMaps> googleMaps()
Optional. Tool that allows grounding the model's response with geospatial context related to the user's query.
-
codeExecution
abstract Optional<ToolCodeExecution> codeExecution()
Optional. CodeExecution tool type. Enables the model to execute code as part of generation.
-
enterpriseWebSearch
abstract Optional<EnterpriseWebSearch> enterpriseWebSearch()
Optional. Tool to support searching public web data, powered by Vertex AI Search and Sec4 compliance. This field is not supported in Gemini API.
-
functionDeclarations
abstract Optional<List<FunctionDeclaration>> functionDeclarations()
Optional. Function tool type. One or more function declarations to be passed to the model along with the current user query. Model may decide to call a subset of these functions by populating FunctionCall in the response. User should provide a FunctionResponse for each function call in the next turn. Based on the function responses, Model will generate the final response back to the user. Maximum 512 function declarations can be provided.
-
googleSearchRetrieval
abstract Optional<GoogleSearchRetrieval> googleSearchRetrieval()
Optional. Specialized retrieval tool that is powered by Google Search.
-
parallelAiSearch
abstract Optional<ToolParallelAiSearch> parallelAiSearch()
Optional. If specified, Vertex AI will use Parallel.ai to search for information to answer user queries. The search results will be grounded on Parallel.ai and presented to the model for response generation. This field is not supported in Gemini API.
-
urlContext
abstract Optional<UrlContext> urlContext()
Optional. Tool to support URL context retrieval.
-
mcpServers
abstract Optional<List<McpServer>> mcpServers()
Optional. MCP Servers to connect to. This field is not supported in Vertex AI.
-
builder
static Tool.Builder builder()
Instantiates a builder for Tool.
-
toBuilder
abstract Tool.Builder toBuilder()
Creates a builder with the same values as this instance.
-
-
-
-