diff --git a/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/function-callback.adoc b/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/function-callback.adoc index af1be7002..2ad3bfdaa 100644 --- a/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/function-callback.adoc +++ b/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/function-callback.adoc @@ -11,8 +11,8 @@ The main interface defines several key methods: * `getName()`: Returns the unique function name within the AI model context * `getDescription()`: Provides a description that helps the model decide when to invoke the function * `getInputTypeSchema()`: Defines the JSON schema for the function's input parameters -* `call(String functionInput)`: Handles the actual function execution -* `call(String functionInput, ToolContext toolContext)`: Extended version that supports additional context +* `call(String functionArguments)`: Handles the actual function execution +* `call(String functionArguments, ToolContext toolContext)`: Extended version that supports additional xref:api/functions.adoc#Tool-Context[tool context] == Builder Pattern @@ -39,7 +39,9 @@ FunctionCallback callback = FunctionCallback.builder() .build(); ---- -==== BiFunction with ToolContext +==== BiFunction + +Using Function with input type and additional xref:api/functions.adoc#Tool-Context[ToolContext] parameter: [source,java] ---- @@ -113,7 +115,7 @@ The method invoking implements the `FunctionCallback` interface and provides: - Support for both static and instance methods - Any number of parameters (including none) and return values (including void) - Any parameter/return types (primitives, objects, collections) -- Special handling for `ToolContext` parameters +- Special handling for xref:api/functions.adoc#Tool-Context[ToolContext] parameters ==== Static Method Invocation @@ -231,7 +233,7 @@ FunctionCallback.builder() === Tool Context Usage -* Use ToolContext when additional state or context is required that is provided from the User and not part of the function input generated by the AI model. +* Use xref:api/functions.adoc#Tool-Context[ToolContext] when additional state or context is required that is provided from the User and not part of the function input generated by the AI model. * Use `BiFunction` to access the ToolContext in the function invocation approach and add `ToolContext` parameter in the method invoking approach. diff --git a/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/functions.adoc b/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/functions.adoc index 649cd6ab1..60ed9c569 100644 --- a/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/functions.adoc +++ b/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/functions.adoc @@ -378,6 +378,7 @@ String response = ChatClient.create(chatModel).prompt() The https://github.com/spring-projects/spring-ai/blob/main/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/client/OpenAiChatClientMethodInvokingFunctionCallbackIT.java[OpenAiChatClientMethodInvokingFunctionCallbackIT] integration test provides additional examples of how to use the FunctionCallback.Builder to create method invocation FunctionCallbacks. +[[Tool-Context]] == Tool Context Spring AI now supports passing additional contextual information to function callbacks through a tool context.