Skip to content

Commit b3bb541

Browse files
committed
docs: improve documentation for function callback and tool context
- Add cross-references to tool context documentation section - Enhance BiFunction section title and description - Improve readability and consistency of function callback documentation
1 parent eaa61cd commit b3bb541

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

spring-ai-docs/src/main/antora/modules/ROOT/pages/api/function-callback.adoc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ The main interface defines several key methods:
1111
* `getName()`: Returns the unique function name within the AI model context
1212
* `getDescription()`: Provides a description that helps the model decide when to invoke the function
1313
* `getInputTypeSchema()`: Defines the JSON schema for the function's input parameters
14-
* `call(String functionInput)`: Handles the actual function execution
15-
* `call(String functionInput, ToolContext toolContext)`: Extended version that supports additional context
14+
* `call(String functionArguments)`: Handles the actual function execution
15+
* `call(String functionArguments, ToolContext toolContext)`: Extended version that supports additional xref:api/functions.adoc#Tool-Context[tool context]
1616

1717
== Builder Pattern
1818

@@ -39,7 +39,9 @@ FunctionCallback callback = FunctionCallback.builder()
3939
.build();
4040
----
4141

42-
==== BiFunction<I, ToolContext, O> with ToolContext
42+
==== BiFunction<I, ToolContext, O>
43+
44+
Using Function with input type <I> and additional xref:api/functions.adoc#Tool-Context[ToolContext] parameter:
4345

4446
[source,java]
4547
----
@@ -113,7 +115,7 @@ The method invoking implements the `FunctionCallback` interface and provides:
113115
- Support for both static and instance methods
114116
- Any number of parameters (including none) and return values (including void)
115117
- Any parameter/return types (primitives, objects, collections)
116-
- Special handling for `ToolContext` parameters
118+
- Special handling for xref:api/functions.adoc#Tool-Context[ToolContext] parameters
117119

118120
==== Static Method Invocation
119121

@@ -231,7 +233,7 @@ FunctionCallback.builder()
231233

232234
=== Tool Context Usage
233235

234-
* 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.
236+
* 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.
235237
* Use `BiFunction<I, ToolContext, O>` to access the ToolContext in the function invocation approach and add `ToolContext` parameter in the method invoking approach.
236238

237239

spring-ai-docs/src/main/antora/modules/ROOT/pages/api/functions.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ String response = ChatClient.create(chatModel).prompt()
378378
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]
379379
integration test provides additional examples of how to use the FunctionCallback.Builder to create method invocation FunctionCallbacks.
380380

381+
[[Tool-Context]]
381382
== Tool Context
382383

383384
Spring AI now supports passing additional contextual information to function callbacks through a tool context.

0 commit comments

Comments
 (0)