Skip to content

Commit e5b2247

Browse files
ThomasVitaletzolov
authored andcommitted
Docs: Fix typos in function calling documents
Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
1 parent 20ea731 commit e5b2247

File tree

5 files changed

+39
-37
lines changed

5 files changed

+39
-37
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Spring AI provides flexible and user-friendly ways to register and call custom f
1212
In general, the custom functions need to provide a function `name`, `description`, and the function call `signature` (as JSON schema) to let the model know what arguments the function expects.
1313
The `description` helps the model to understand when to call the function.
1414

15-
As a developer, you need to implement a functions that takes the function call arguments sent from the AI model, and respond with the result back to the model.
15+
As a developer, you need to implement a function that takes the function call arguments sent from the AI model, and respond with the result back to the model.
1616
Your function can in turn invoke other 3rd party services to provide the results.
1717

1818
Spring AI makes this as easy as defining a `@Bean` definition that returns a `java.util.Function` and supplying the bean name as an option when invoking the `ChatClient`.
@@ -29,7 +29,7 @@ We can provide the AI model with metadata about our own functions that it can us
2929
For example, if during the processing of a prompt, the AI Model determines that it needs additional information about the temperature in a given location, it will start a server side generated request/response interaction. The AI Model invokes a client side function.
3030
The AI Model provides method invocation details as JSON and it is the responsibility of the client to execute that function and return the response.
3131

32-
Spring AI greatly simplifies code you need to write to support function invocation.
32+
Spring AI greatly simplifies the code you need to write to support function invocation.
3333
It brokers the function invocation conversation for you.
3434
You can simply provide your function definition as a `@Bean` and then provide the bean name of the function in your prompt options.
3535
You can also reference multiple function bean names in your prompt.
@@ -88,10 +88,10 @@ static class Config {
8888
}
8989
----
9090

91-
The `@Description` annotation is optional and provides a function description (2) that helps the model to understand when to call the function.
91+
The `@Description` annotation is optional and provides a function description (2) that helps the model understand when to call the function.
9292
It is an important property to set to help the AI model determine what client side function to invoke.
9393

94-
Another option to provide the description of the function is to the `@JacksonDescription` annotation on the `MockWeatherService.Request` to provide the function description:
94+
Another option to provide the description of the function is to use the `@JsonClassDescription` annotation on the `MockWeatherService.Request` to provide the function description:
9595

