Skip to content

Commit 919223c

Browse files
committed
Remove FunctionCallback deprecations
- Remove the super type FunctionCallingOptions from ToolCallingChatOptions - Move toolContext builder methods into ToolCallingChatOptions - Remove Model chat options' function specific usages - Replace them with tooling: FunctionCallback -> ToolCallback functions -> toolNames - Remove proxyToolCalls use - Remove deprecated methods - Update ChatClient methods - Replace FunctionCallback -> ToolCallback - Remove deprecated methods - Update DefaultChatClient - functionNames -> toolNames - functionCallbacks -> toolCallbacks - Update AdviseRequest - functionNames -> toolNames - functionCallbacks -> toolCallbacks - Remove FunctionCallingOptions and replace it with ToolCallingOptions - Remove FunctionCallingHelper - Update DefaultToolCallingChatOptions, ToolCallbackResolvers, ToolCallbackProvider to use Tool calling types - Update documentation Resolves #2528 Signed-off-by: Ilayaperumal Gopinathan <[email protected]>
1 parent ef0a202 commit 919223c

File tree

92 files changed

+532
-3104
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+532
-3104
lines changed

auto-configurations/models/spring-ai-autoconfigure-model-anthropic/src/test/java/org/springframework/ai/model/anthropic/autoconfigure/tool/FunctionCallWithFunctionBeanIT.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,14 @@ void functionCallTest() {
6666
"What's the weather like in San Francisco, in Paris, France and in Tokyo, Japan? Return the temperature in Celsius.");
6767

6868
ChatResponse response = chatModel.call(new Prompt(List.of(userMessage),
69-
AnthropicChatOptions.builder().function("weatherFunction").build()));
69+
AnthropicChatOptions.builder().toolNames("weatherFunction").build()));
7070

7171
logger.info("Response: {}", response);
7272

7373
assertThat(response.getResult().getOutput().getText()).contains("30", "10", "15");
7474

7575
response = chatModel.call(new Prompt(List.of(userMessage),
76-
AnthropicChatOptions.builder().function("weatherFunction3").build()));
76+
AnthropicChatOptions.builder().toolNames("weatherFunction3").build()));
7777

7878
logger.info("Response: {}", response);
7979

auto-configurations/models/spring-ai-autoconfigure-model-anthropic/src/test/java/org/springframework/ai/model/anthropic/autoconfigure/tool/FunctionCallWithPromptFunctionIT.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void functionCallTest() {
5858
"What's the weather like in San Francisco, in Paris and in Tokyo? Return the temperature in Celsius.");
5959

6060
var promptOptions = AnthropicChatOptions.builder()
61-
.functionCallbacks(
61+
.toolCallbacks(
6262
List.of(FunctionToolCallback.builder("CurrentWeatherService", new MockWeatherService())
6363
.description("Get the weather in location. Return temperature in 36°F or 36°C format.")
6464
.inputType(MockWeatherService.Request.class)

auto-configurations/models/spring-ai-autoconfigure-model-azure-openai/src/test/java/org/springframework/ai/model/azure/openai/autoconfigure/tool/FunctionCallWithFunctionBeanIT.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,14 @@ void functionCallTest() {
6767
"What's the weather like in San Francisco, Paris and in Tokyo? Use Multi-turn function calling.");
6868

6969
ChatResponse response = chatModel.call(new Prompt(List.of(userMessage),
70-
AzureOpenAiChatOptions.builder().function("weatherFunction").build()));
70+
AzureOpenAiChatOptions.builder().toolNames("weatherFunction").build()));
7171

7272
logger.info("Response: {}", response);
7373

7474
assertThat(response.getResult().getOutput().getText()).contains("30", "10", "15");
7575

7676
response = chatModel.call(new Prompt(List.of(userMessage),
77-
AzureOpenAiChatOptions.builder().function("weatherFunction3").build()));
77+
AzureOpenAiChatOptions.builder().toolNames("weatherFunction3").build()));
7878

7979
logger.info("Response: {}", response);
8080

auto-configurations/models/spring-ai-autoconfigure-model-azure-openai/src/test/java/org/springframework/ai/model/azure/openai/autoconfigure/tool/FunctionCallWithFunctionWrapperIT.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void functionCallTest() {
6565
"What's the weather like in San Francisco, Paris and in Tokyo?");
6666

