Class GoogleGenAiToolCallingManager

java.lang.Object
org.springframework.ai.google.genai.schema.GoogleGenAiToolCallingManager
All Implemented Interfaces:
org.springframework.ai.model.tool.ToolCallingManager

public class GoogleGenAiToolCallingManager extends Object implements org.springframework.ai.model.tool.ToolCallingManager
Implementation of ToolCallingManager specifically designed for Vertex AI Gemini. This manager adapts tool definitions to be compatible with Vertex AI's OpenAPI schema format by converting JSON schemas and ensuring proper type value upper-casing.

It delegates the actual tool execution to another ToolCallingManager while handling the necessary schema conversions for Vertex AI compatibility.

Since:
1.0.0
Author:
Christian Tzolov, Dan Dobrin
  • Constructor Summary

    Constructors
    Constructor
    Description
    GoogleGenAiToolCallingManager(org.springframework.ai.model.tool.ToolCallingManager delegateToolCallingManager)
    Creates a new instance of GoogleGenAiToolCallingManager.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.springframework.ai.model.tool.ToolExecutionResult
    executeToolCalls(org.springframework.ai.chat.prompt.Prompt prompt, org.springframework.ai.chat.model.ChatResponse chatResponse)
    Executes tool calls by delegating to the underlying tool calling manager.
    List<org.springframework.ai.tool.definition.ToolDefinition>
    resolveToolDefinitions(org.springframework.ai.model.tool.ToolCallingChatOptions chatOptions)
    Resolves tool definitions and converts their input schemas to be compatible with Vertex AI's OpenAPI format.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • GoogleGenAiToolCallingManager

      public GoogleGenAiToolCallingManager(org.springframework.ai.model.tool.ToolCallingManager delegateToolCallingManager)
      Creates a new instance of GoogleGenAiToolCallingManager.
      Parameters:
      delegateToolCallingManager - the underlying tool calling manager that handles actual tool execution
  • Method Details

    • resolveToolDefinitions

      public List<org.springframework.ai.tool.definition.ToolDefinition> resolveToolDefinitions(org.springframework.ai.model.tool.ToolCallingChatOptions chatOptions)
      Resolves tool definitions and converts their input schemas to be compatible with Vertex AI's OpenAPI format. This includes converting JSON schemas to OpenAPI format and ensuring proper type value casing.
      Specified by:
      resolveToolDefinitions in interface org.springframework.ai.model.tool.ToolCallingManager
      Parameters:
      chatOptions - the options containing tool preferences and configurations
      Returns:
      a list of tool definitions with Vertex AI compatible schemas
    • executeToolCalls

      public org.springframework.ai.model.tool.ToolExecutionResult executeToolCalls(org.springframework.ai.chat.prompt.Prompt prompt, org.springframework.ai.chat.model.ChatResponse chatResponse)
      Executes tool calls by delegating to the underlying tool calling manager.
      Specified by:
      executeToolCalls in interface org.springframework.ai.model.tool.ToolCallingManager
      Parameters:
      prompt - the original prompt that triggered the tool calls
      chatResponse - the chat response containing the tool calls to execute
      Returns:
      the result of executing the tool calls