Class VertexToolCallingManager
java.lang.Object
org.springframework.ai.vertexai.gemini.schema.VertexToolCallingManager
- All Implemented Interfaces:
org.springframework.ai.model.tool.ToolCallingManager
public class VertexToolCallingManager
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
-
Constructor Summary
ConstructorsConstructorDescriptionVertexToolCallingManager(org.springframework.ai.model.tool.ToolCallingManager delegateToolCallingManager) Creates a new instance of VertexToolCallingManager. -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.ai.model.tool.ToolExecutionResultexecuteToolCalls(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.
-
Constructor Details
-
VertexToolCallingManager
public VertexToolCallingManager(org.springframework.ai.model.tool.ToolCallingManager delegateToolCallingManager) Creates a new instance of VertexToolCallingManager.- 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:
resolveToolDefinitionsin interfaceorg.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:
executeToolCallsin interfaceorg.springframework.ai.model.tool.ToolCallingManager- Parameters:
prompt- the original prompt that triggered the tool callschatResponse- the chat response containing the tool calls to execute- Returns:
- the result of executing the tool calls
-