Class FunctionToolCallback<I,O>
java.lang.Object
org.springframework.ai.tool.function.FunctionToolCallback<I,O>
- All Implemented Interfaces:
ToolCallback
A
ToolCallback
implementation to invoke functions as tools.- Since:
- 1.0.0
- Author:
- Thomas Vitale
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionFunctionToolCallback
(ToolDefinition toolDefinition, ToolMetadata toolMetadata, Type toolInputType, BiFunction<I, ToolContext, O> toolFunction, ToolCallResultConverter toolCallResultConverter) -
Method Summary
Modifier and TypeMethodDescriptionstatic <I,
O> FunctionToolCallback.Builder<I, O> builder
(String name, BiFunction<I, ToolContext, O> function) Build aFunctionToolCallback
from aBiFunction
.static <I> FunctionToolCallback.Builder<I,
Void> Build aFunctionToolCallback
from aConsumer
.static <I,
O> FunctionToolCallback.Builder<I, O> Build aFunctionToolCallback
from aFunction
.static <O> FunctionToolCallback.Builder<Void,
O> Build aFunctionToolCallback
from aSupplier
.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()
-
Constructor Details
-
FunctionToolCallback
public FunctionToolCallback(ToolDefinition toolDefinition, @Nullable ToolMetadata toolMetadata, Type toolInputType, BiFunction<I, ToolContext, O> toolFunction, @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 interfaceToolCallback
-
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 interfaceToolCallback
-
toString
-
builder
public static <I,O> FunctionToolCallback.Builder<I,O> builder(String name, BiFunction<I, ToolContext, O> function) Build aFunctionToolCallback
from aBiFunction
. -
builder
Build aFunctionToolCallback
from aFunction
. -
builder
Build aFunctionToolCallback
from aSupplier
. -
builder
Build aFunctionToolCallback
from aConsumer
.
-