6767
ChatResponse response = chatModel.call(new Prompt(List.of(userMessage),
68-
AzureOpenAiChatOptions.builder().function("WeatherInfo").build()));
68+
AzureOpenAiChatOptions.builder().toolNames("WeatherInfo").build()));
6969

7070
logger.info("Response: {}", response);
7171

auto-configurations/models/spring-ai-autoconfigure-model-azure-openai/src/test/java/org/springframework/ai/model/azure/openai/autoconfigure/tool/FunctionCallWithPromptFunctionIT.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ void functionCallTest() {
6161
"What's the weather like in San Francisco, in Paris and in Tokyo? Use Multi-turn function calling.");
6262

6363
var promptOptions = AzureOpenAiChatOptions.builder()
64-
.functionCallbacks(
64+
.toolCallbacks(
6565
List.of(FunctionToolCallback.builder("CurrentWeatherService", new MockWeatherService())
6666
.description("Get the weather in location")
6767
.inputType(MockWeatherService.Request.class)

auto-configurations/models/spring-ai-autoconfigure-model-mistral-ai/src/test/java/org/springframework/ai/model/mistralai/autoconfigure/tool/PaymentStatusBeanIT.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ void functionCallTest() {
6868
ChatResponse response = chatModel
6969
.call(new Prompt(List.of(new UserMessage("What's the status of my transaction with id T1001?")),
7070
MistralAiChatOptions.builder()
71-
.function("retrievePaymentStatus")
72-
.function("retrievePaymentDate")
71+
.toolNames("retrievePaymentStatus")
72+
.toolNames("retrievePaymentDate")
7373
.build()));
7474

7575
logger.info("Response: {}", response);

auto-configurations/models/spring-ai-autoconfigure-model-mistral-ai/src/test/java/org/springframework/ai/model/mistralai/autoconfigure/tool/PaymentStatusBeanOpenAiIT.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ void functionCallTest() {
7575
ChatResponse response = chatModel
7676
.call(new Prompt(List.of(new UserMessage("What's the status of my transaction with id T1001?")),
7777
OpenAiChatOptions.builder()
78-
.function("retrievePaymentStatus")
79-
.function("retrievePaymentDate")
78+
.toolNames("retrievePaymentStatus")
79+
.toolNames("retrievePaymentDate")
8080
.build()));
8181

8282
logger.info("Response: {}", response);

auto-configurations/models/spring-ai-autoconfigure-model-mistral-ai/src/test/java/org/springframework/ai/model/mistralai/autoconfigure/tool/PaymentStatusPromptIT.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ void functionCallTest() {
6464
UserMessage userMessage = new UserMessage("What's the status of my transaction with id T1001?");
6565

6666
var promptOptions = MistralAiChatOptions.builder()
67-
.functionCallbacks(List.of(FunctionToolCallback
67+
.toolCallbacks(List.of(FunctionToolCallback
6868
.builder("retrievePaymentStatus",
6969
(Transaction transaction) -> new Status(DATA.get(transaction).status()))
7070
.description("Get payment status of a transaction")

auto-configurations/models/spring-ai-autoconfigure-model-mistral-ai/src/test/java/org/springframework/ai/model/mistralai/autoconfigure/tool/WeatherServicePromptIT.java

+4-5
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,10 @@ void promptFunctionCall() {
7373

7474
var promptOptions = MistralAiChatOptions.builder()
7575
.toolChoice(ToolChoice.AUTO)
76-
.functionCallbacks(
77-
List.of(FunctionToolCallback.builder("CurrentWeatherService", new MyWeatherService())
78-
.description("Get the current weather in requested location")
79-
.inputType(MyWeatherService.Request.class)
80-
.build()))
76+
.toolCallbacks(List.of(FunctionToolCallback.builder("CurrentWeatherService", new MyWeatherService())
77+
.description("Get the current weather in requested location")
78+
.inputType(MyWeatherService.Request.class)
79+
.build()))
8180
.build();
8281

8382
ChatResponse response = chatModel.call(new Prompt(List.of(userMessage), promptOptions));

auto-configurations/models/spring-ai-autoconfigure-model-ollama/src/test/java/org/springframework/ai/model/ollama/autoconfigure/tool/FunctionCallbackInPromptIT.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ void functionCallTest() {
7070
"What are the weather conditions in San Francisco, Tokyo, and Paris? Find the temperature in Celsius for each of the three locations.");
7171

7272
var promptOptions = OllamaOptions.builder()
73-
.functionCallbacks(List.of(FunctionToolCallback
74-
.builder("CurrentWeatherService", new MockWeatherService())
73+
.toolCallbacks(List.of(FunctionToolCallback.builder("CurrentWeatherService", new MockWeatherService())
7574
.description(
7675
"Find the weather conditions, forecasts, and temperatures for a location, like a city or state.")
7776
.inputType(MockWeatherService.Request.class)
@@ -96,8 +95,7 @@ void streamingFunctionCallTest() {
9695
"What are the weather conditions in San Francisco, Tokyo, and Paris? Find the temperature in Celsius for each of the three locations.");
9796

9897
var promptOptions = OllamaOptions.builder()
99-
.functionCallbacks(List.of(FunctionToolCallback
100-
.builder("CurrentWeatherService", new MockWeatherService())
98+
.toolCallbacks(List.of(FunctionToolCallback.builder("CurrentWeatherService", new MockWeatherService())
10199
.description(
102100
"Find the weather conditions, forecasts, and temperatures for a location, like a city or state.")
103101
.inputType(MockWeatherService.Request.class)

auto-configurations/models/spring-ai-autoconfigure-model-ollama/src/test/java/org/springframework/ai/model/ollama/autoconfigure/tool/OllamaFunctionCallbackIT.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ void functionCallTest() {
7575
"What are the weather conditions in San Francisco, Tokyo, and Paris? Find the temperature in Celsius for each of the three locations.");
7676

7777
ChatResponse response = chatModel
78-
.call(new Prompt(List.of(userMessage), OllamaOptions.builder().function("WeatherInfo").build()));
78+
.call(new Prompt(List.of(userMessage), OllamaOptions.builder().toolNames("WeatherInfo").build()));
7979

8080
logger.info("Response: " + response);
8181

@@ -93,7 +93,7 @@ void streamFunctionCallTest() {
9393
"What are the weather conditions in San Francisco, Tokyo, and Paris? Find the temperature in Celsius for each of the three locations.");
9494

9595
Flux<ChatResponse> response = chatModel
96-
.stream(new Prompt(List.of(userMessage), OllamaOptions.builder().function("WeatherInfo").build()));
96+
.stream(new Prompt(List.of(userMessage), OllamaOptions.builder().toolNames("WeatherInfo").build()));
9797

9898
String content = response.collectList()
9999
.block()

auto-configurations/models/spring-ai-autoconfigure-model-ollama/src/test/java/org/springframework/ai/model/ollama/autoconfigure/tool/OllamaFunctionToolBeanIT.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ void streamFunctionCallTest() {
121121
"What are the weather conditions in San Francisco, Tokyo, and Paris? Find the temperature in Celsius for each of the three locations.");
122122

123123
Flux<ChatResponse> response = chatModel
124-
.stream(new Prompt(List.of(userMessage), OllamaOptions.builder().function("weatherInfo").build()));
124+
.stream(new Prompt(List.of(userMessage), OllamaOptions.builder().toolNames("weatherInfo").build()));
125125

126126
String content = response.collectList()
127127
.block()

auto-configurations/models/spring-ai-autoconfigure-model-ollama/src/test/kotlin/org/springframework/ai/model/ollama/autoconfigure/tool/FunctionCallbackContextKotlinIT.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class FunctionCallbackResolverKotlinIT : BaseOllamaIT() {
6868
"What are the weather conditions in San Francisco, Tokyo, and Paris? Find the temperature in Celsius for each of the three locations.")
6969

7070
val response = chatModel
71-
.call(Prompt(listOf(userMessage), OllamaOptions.builder().function("weatherInfo").build()))
71+
.call(Prompt(listOf(userMessage), OllamaOptions.builder().toolNames("weatherInfo").build()))
7272

7373
logger.info("Response: $response")
7474

auto-configurations/models/spring-ai-autoconfigure-model-openai/src/test/java/org/springframework/ai/model/openai/autoconfigure/tool/FunctionCallbackInPrompt2IT.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void functionCallTest() {
6060

6161
String content = ChatClient.builder(chatModel).build().prompt()
6262
.user("What's the weather like in San Francisco, Tokyo, and Paris?")
63-
.functions(FunctionToolCallback
63+
.tools(FunctionToolCallback
6464
.builder("CurrentWeatherService", new MockWeatherService())
6565
.description("Get the weather in location")
6666
.inputType(MockWeatherService.Request.class)
@@ -88,7 +88,7 @@ record LightInfo(String roomName, boolean isOn) {
8888
// @formatter:off
8989
String content = ChatClient.builder(chatModel).build().prompt()
9090
.user("Turn the light on in the kitchen and in the living room!")
91-
.functions(FunctionToolCallback
91+
.tools(FunctionToolCallback
9292
.builder("turnLight", (LightInfo lightInfo) -> {
9393
logger.info("Turning light to [" + lightInfo.isOn + "] in " + lightInfo.roomName());
9494
state.put(lightInfo.roomName(), lightInfo.isOn());
@@ -114,7 +114,7 @@ void functionCallTest2() {
114114
// @formatter:off
115115
String content = ChatClient.builder(chatModel).build().prompt()
116116
.user("What's the weather like in Amsterdam?")
117-
.functions(FunctionToolCallback
117+
.tools(FunctionToolCallback
118118
.builder("CurrentWeatherService", input -> "18 degrees Celsius")
119119
.description("Get the weather in location")
120120
.inputType(MockWeatherService.Request.class)
@@ -138,7 +138,7 @@ void streamingFunctionCallTest() {
138138
// @formatter:off
139139
String content = ChatClient.builder(chatModel).build().prompt()
140140
.user("What's the weather like in San Francisco, Tokyo, and Paris?")
141-
.functions(FunctionToolCallback
141+
.tools(FunctionToolCallback
142142
.builder("CurrentWeatherService", new MockWeatherService())
143143
.description("Get the weather in location")
144144
.inputType(MockWeatherService.Request.class)

auto-configurations/models/spring-ai-autoconfigure-model-openai/src/test/java/org/springframework/ai/model/openai/autoconfigure/tool/FunctionCallbackInPromptIT.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ void functionCallTest() {
6262
"What's the weather like in San Francisco, Tokyo, and Paris?");
6363

6464
var promptOptions = OpenAiChatOptions.builder()
65-
.functionCallbacks(
65+
.toolCallbacks(
6666
List.of(FunctionToolCallback.builder("CurrentWeatherService", new MockWeatherService())
6767
.description("Get the weather in location")
6868
.inputType(MockWeatherService.Request.class)
@@ -91,7 +91,7 @@ void streamingFunctionCallTest() {
9191
"What's the weather like in San Francisco, Tokyo, and Paris?");
9292

9393
var promptOptions = OpenAiChatOptions.builder()
94-
.functionCallbacks(
94+
.toolCallbacks(
9595
List.of(FunctionToolCallback.builder("CurrentWeatherService", new MockWeatherService())
9696
.description("Get the weather in location")
9797
.inputType(MockWeatherService.Request.class)

auto-configurations/models/spring-ai-autoconfigure-model-openai/src/test/java/org/springframework/ai/model/openai/autoconfigure/tool/FunctionCallbackWithPlainFunctionBeanIT.java

+12-12
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void functionCallingVoidInput() {
8080
UserMessage userMessage = new UserMessage("Turn the light on in the living room");
8181

8282
ChatResponse response = chatModel.call(new Prompt(List.of(userMessage),
83-
OpenAiChatOptions.builder().function("turnLivingRoomLightOn").build()));
83+
OpenAiChatOptions.builder().toolNames("turnLivingRoomLightOn").build()));
8484

8585
logger.info("Response: {}", response);
8686
assertThat(feedback).hasSize(1);
@@ -98,7 +98,7 @@ void functionCallingSupplier() {
9898
UserMessage userMessage = new UserMessage("Turn the light on in the living room");
9999

100100
ChatResponse response = chatModel.call(new Prompt(List.of(userMessage),
101-
OpenAiChatOptions.builder().function("turnLivingRoomLightOnSupplier").build()));
101+
OpenAiChatOptions.builder().toolNames("turnLivingRoomLightOnSupplier").build()));
102102

103103
logger.info("Response: {}", response);
104104
assertThat(feedback).hasSize(1);
@@ -116,7 +116,7 @@ void functionCallingVoidOutput() {
116116
UserMessage userMessage = new UserMessage("Turn the light on in the kitchen and in the living room");
117117

118118
ChatResponse response = chatModel
119-
.call(new Prompt(List.of(userMessage), OpenAiChatOptions.builder().function("turnLight").build()));
119+
.call(new Prompt(List.of(userMessage), OpenAiChatOptions.builder().toolNames("turnLight").build()));
120120

121121
logger.info("Response: {}", response);
122122
assertThat(feedback).hasSize(2);
@@ -135,7 +135,7 @@ void functionCallingConsumer() {
135135
UserMessage userMessage = new UserMessage("Turn the light on in the kitchen and in the living room");
136136

137137
ChatResponse response = chatModel.call(new Prompt(List.of(userMessage),
138-
OpenAiChatOptions.builder().function("turnLightConsumer").build()));
138+
OpenAiChatOptions.builder().toolNames("turnLightConsumer").build()));
139139

140140
logger.info("Response: {}", response);
141141
assertThat(feedback).hasSize(2);
@@ -174,7 +174,7 @@ void functionCallWithDirectBiFunction() {
174174
ChatClient chatClient = ChatClient.builder(chatModel).build();
175175

176176
String content = chatClient.prompt("What's the weather like in San Francisco, Tokyo, and Paris?")
177-
.functions("weatherFunctionWithContext")
177+
.tools("weatherFunctionWithContext")
178178
.toolContext(Map.of("sessionId", "123"))
179179
.call()
180180
.content();
@@ -186,7 +186,7 @@ void functionCallWithDirectBiFunction() {
186186

187187
ChatResponse response = chatModel.call(new Prompt(List.of(userMessage),
188188
OpenAiChatOptions.builder()
189-
.function("weatherFunctionWithContext")
189+
.toolNames("weatherFunctionWithContext")
190190
.toolContext(Map.of("sessionId", "123"))
191191
.build()));
192192

@@ -206,7 +206,7 @@ void functionCallWithBiFunctionClass() {
206206
ChatClient chatClient = ChatClient.builder(chatModel).build();
207207

208208
String content = chatClient.prompt("What's the weather like in San Francisco, Tokyo, and Paris?")
209-
.functions("weatherFunctionWithClassBiFunction")
209+
.tools("weatherFunctionWithClassBiFunction")
210210
.toolContext(Map.of("sessionId", "123"))
211211
.call()
212212
.content();
@@ -218,7 +218,7 @@ void functionCallWithBiFunctionClass() {
218218

219219
ChatResponse response = chatModel.call(new Prompt(List.of(userMessage),
220220
OpenAiChatOptions.builder()
221-
.function("weatherFunctionWithClassBiFunction")
221+
.toolNames("weatherFunctionWithClassBiFunction")
222222
.toolContext(Map.of("sessionId", "123"))
223223
.build()));
224224

@@ -240,15 +240,15 @@ void functionCallTest() {
240240
"What's the weather like in San Francisco, Tokyo, and Paris? You can call the following functions 'weatherFunction'");
241241

242242
ChatResponse response = chatModel.call(
243-
new Prompt(List.of(userMessage), OpenAiChatOptions.builder().function("weatherFunction").build()));
243+
new Prompt(List.of(userMessage), OpenAiChatOptions.builder().toolNames("weatherFunction").build()));
244244

245245
logger.info("Response: {}", response);
246246

247247
assertThat(response.getResult().getOutput().getText()).contains("30", "10", "15");
248248

249249
// Test weatherFunctionTwo
250250
response = chatModel.call(new Prompt(List.of(userMessage),
251-
OpenAiChatOptions.builder().function("weatherFunctionTwo").build()));
251+
OpenAiChatOptions.builder().toolNames("weatherFunctionTwo").build()));
252252

253253
logger.info("Response: {}", response);
254254

@@ -289,7 +289,7 @@ void streamFunctionCallTest() {
289289
"What's the weather like in San Francisco, Tokyo, and Paris? You can call the following functions 'weatherFunction'");
290290

291291
Flux<ChatResponse> response = chatModel.stream(
292-
new Prompt(List.of(userMessage), OpenAiChatOptions.builder().function("weatherFunction").build()));
292+
new Prompt(List.of(userMessage), OpenAiChatOptions.builder().toolNames("weatherFunction").build()));
293293

294294
String content = response.collectList()
295295
.block()
@@ -305,7 +305,7 @@ void streamFunctionCallTest() {
305305

306306
// Test weatherFunctionTwo
307307
response = chatModel.stream(new Prompt(List.of(userMessage),
308-
OpenAiChatOptions.builder().function("weatherFunctionTwo").build()));
308+
OpenAiChatOptions.builder().toolNames("weatherFunctionTwo").build()));
309309

310310
content = response.collectList()
311311
.block()

auto-configurations/models/spring-ai-autoconfigure-model-openai/src/test/java/org/springframework/ai/model/openai/autoconfigure/tool/OpenAiFunctionCallback2IT.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void functionCallTest() {
5555

5656
// @formatter:off
5757
ChatClient chatClient = ChatClient.builder(chatModel)
58-
.defaultFunctions("WeatherInfo")
58+
.defaultTools("WeatherInfo")
5959
.defaultUser(u -> u.text("What's the weather like in {cities}?"))
6060
.build();
6161

@@ -78,7 +78,7 @@ void streamFunctionCallTest() {
7878

7979
// @formatter:off
8080
String content = ChatClient.builder(chatModel).build().prompt()
81-
.functions("WeatherInfo")
81+
.tools("WeatherInfo")
8282
.user("What's the weather like in San Francisco, Tokyo, and Paris?")
8383
.stream().content()
8484
.collectList().block().stream().collect(Collectors.joining());

auto-configurations/models/spring-ai-autoconfigure-model-openai/src/test/java/org/springframework/ai/model/openai/autoconfigure/tool/OpenAiFunctionCallbackIT.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void functionCallTest() {
6363
UserMessage userMessage = new UserMessage("What's the weather like in San Francisco, Tokyo, and Paris?");
6464

6565
ChatResponse response = chatModel
66-
.call(new Prompt(List.of(userMessage), OpenAiChatOptions.builder().function("WeatherInfo").build()));
66+
.call(new Prompt(List.of(userMessage), OpenAiChatOptions.builder().toolNames("WeatherInfo").build()));
6767

6868
logger.info("Response: {}", response);
6969

@@ -82,7 +82,7 @@ void streamFunctionCallTest() {
8282
"What's the weather like in San Francisco, Tokyo, and Paris? You can call the following functions 'WeatherInfo'");
8383

8484
Flux<ChatResponse> response = chatModel
85-
.stream(new Prompt(List.of(userMessage), OpenAiChatOptions.builder().function("WeatherInfo").build()));
85+
.stream(new Prompt(List.of(userMessage), OpenAiChatOptions.builder().toolNames("WeatherInfo").build()));
8686

8787
String content = response.collectList()
8888
.block()

auto-configurations/models/tool/spring-ai-autoconfigure-model-tool/src/main/java/org/springframework/ai/model/tool/autoconfigure/ToolCallingAutoConfiguration.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import io.micrometer.observation.ObservationRegistry;
2323

2424
import org.springframework.ai.chat.model.ChatModel;
25-
import org.springframework.ai.model.function.FunctionCallback;
25+
import org.springframework.ai.tool.ToolCallback;
2626
import org.springframework.ai.model.tool.ToolCallingManager;
2727
import org.springframework.ai.tool.ToolCallbackProvider;
2828
import org.springframework.ai.tool.execution.DefaultToolExecutionExceptionProcessor;
@@ -52,9 +52,9 @@ public class ToolCallingAutoConfiguration {
5252
@Bean
5353
@ConditionalOnMissingBean
5454
ToolCallbackResolver toolCallbackResolver(GenericApplicationContext applicationContext,
55-
List<FunctionCallback> functionCallbacks, List<ToolCallbackProvider> tcbProviders) {
55+
List<ToolCallback> toolCallbacks, List<ToolCallbackProvider> tcbProviders) {
5656

57-
List<FunctionCallback> allFunctionAndToolCallbacks = new ArrayList<>(functionCallbacks);
57+
List<ToolCallback> allFunctionAndToolCallbacks = new ArrayList<>(toolCallbacks);
5858
tcbProviders.stream().map(pr -> List.of(pr.getToolCallbacks())).forEach(allFunctionAndToolCallbacks::addAll);
5959

6060
var staticToolCallbackResolver = new StaticToolCallbackResolver(allFunctionAndToolCallbacks);

0 commit comments

Comments
 (0)