Skip to content

Commit ebfa5b9

Browse files
markpollackilayaperumalg
authored andcommitted
refactor: remove inter package dependency cycles in spring-ai-model
Remove circular dependencies: Move utility classes from various packages to dedicated support packages: - Move ToolCallbacks from ai.tool to ai.support - Move UsageUtils to UsageCalculator in ai.support - Move tool.util to tool.support - Create new ToolDefinitions utility class Support packages for the classes in question is more idomatic in spring than util packages. Signed-off-by: Mark Pollack <[email protected]>
1 parent 548abed commit ebfa5b9

File tree

42 files changed

+156
-117
lines changed

Some content is hidden

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

42 files changed

+156
-117
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
import org.springframework.ai.model.tool.ToolCallingChatOptions;
3737
import org.springframework.ai.ollama.OllamaChatModel;
3838
import org.springframework.ai.ollama.api.OllamaOptions;
39-
import org.springframework.ai.tool.ToolCallbacks;
39+
import org.springframework.ai.support.ToolCallbacks;
4040
import org.springframework.ai.tool.annotation.Tool;
4141
import org.springframework.boot.autoconfigure.AutoConfigurations;
4242
import org.springframework.boot.test.context.runner.ApplicationContextRunner;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@
2626
import org.springframework.ai.tool.ToolCallback;
2727
import org.springframework.ai.tool.ToolCallbackProvider;
2828
import org.springframework.ai.tool.annotation.Tool;
29-
import org.springframework.ai.tool.definition.ToolDefinition;
3029
import org.springframework.ai.tool.execution.DefaultToolExecutionExceptionProcessor;
3130
import org.springframework.ai.tool.execution.ToolExecutionExceptionProcessor;
3231
import org.springframework.ai.tool.function.FunctionToolCallback;
3332
import org.springframework.ai.tool.method.MethodToolCallback;
3433
import org.springframework.ai.tool.method.MethodToolCallbackProvider;
3534
import org.springframework.ai.tool.resolution.DelegatingToolCallbackResolver;
3635
import org.springframework.ai.tool.resolution.ToolCallbackResolver;
36+
import org.springframework.ai.tool.support.ToolDefinitions;
3737
import org.springframework.boot.autoconfigure.AutoConfigurations;
3838
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
3939
import org.springframework.context.annotation.Bean;
@@ -187,7 +187,7 @@ public ToolCallbackProvider blabla() {
187187
public ToolCallback toolCallbacks6() {
188188
var toolMethod = ReflectionUtils.findMethod(WeatherService.class, "getAlert", String.class);
189189
return MethodToolCallback.builder()
190-
.toolDefinition(ToolDefinition.builder(toolMethod).build())
190+
.toolDefinition(ToolDefinitions.builder(toolMethod).build())
191191
.toolMethod(toolMethod)
192192
.toolObject(new WeatherService())
193193
.build();

mcp/common/src/main/java/org/springframework/ai/mcp/AsyncMcpToolCallback.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.springframework.ai.chat.model.ToolContext;
2626
import org.springframework.ai.model.ModelOptionsUtils;
2727
import org.springframework.ai.tool.ToolCallback;
28+
import org.springframework.ai.tool.definition.DefaultToolDefinition;
2829
import org.springframework.ai.tool.definition.ToolDefinition;
2930

3031
/**
@@ -84,7 +85,7 @@ public AsyncMcpToolCallback(McpAsyncClient mcpClient, Tool tool) {
8485
*/
8586
@Override
8687
public ToolDefinition getToolDefinition() {
87-
return ToolDefinition.builder()
88+
return DefaultToolDefinition.builder()
8889
.name(McpToolUtils.prefixedToolName(this.asyncMcpClient.getClientInfo().name(), this.tool.name()))
8990
.description(this.tool.description())
9091
.inputSchema(ModelOptionsUtils.toJsonString(this.tool.inputSchema()))

mcp/common/src/main/java/org/springframework/ai/mcp/AsyncMcpToolCallbackProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
import org.springframework.ai.tool.ToolCallback;
2929
import org.springframework.ai.tool.ToolCallbackProvider;
30-
import org.springframework.ai.tool.util.ToolUtils;
30+
import org.springframework.ai.tool.support.ToolUtils;
3131
import org.springframework.util.CollectionUtils;
3232

3333
/**

mcp/common/src/main/java/org/springframework/ai/mcp/SyncMcpToolCallback.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.springframework.ai.chat.model.ToolContext;
2727
import org.springframework.ai.model.ModelOptionsUtils;
2828
import org.springframework.ai.tool.ToolCallback;
29+
import org.springframework.ai.tool.definition.DefaultToolDefinition;
2930
import org.springframework.ai.tool.definition.ToolDefinition;
3031

3132
/**
@@ -88,7 +89,7 @@ public SyncMcpToolCallback(McpSyncClient mcpClient, Tool tool) {
8889
*/
8990
@Override
9091
public ToolDefinition getToolDefinition() {
91-
return ToolDefinition.builder()
92+
return DefaultToolDefinition.builder()
9293
.name(McpToolUtils.prefixedToolName(this.mcpClient.getClientInfo().name(), this.tool.name()))
9394
.description(this.tool.description())
9495
.inputSchema(ModelOptionsUtils.toJsonString(this.tool.inputSchema()))

mcp/common/src/main/java/org/springframework/ai/mcp/SyncMcpToolCallbackProvider.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package org.springframework.ai.mcp;
1818

19-
import java.util.ArrayList;
2019
import java.util.List;
2120
import java.util.function.BiPredicate;
2221

@@ -25,7 +24,7 @@
2524

2625
import org.springframework.ai.tool.ToolCallback;
2726
import org.springframework.ai.tool.ToolCallbackProvider;
28-
import org.springframework.ai.tool.util.ToolUtils;
27+
import org.springframework.ai.tool.support.ToolUtils;
2928
import org.springframework.util.Assert;
3029
import org.springframework.util.CollectionUtils;
3130

mcp/common/src/test/java/org/springframework/ai/mcp/ToolUtilsTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import reactor.test.StepVerifier;
3636

3737
import org.springframework.ai.tool.ToolCallback;
38+
import org.springframework.ai.tool.definition.DefaultToolDefinition;
3839
import org.springframework.ai.tool.definition.ToolDefinition;
3940

4041
import static org.assertj.core.api.Assertions.assertThat;
@@ -193,7 +194,7 @@ void toAsyncToolSpecificationShouldConvertMultipleCallbacks() {
193194

194195
private ToolCallback createMockToolCallback(String name, String result) {
195196
ToolCallback callback = mock(ToolCallback.class);
196-
ToolDefinition definition = ToolDefinition.builder()
197+
ToolDefinition definition = DefaultToolDefinition.builder()
197198
.name(name)
198199
.description("Test tool")
199200
.inputSchema("{}")
@@ -205,7 +206,7 @@ private ToolCallback createMockToolCallback(String name, String result) {
205206

206207
private ToolCallback createMockToolCallback(String name, RuntimeException error) {
207208
ToolCallback callback = mock(ToolCallback.class);
208-
ToolDefinition definition = ToolDefinition.builder()
209+
ToolDefinition definition = DefaultToolDefinition.builder()
209210
.name(name)
210211
.description("Test tool")
211212
.inputSchema("{}")

models/spring-ai-anthropic/src/main/java/org/springframework/ai/anthropic/AnthropicChatModel.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
import org.springframework.ai.chat.metadata.DefaultUsage;
5252
import org.springframework.ai.chat.metadata.EmptyUsage;
5353
import org.springframework.ai.chat.metadata.Usage;
54-
import org.springframework.ai.chat.metadata.UsageUtils;
54+
import org.springframework.ai.support.UsageCalculator;
5555
import org.springframework.ai.chat.model.ChatModel;
5656
import org.springframework.ai.chat.model.ChatResponse;
5757
import org.springframework.ai.chat.model.Generation;
@@ -194,7 +194,8 @@ public ChatResponse internalCall(Prompt prompt, ChatResponse previousChatRespons
194194

195195
Usage currentChatResponseUsage = usage != null ? this.getDefaultUsage(completionResponse.usage())
196196
: new EmptyUsage();
197-
Usage accumulatedUsage = UsageUtils.getCumulativeUsage(currentChatResponseUsage, previousChatResponse);
197+
Usage accumulatedUsage = UsageCalculator.getCumulativeUsage(currentChatResponseUsage,
198+
previousChatResponse);
198199

199200
ChatResponse chatResponse = toChatResponse(completionEntity.getBody(), accumulatedUsage);
200201
observationContext.setResponse(chatResponse);
@@ -256,7 +257,7 @@ public Flux<ChatResponse> internalStream(Prompt prompt, ChatResponse previousCha
256257
Flux<ChatResponse> chatResponseFlux = response.flatMap(chatCompletionResponse -> {
257258
AnthropicApi.Usage usage = chatCompletionResponse.usage();
258259
Usage currentChatResponseUsage = usage != null ? this.getDefaultUsage(chatCompletionResponse.usage()) : new EmptyUsage();
259-
Usage accumulatedUsage = UsageUtils.getCumulativeUsage(currentChatResponseUsage, previousChatResponse);
260+
Usage accumulatedUsage = UsageCalculator.getCumulativeUsage(currentChatResponseUsage, previousChatResponse);
260261
ChatResponse chatResponse = toChatResponse(chatCompletionResponse, accumulatedUsage);
261262

262263
if (this.toolExecutionEligibilityPredicate.isToolExecutionRequired(prompt.getOptions(), chatResponse) && chatResponse.hasFinishReasons(Set.of("tool_use"))) {

models/spring-ai-anthropic/src/test/java/org/springframework/ai/anthropic/client/AnthropicChatClientMethodInvokingFunctionCallbackIT.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
import org.springframework.ai.chat.model.ChatModel;
3333
import org.springframework.ai.chat.model.ToolContext;
3434
import org.springframework.ai.tool.annotation.Tool;
35-
import org.springframework.ai.tool.definition.ToolDefinition;
3635
import org.springframework.ai.tool.method.MethodToolCallback;
36+
import org.springframework.ai.tool.support.ToolDefinitions;
3737
import org.springframework.beans.factory.annotation.Autowired;
3838
import org.springframework.boot.test.context.SpringBootTest;
3939
import org.springframework.test.context.ActiveProfiles;
@@ -68,7 +68,7 @@ void methodGetWeatherGeneratedDescription() {
6868
String response = ChatClient.create(this.chatModel).prompt()
6969
.user("What's the weather like in San Francisco, Tokyo, and Paris? Use Celsius.")
7070
.toolCallbacks(MethodToolCallback.builder()
71-
.toolDefinition(ToolDefinition.builder(toolMethod).build())
71+
.toolDefinition(ToolDefinitions.builder(toolMethod).build())
7272
.toolMethod(toolMethod)
7373
.build())
7474
.call()
@@ -90,7 +90,7 @@ void methodGetWeatherStatic() {
9090
String response = ChatClient.create(this.chatModel).prompt()
9191
.user("What's the weather like in San Francisco, Tokyo, and Paris? Use Celsius.")
9292
.toolCallbacks(MethodToolCallback.builder()
93-
.toolDefinition(ToolDefinition.builder(toolMethod)
93+
.toolDefinition(ToolDefinitions.builder(toolMethod)
9494
.description("Get the weather in location")
9595
.build())
9696
.toolMethod(toolMethod)
@@ -117,7 +117,7 @@ void methodTurnLightNoResponse() {
117117
String response = ChatClient.create(this.chatModel).prompt()
118118
.user("Turn light on in the living room.")
119119
.toolCallbacks(MethodToolCallback.builder()
120-
.toolDefinition(ToolDefinition.builder(turnLightMethod)
120+
.toolDefinition(ToolDefinitions.builder(turnLightMethod)
121121
.description("Turn light on in the living room.")
122122
.build())
123123
.toolMethod(turnLightMethod)
@@ -145,7 +145,7 @@ void methodGetWeatherNonStatic() {
145145
String response = ChatClient.create(this.chatModel).prompt()
146146
.user("What's the weather like in San Francisco, Tokyo, and Paris? Use Celsius.")
147147
.toolCallbacks(MethodToolCallback.builder()
148-
.toolDefinition(ToolDefinition.builder(toolMethod)
148+
.toolDefinition(ToolDefinitions.builder(toolMethod)
149149
.description("Get the weather in location")
150150
.build())
151151
.toolMethod(toolMethod)
@@ -172,7 +172,7 @@ void methodGetWeatherToolContext() {
172172
String response = ChatClient.create(this.chatModel).prompt()
173173
.user("What's the weather like in San Francisco, Tokyo, and Paris? Use Celsius.")
174174
.toolCallbacks(MethodToolCallback.builder()
175-
.toolDefinition(ToolDefinition.builder(toolMethod)
175+
.toolDefinition(ToolDefinitions.builder(toolMethod)
176176
.description("Get the weather in location")
177177
.build())
178178
.toolMethod(toolMethod)
@@ -203,7 +203,7 @@ void methodGetWeatherWithContextMethodButMissingContext() {
203203
assertThatThrownBy(() -> ChatClient.create(this.chatModel).prompt()
204204
.user("What's the weather like in San Francisco, Tokyo, and Paris? Use Celsius.")
205205
.toolCallbacks(MethodToolCallback.builder()
206-
.toolDefinition(ToolDefinition.builder(toolMethod)
206+
.toolDefinition(ToolDefinitions.builder(toolMethod)
207207
.description("Get the weather in location")
208208
.build())
209209
.toolMethod(toolMethod)
@@ -229,7 +229,7 @@ void methodNoParameters() {
229229
.user("Turn light on in the living room.")
230230
.toolCallbacks(MethodToolCallback.builder()
231231
.toolMethod(toolMethod)
232-
.toolDefinition(ToolDefinition.builder(toolMethod)
232+
.toolDefinition(ToolDefinitions.builder(toolMethod)
233233
.description("Can turn lights on in the Living Room")
234234
.build())
235235
.toolObject(targetObject)

models/spring-ai-azure-openai/src/main/java/org/springframework/ai/azure/openai/AzureOpenAiChatModel.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
import org.springframework.ai.chat.metadata.PromptMetadata;
7878
import org.springframework.ai.chat.metadata.PromptMetadata.PromptFilterMetadata;
7979
import org.springframework.ai.chat.metadata.Usage;
80-
import org.springframework.ai.chat.metadata.UsageUtils;
80+
import org.springframework.ai.support.UsageCalculator;
8181
import org.springframework.ai.chat.model.ChatModel;
8282
import org.springframework.ai.chat.model.ChatResponse;
8383
import org.springframework.ai.chat.model.Generation;
@@ -357,15 +357,16 @@ public Flux<ChatResponse> internalStream(Prompt prompt, ChatResponse previousCha
357357
// Accumulate the usage from the previous chat response
358358
CompletionsUsage usage = chatCompletion.getUsage();
359359
Usage currentChatResponseUsage = usage != null ? getDefaultUsage(usage) : new EmptyUsage();
360-
Usage accumulatedUsage = UsageUtils.getCumulativeUsage(currentChatResponseUsage, previousChatResponse);
360+
Usage accumulatedUsage = UsageCalculator.getCumulativeUsage(currentChatResponseUsage,
361+
previousChatResponse);
361362
return toChatResponse(chatCompletion, accumulatedUsage);
362363
}).buffer(2, 1).map(bufferList -> {
363364
ChatResponse chatResponse1 = bufferList.get(0);
364365
if (options.getStreamOptions() != null && options.getStreamOptions().isIncludeUsage()) {
365366
if (bufferList.size() == 2) {
366367
ChatResponse chatResponse2 = bufferList.get(1);
367368
if (chatResponse2 != null && chatResponse2.getMetadata() != null
368-
&& !UsageUtils.isEmpty(chatResponse2.getMetadata().getUsage())) {
369+
&& !UsageCalculator.isEmpty(chatResponse2.getMetadata().getUsage())) {
369370
return toChatResponse(chatResponse1, chatResponse2.getMetadata().getUsage());
370371
}
371372
}
@@ -462,7 +463,7 @@ private ChatResponse toChatResponse(ChatCompletions chatCompletions, ChatRespons
462463
if (chatCompletions.getUsage() != null) {
463464
currentUsage = getDefaultUsage(chatCompletions.getUsage());
464465
}
465-
Usage cumulativeUsage = UsageUtils.getCumulativeUsage(currentUsage, previousChatResponse);
466+
Usage cumulativeUsage = UsageCalculator.getCumulativeUsage(currentUsage, previousChatResponse);
466467
return new ChatResponse(generations, from(chatCompletions, promptFilterMetadata, cumulativeUsage));
467468
}
468469

models/spring-ai-deepseek/src/main/java/org/springframework/ai/deepseek/DeepSeekChatModel.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import org.springframework.ai.model.ModelOptionsUtils;
4444
import org.springframework.ai.model.tool.*;
4545
import org.springframework.ai.retry.RetryUtils;
46+
import org.springframework.ai.support.UsageCalculator;
4647
import org.springframework.ai.tool.definition.ToolDefinition;
4748
import org.springframework.http.ResponseEntity;
4849
import org.springframework.retry.support.RetryTemplate;
@@ -179,7 +180,8 @@ public ChatResponse internalCall(Prompt prompt, ChatResponse previousChatRespons
179180
// Current usage
180181
DeepSeekApi.Usage usage = completionEntity.getBody().usage();
181182
Usage currentChatResponseUsage = usage != null ? getDefaultUsage(usage) : new EmptyUsage();
182-
Usage accumulatedUsage = UsageUtils.getCumulativeUsage(currentChatResponseUsage, previousChatResponse);
183+
Usage accumulatedUsage = UsageCalculator.getCumulativeUsage(currentChatResponseUsage,
184+
previousChatResponse);
183185
ChatResponse chatResponse = new ChatResponse(generations,
184186
from(completionEntity.getBody(), accumulatedUsage));
185187

@@ -256,7 +258,7 @@ public Flux<ChatResponse> internalStream(Prompt prompt, ChatResponse previousCha
256258
}).toList();
257259
DeepSeekApi.Usage usage = chatCompletion2.usage();
258260
Usage currentUsage = (usage != null) ? getDefaultUsage(usage) : new EmptyUsage();
259-
Usage cumulativeUsage = UsageUtils.getCumulativeUsage(currentUsage, previousChatResponse);
261+
Usage cumulativeUsage = UsageCalculator.getCumulativeUsage(currentUsage, previousChatResponse);
260262

261263
return new ChatResponse(generations, from(chatCompletion2, cumulativeUsage));
262264
}

models/spring-ai-mistral-ai/src/main/java/org/springframework/ai/mistralai/MistralAiChatModel.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
import org.springframework.ai.chat.metadata.ChatResponseMetadata;
4040
import org.springframework.ai.chat.metadata.DefaultUsage;
4141
import org.springframework.ai.chat.metadata.Usage;
42-
import org.springframework.ai.chat.metadata.UsageUtils;
42+
import org.springframework.ai.support.UsageCalculator;
4343
import org.springframework.ai.chat.model.ChatModel;
4444
import org.springframework.ai.chat.model.ChatResponse;
4545
import org.springframework.ai.chat.model.Generation;
@@ -216,7 +216,7 @@ public ChatResponse internalCall(Prompt prompt, ChatResponse previousChatRespons
216216
}).toList();
217217

218218
DefaultUsage usage = getDefaultUsage(completionEntity.getBody().usage());
219-
Usage cumulativeUsage = UsageUtils.getCumulativeUsage(usage, previousChatResponse);
219+
Usage cumulativeUsage = UsageCalculator.getCumulativeUsage(usage, previousChatResponse);
220220
ChatResponse chatResponse = new ChatResponse(generations,
221221
from(completionEntity.getBody(), cumulativeUsage));
222222

@@ -298,7 +298,7 @@ public Flux<ChatResponse> internalStream(Prompt prompt, ChatResponse previousCha
298298

299299
if (chatCompletion2.usage() != null) {
300300
DefaultUsage usage = getDefaultUsage(chatCompletion2.usage());
301-
Usage cumulativeUsage = UsageUtils.getCumulativeUsage(usage, previousChatResponse);
301+
Usage cumulativeUsage = UsageCalculator.getCumulativeUsage(usage, previousChatResponse);
302302
return new ChatResponse(generations, from(chatCompletion2, cumulativeUsage));
303303
}
304304
else {

models/spring-ai-mistral-ai/src/test/java/org/springframework/ai/mistralai/MistralAiChatCompletionRequestTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.springframework.ai.mistralai.api.MistralAiApi;
2626
import org.springframework.ai.model.tool.ToolCallingChatOptions;
2727
import org.springframework.ai.tool.ToolCallback;
28+
import org.springframework.ai.tool.definition.DefaultToolDefinition;
2829
import org.springframework.ai.tool.definition.ToolDefinition;
2930
import org.springframework.boot.test.context.SpringBootTest;
3031

@@ -106,7 +107,7 @@ static class TestToolCallback implements ToolCallback {
106107
private final ToolDefinition toolDefinition;
107108

108109
TestToolCallback(String name) {
109-
this.toolDefinition = ToolDefinition.builder().name(name).inputSchema("{}").build();
110+
this.toolDefinition = DefaultToolDefinition.builder().name(name).inputSchema("{}").build();
110111
}
111112

112113
@Override

models/spring-ai-mistral-ai/src/test/java/org/springframework/ai/mistralai/MistralAiChatModelIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
import org.springframework.ai.model.tool.ToolCallingChatOptions;
5757
import org.springframework.ai.model.tool.ToolCallingManager;
5858
import org.springframework.ai.model.tool.ToolExecutionResult;
59-
import org.springframework.ai.tool.ToolCallbacks;
59+
import org.springframework.ai.support.ToolCallbacks;
6060
import org.springframework.ai.tool.annotation.Tool;
6161
import org.springframework.ai.tool.function.FunctionToolCallback;
6262
import org.springframework.beans.factory.annotation.Autowired;

models/spring-ai-ollama/src/test/java/org/springframework/ai/ollama/OllamaChatModelIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
import org.springframework.ai.ollama.management.ModelManagementOptions;
5353
import org.springframework.ai.ollama.management.OllamaModelManager;
5454
import org.springframework.ai.ollama.management.PullModelStrategy;
55-
import org.springframework.ai.tool.ToolCallbacks;
55+
import org.springframework.ai.support.ToolCallbacks;
5656
import org.springframework.ai.tool.annotation.Tool;
5757
import org.springframework.beans.factory.annotation.Autowired;
5858
import org.springframework.boot.SpringBootConfiguration;

models/spring-ai-ollama/src/test/java/org/springframework/ai/ollama/OllamaChatRequestTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.springframework.ai.ollama.api.OllamaApi;
2727
import org.springframework.ai.ollama.api.OllamaOptions;
2828
import org.springframework.ai.tool.ToolCallback;
29+
import org.springframework.ai.tool.definition.DefaultToolDefinition;
2930
import org.springframework.ai.tool.definition.ToolDefinition;
3031

3132
import static org.assertj.core.api.Assertions.assertThat;
@@ -167,7 +168,7 @@ static class TestToolCallback implements ToolCallback {
167168
private final ToolDefinition toolDefinition;
168169

169170
TestToolCallback(String name) {
170-
this.toolDefinition = ToolDefinition.builder().name(name).inputSchema("{}").build();
171+
this.toolDefinition = DefaultToolDefinition.builder().name(name).inputSchema("{}").build();
171172
}
172173

173174
@Override

0 commit comments

Comments
 (0)