Skip to content

Commit eaa61cd

Browse files
committed
docs: Imporove Function Calling docs
1 parent c1f2ec6 commit eaa61cd

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,13 @@ String response = ChatClient.create(chatModel).prompt()
163163

164164
TIP: Optionally, using the `.name()`, you can set a custom function name different from the method name.
165165

166-
== Schema Type Support
166+
== Common Configurations
167167

168-
The framework supports different schema types for function parameter validation:
168+
There are several common configurations that you can use to customize the function callbacks.
169+
170+
=== Schema Type
171+
172+
The framework supports different schema types for generating the schemas for the input parameters:
169173

170174
* JSON Schema (default)
171175
* OpenAPI Schema (for Vertex AI compatibility)
@@ -180,6 +184,12 @@ FunctionCallback.builder()
180184

181185
=== Custom Response Handling
182186

187+
You can provide a custom response converter to format the function response before sending it back to the AI model.
188+
Most AI Models expect an text response, so it is your responsibility to convert the function response to a text format.
189+
By default, the response is converted to a String.
190+
191+
TIP: Many models cope well with JSON responses, so you can return a JSON string.
192+
183193
[source,java]
184194
----
185195
FunctionCallback.builder()
@@ -191,6 +201,9 @@ FunctionCallback.builder()
191201

192202
=== Custom Object Mapping
193203

204+
Spring AI uses ObjectMapper for JSON serialization and deserialization.
205+
You can provide a custom ObjectMapper to handle custom object mapping:
206+
194207
[source,java]
195208
----
196209
FunctionCallback.builder()

0 commit comments

Comments
 (0)