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.

    • Constructor Detail

      • Tool

        Tool()
    • 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.

      • googleMaps

         abstract Optional<GoogleMaps> googleMaps()

        Optional. Tool that allows grounding the model's response with geospatial context related to the user's query.

      • 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.

      • 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.

      • fromJson

         static Tool fromJson(String jsonString)

        Deserializes a JSON string to a Tool object.