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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 4 additions & 5 deletions
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

Lines changed: 2 additions & 4 deletions
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)

0 commit comments

Comments
 (0)