Class MethodToolCallback
java.lang.Object
org.springframework.ai.tool.method.MethodToolCallback
- All Implemented Interfaces:
FunctionCallback
,ToolCallback
A
ToolCallback
implementation to invoke methods as tools.- Since:
- 1.0.0
- Author:
- Thomas Vitale
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface org.springframework.ai.model.function.FunctionCallback
FunctionCallback.CommonCallbackInvokingSpec<B extends FunctionCallback.CommonCallbackInvokingSpec<B>>, FunctionCallback.FunctionInvokingSpec<I,
O>, FunctionCallback.MethodInvokingSpec, FunctionCallback.SchemaType -
Constructor Summary
ConstructorsConstructorDescriptionMethodToolCallback
(ToolDefinition toolDefinition, ToolMetadata toolMetadata, Method toolMethod, Object toolObject, ToolCallResultConverter toolCallResultConverter) -
Method Summary
Modifier and TypeMethodDescriptionstatic MethodToolCallback.Builder
builder()
Creates a newFunctionCallback.Builder
instance used to build a defaultFunctionCallback
instance.Execute tool with the given input and return the result to send back to the AI model.call
(String toolInput, ToolContext toolContext) Execute tool with the given input and context, and return the result to send back to the AI model.Definition used by the AI model to determine when and how to call the tool.Metadata providing additional information on how to handle the tool.toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.springframework.ai.tool.ToolCallback
getDescription, getInputTypeSchema, getName
-
Constructor Details
-
MethodToolCallback
public MethodToolCallback(ToolDefinition toolDefinition, @Nullable ToolMetadata toolMetadata, Method toolMethod, @Nullable Object toolObject, @Nullable ToolCallResultConverter toolCallResultConverter)
-
-
Method Details
-
getToolDefinition
Description copied from interface:ToolCallback
Definition used by the AI model to determine when and how to call the tool.- Specified by:
getToolDefinition
in interfaceToolCallback
-
getToolMetadata
Description copied from interface:ToolCallback
Metadata providing additional information on how to handle the tool.- Specified by:
getToolMetadata
in interfaceToolCallback
-
call
Description copied from interface:ToolCallback
Execute tool with the given input and return the result to send back to the AI model.- Specified by:
call
in interfaceFunctionCallback
- Specified by:
call
in interfaceToolCallback
- Parameters:
toolInput
- JSON string with the function arguments to be passed to the function. The arguments are defined as JSON schema usually registered with the model.- Returns:
- String containing the function call response.
-
call
Description copied from interface:ToolCallback
Execute tool with the given input and context, and return the result to send back to the AI model.- Specified by:
call
in interfaceFunctionCallback
- Specified by:
call
in interfaceToolCallback
- Parameters:
toolInput
- JSON string with the function arguments to be passed to the function. The arguments are defined as JSON schema usually registered with the model. Arguments are provided by the AI model.toolContext
- Map with the function context. The context is used to pass additional user provided state in addition to the arguments provided by the AI model.- Returns:
- String containing the function call response.
-
toString
-
builder
Description copied from interface:FunctionCallback
Creates a newFunctionCallback.Builder
instance used to build a defaultFunctionCallback
instance.- Returns:
- Returns a new
FunctionCallback.Builder
instance.
-