9696
[source,java]
9797
----
@@ -110,14 +110,14 @@ static class Config {
110110
public record Request(String location, Unit unit) {}
111111
----
112112

113-
It is a best practice to annotate the request object with information such that the generates JSON schema of that function is as descriptive as possible to help the AI model pick the correct function to invoke.
113+
It is a best practice to annotate the request object with information such that the generated JSON schema of that function is as descriptive as possible to help the AI model pick the correct function to invoke.
114114

115115
The link:https://github.com/spring-projects/spring-ai/blob/main/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/anthropic/tool/FunctionCallWithFunctionBeanIT.java.java[FunctionCallWithFunctionBeanIT.java] demonstrates this approach.
116116

117117

118118
==== FunctionCallback Wrapper
119119

120-
Another way register a function is to create `FunctionCallbackWrapper` wrapper like this:
120+
Another way to register a function is to create a `FunctionCallbackWrapper` wrapper like this:
121121

122122
[source,java]
123123
----
@@ -136,7 +136,7 @@ static class Config {
136136
}
137137
----
138138

139-
It wraps the 3rd party, `MockWeatherService` function and registers it as a `CurrentWeather` function with the `AnthropicChatClient`.
139+
It wraps the 3rd party `MockWeatherService` function and registers it as a `CurrentWeather` function with the `AnthropicChatClient`.
140140
It also provides a description (2) and an optional response converter (3) to convert the response into a text as expected by the model.
141141

142142
NOTE: By default, the response converter does a JSON serialization of the Response object.

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ The Azure OpenAI API does not call the function directly; instead, the model gen
1313
Spring AI provides flexible and user-friendly ways to register and call custom functions.
1414
In general, the custom functions need to provide a function `name`, `description`, and the function call `signature` (as JSON schema) to let the model know what arguments the function expects. The `description` helps the model to understand when to call the function.
1515

16-
As a developer, you need to implement a functions that takes the function call arguments sent from the AI model, and respond with the result back to the model. Your function can in turn invoke other 3rd party services to provide the results.
16+
As a developer, you need to implement a function that takes the function call arguments sent from the AI model, and respond with the result back to the model.
17+
Your function can in turn invoke other 3rd party services to provide the results.
1718

1819
Spring AI makes this as easy as defining a `@Bean` definition that returns a `java.util.Function` and supplying the bean name as an option when invoking the `ChatClient`.
1920

@@ -29,7 +30,7 @@ We can provide the AI model with metadata about our own functions that it can us
2930
For example, if during the processing of a prompt, the AI Model determines that it needs additional information about the temperature in a given location, it will start a server side generated request/response interaction. The AI Model invokes a client side function.
3031
The AI Model provides method invocation details as JSON and it is the responsibility of the client to execute that function and return the response.
3132

32-
Spring AI greatly simplifies code you need to write to support function invocation.
33+
Spring AI greatly simplifies the code you need to write to support function invocation.
3334
It brokers the function invocation conversation for you.
3435
You can simply provide your function definition as a `@Bean` and then provide the bean name of the function in your prompt options.
3536
You can also reference multiple function bean names in your prompt.
@@ -87,9 +88,9 @@ static class Config {
8788
}
8889
----
8990

90-
The `@Description` annotation is optional and provides a function description (2) that helps the model to understand when to call the function. It is an important property to set to help the AI model determine what client side function to invoke.
91+
The `@Description` annotation is optional and provides a function description (2) that helps the model understand when to call the function. It is an important property to set to help the AI model determine what client side function to invoke.
9192

92-
Another option to provide the description of the function is to the `@JacksonDescription` annotation on the `MockWeatherService.Request` to provide the function description:
93+
Another option to provide the description of the function is to use the `@JsonClassDescription` annotation on the `MockWeatherService.Request` to provide the function description:
9394

9495
[source,java]
9596
----
@@ -108,13 +109,13 @@ static class Config {
108109
public record Request(String location, Unit unit) {}
109110
----
110111

111-
It is a best practice to annotate the request object with information such that the generates JSON schema of that function is as descriptive as possible to help the AI model pick the correct function to invoke.
112+
It is a best practice to annotate the request object with information such that the generated JSON schema of that function is as descriptive as possible to help the AI model pick the correct function to invoke.
112113

113114
The link:https://github.com/spring-projects/spring-ai/blob/main/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/azure/tool/FunctionCallWithFunctionBeanIT.java[FunctionCallWithFunctionBeanIT.java] demonstrates this approach.
114115

115116
==== FunctionCallback Wrapper
116117

117-
Another way register a function is to create `FunctionCallbackWrapper` wrapper like this:
118+
Another way to register a function is to create a `FunctionCallbackWrapper` wrapper like this:
118119

119120
[source,java]
120121
----
@@ -133,7 +134,7 @@ static class Config {
133134
}
134135
----
135136

136-
It wraps the 3rd party, `MockWeatherService` function and registers it as a `CurrentWeather` function with the `ChatClient` and provides a description (2).
137+
It wraps the 3rd party `MockWeatherService` function and registers it as a `CurrentWeather` function with the `AzureAiChatClient` and provides a description (2).
137138

138139
NOTE: The default response converter does a JSON serialization of the Response object.
139140

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22

33
You can register custom Java functions with the `MistralAiChatClient` and have the Mistral AI models intelligently choose to output a JSON object containing arguments to call one or many of the registered functions.
44
This allows you to connect the LLM capabilities with external tools and APIs.
5-
The `mistral_small_latest` and `mistral_large_latest` models are trained to detect when a function should be called and to respond with JSON that adheres to the function signature.
5+
The `open-mixtral-8x22b`, `mistral_small_latest`, and `mistral_large_latest` models are trained to detect when a function should be called and to respond with JSON that adheres to the function signature.
66

77
The MistralAI API does not call the function directly; instead, the model generates JSON that you can use to call the function in your code and return the result back to the model to complete the conversation.
88

9-
NOTE: As of March 13, 2024, Mistral AI has integrated support for parallel function calling into their `mistral_large_latest`` model, a feature that was absent at the time of the first Spring AI Mistral AI.
9+
NOTE: As of March 13, 2024, Mistral AI has integrated support for parallel function calling into their `mistral_large_latest` model, a feature that was absent at the time of the first Spring AI Mistral AI.
1010

1111
Spring AI provides flexible and user-friendly ways to register and call custom functions.
1212
In general, the custom functions need to provide a function `name`, `description`, and the function call `signature` (as JSON schema) to let the model know what arguments the function expects.
1313
The `description` helps the model to understand when to call the function.
1414

15-
As a developer, you need to implement a functions that takes the function call arguments sent from the AI model, and respond with the result back to the model.
15+
As a developer, you need to implement a function that takes the function call arguments sent from the AI model, and respond with the result back to the model.
1616
Your function can in turn invoke other 3rd party services to provide the results.
1717

1818
Spring AI makes this as easy as defining a `@Bean` definition that returns a `java.util.Function` and supplying the bean name as an option when invoking the `ChatClient`.
@@ -29,7 +29,7 @@ We can provide the AI model with metadata about our own functions that it can us
2929
For example, if during the processing of a prompt, the AI Model determines that it needs additional information about the temperature in a given location, it will start a server side generated request/response interaction. The AI Model invokes a client side function.
3030
The AI Model provides method invocation details as JSON and it is the responsibility of the client to execute that function and return the response.
3131

32-
Spring AI greatly simplifies code you need to write to support function invocation.
32+
Spring AI greatly simplifies the code you need to write to support function invocation.
3333
It brokers the function invocation conversation for you.
3434
You can simply provide your function definition as a `@Bean` and then provide the bean name of the function in your prompt options.
3535
You can also reference multiple function bean names in your prompt.
@@ -41,7 +41,7 @@ To support the response of the chatbot, we will register our own function that t
4141

4242
When the response to the prompt to the model needs to answer a question such as `"What’s the weather like in Boston?"` the AI model will invoke the client providing the location value as an argument to be passed to the function. This RPC-like data is passed as JSON.
4343

44-
Our function can some SaaS based weather service API and returns the weather response back to the model to complete the conversation.
44+
Our function calls some SaaS based weather service API and returns the weather response back to the model to complete the conversation.
4545
In this example we will use a simple implementation named `MockWeatherService` that hard codes the temperature for various locations.
4646

4747
The following `MockWeatherService.java` represents the weather service API:
@@ -88,10 +88,10 @@ static class Config {
8888
}
8989
----
9090

91-
The `@Description` annotation is optional and provides a function description (2) that helps the model to understand when to call the function.
91+
The `@Description` annotation is optional and provides a function description (2) that helps the model understand when to call the function.
9292
It is an important property to set to help the AI model determine what client side function to invoke.
9393

94-
Another option to provide the description of the function is to the `@JacksonDescription` annotation on the `MockWeatherService.Request` to provide the function description:
94+
Another option to provide the description of the function is the `@JsonClassDescription` annotation on the `MockWeatherService.Request` to provide the function description:
9595

9696
[source,java]
9797
----
@@ -110,7 +110,7 @@ static class Config {
110110
public record Request(String location, Unit unit) {}
111111
----
112112

113-
It is a best practice to annotate the request object with information such that the generates JSON schema of that function is as descriptive as possible to help the AI model pick the correct function to invoke.
113+
It is a best practice to annotate the request object with information such that the generated JSON schema of that function is as descriptive as possible to help the AI model pick the correct function to invoke.
114114

115115
The link:https://github.com/spring-projects/spring-ai/blob/main/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/mistralai/tool/PaymentStatusBeanIT.java[PaymentStatusBeanIT.java] demonstrates this approach.
116116

@@ -120,7 +120,7 @@ MistralAI is almost identical to OpenAI in this regard.
120120

121121
==== FunctionCallback Wrapper
122122

123-
Another way register a function is to create `FunctionCallbackWrapper` wrapper like this:
123+
Another way to register a function is to create `FunctionCallbackWrapper` wrapper like this:
124124

125125
[source,java]
126126
----
@@ -139,7 +139,7 @@ static class Config {
139139
}
140140
----
141141

142-
It wraps the 3rd party, `MockWeatherService` function and registers it as a `CurrentWeather` function with the `MistralAiChatClient`.
142+
It wraps the 3rd party `MockWeatherService` function and registers it as a `CurrentWeather` function with the `MistralAiChatClient`.
143143
It also provides a description (2) and an optional response converter (3) to convert the response into a text as expected by the model.
144144

145145
NOTE: By default, the response converter does a JSON serialization of the Response object.

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ The AI Model provides method invocation details as JSON and it is the responsibi
3030

3131
The model-client interaction is illustrated in the <<spring-ai-function-calling-flow>> diagram.
3232

33-
Spring AI greatly simplifies code you need to write to support function invocation.
33+
Spring AI greatly simplifies the code you need to write to support function invocation.
3434
It brokers the function invocation conversation for you.
3535
You can simply provide your function definition as a `@Bean` and then provide the bean name of the function in your prompt options.
3636
You can also reference multiple function bean names in your prompt.
@@ -89,9 +89,9 @@ static class Config {
8989
}
9090
----
9191

92-
The `@Description` annotation is optional and provides a function description (2) that helps the model to understand when to call the function. It is an important property to set to help the AI model determine what client side function to invoke.
92+
The `@Description` annotation is optional and provides a function description (2) that helps the model understand when to call the function. It is an important property to set to help the AI model determine what client side function to invoke.
9393

94-
Another option to provide the description of the function is to the `@JacksonDescription` annotation on the `MockWeatherService.Request` to provide the function description:
94+
Another option to provide the description of the function is to use the `@JsonClassDescription` annotation on the `MockWeatherService.Request` to provide the function description:
9595

9696
[source,java]
9797
----
@@ -110,14 +110,14 @@ static class Config {
110110
public record Request(String location, Unit unit) {}
111111
----
112112

113-
It is a best practice to annotate the request object with information such that the generates JSON schema of that function is as descriptive as possible to help the AI model pick the correct function to invoke.
113+
It is a best practice to annotate the request object with information such that the generated JSON schema of that function is as descriptive as possible to help the AI model pick the correct function to invoke.
114114

115115
The link:https://github.com/spring-projects/spring-ai/blob/main/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/openai/tool/FunctionCallbackWithPlainFunctionBeanIT.java[FunctionCallbackWithPlainFunctionBeanIT.java] demonstrates this approach.
116116

117117

118118
==== FunctionCallback Wrapper
119119

120-
Another way register a function is to create `FunctionCallbackWrapper` wrapper like this:
120+
Another way to register a function is to create a `FunctionCallbackWrapper` wrapper like this:
121121

122122
[source,java]
123123
----
@@ -136,7 +136,7 @@ static class Config {
136136
}
137137
----
138138

139-
It wraps the 3rd party, `MockWeatherService` function and registers it as a `CurrentWeather` function with the `OpenAiChatClient`.
139+
It wraps the 3rd party `MockWeatherService` function and registers it as a `CurrentWeather` function with the `OpenAiChatClient`.
140140
It also provides a description (2) and an optional response converter (3) to convert the response into a text as expected by the model.
141141

142142
NOTE: By default, the response converter does a JSON serialization of the Response object.

0 commit comments

Comments
 (0)