Skip to content

Commit 79efa7f

Browse files
committed
GH-1540: Remove Spring Boot dependencies from core modules
Resolves #1540 - Remove @NestedConfigurationProperty and @ConstructorBinding annotations from model options classes - Remove spring-boot dependency from spring-ai-openai module - Add exclusion for spring-boot-autoconfigure in spring-cloud-function-context dependency - Move configuration metadata to spring-ai-spring-boot-autoconfigure module This change decouples the core AI model implementations from Spring Boot, making the core modules more lightweight and allowing them to be used in non-Spring Boot applications. Configuration properties are now handled by the spring-ai-spring-boot-autoconfigure module instead.
1 parent 9c7af56 commit 79efa7f

File tree

18 files changed

+39
-77
lines changed

18 files changed

+39
-77
lines changed

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

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,17 @@
2222
import java.util.Map;
2323
import java.util.Set;
2424

25+
import org.springframework.ai.chat.prompt.ChatOptions;
26+
import org.springframework.ai.model.function.FunctionCallback;
27+
import org.springframework.ai.model.function.FunctionCallingOptions;
28+
import org.springframework.util.Assert;
29+
2530
import com.azure.ai.openai.models.AzureChatEnhancementConfiguration;
2631
import com.fasterxml.jackson.annotation.JsonIgnore;
2732
import com.fasterxml.jackson.annotation.JsonInclude;
2833
import com.fasterxml.jackson.annotation.JsonInclude.Include;
2934
import com.fasterxml.jackson.annotation.JsonProperty;
3035

31-
import org.springframework.ai.chat.prompt.ChatOptions;
32-
import org.springframework.ai.model.function.FunctionCallback;
33-
import org.springframework.ai.model.function.FunctionCallingOptions;
34-
import org.springframework.boot.context.properties.NestedConfigurationProperty;
35-
import org.springframework.util.Assert;
36-
3736
/**
3837
* The configuration information for a chat completions request. Completions support a
3938
* wide variety of tasks and generate text that continues from or "completes" provided
@@ -145,7 +144,6 @@ public class AzureOpenAiChatOptions implements FunctionCallingOptions, ChatOptio
145144
* default. Use the enableFunctions to set the functions from the registry to be used
146145
* by the ChatModel chat completion requests.
147146
*/
148-
@NestedConfigurationProperty
149147
@JsonIgnore
150148
private List<FunctionCallback> functionCallbacks = new ArrayList<>();
151149

@@ -160,7 +158,6 @@ public class AzureOpenAiChatOptions implements FunctionCallingOptions, ChatOptio
160158
* functions is set in a prompt options, then the enabled functions are only active
161159
* for the duration of this prompt execution.
162160
*/
163-
@NestedConfigurationProperty
164161
@JsonIgnore
165162
private Set<String> functions = new HashSet<>();
166163

@@ -194,11 +191,9 @@ public class AzureOpenAiChatOptions implements FunctionCallingOptions, ChatOptio
194191
* If provided, the configuration options for available Azure OpenAI chat
195192
* enhancements.
196193
*/
197-
@NestedConfigurationProperty
198194
@JsonIgnore
199195
private AzureChatEnhancementConfiguration enhancements;
200196

201-
@NestedConfigurationProperty
202197
@JsonIgnore
203198
private Map<String, Object> toolContext;
204199

models/spring-ai-minimax/src/main/java/org/springframework/ai/minimax/MiniMaxChatOptions.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import org.springframework.ai.minimax.api.MiniMaxApi;
3232
import org.springframework.ai.model.function.FunctionCallback;
3333
import org.springframework.ai.model.function.FunctionCallingOptions;
34-
import org.springframework.boot.context.properties.NestedConfigurationProperty;
3534
import org.springframework.util.Assert;
3635

3736
/**
@@ -88,7 +87,6 @@ public class MiniMaxChatOptions implements FunctionCallingOptions, ChatOptions {
8887
/**
8988
* Up to 4 sequences where the API will stop generating further tokens.
9089
*/
91-
@NestedConfigurationProperty
9290
private @JsonProperty("stop") List<String> stop;
9391
/**
9492
* What sampling temperature to use, between 0 and 1. Higher values like 0.8 will make the output
@@ -112,7 +110,6 @@ public class MiniMaxChatOptions implements FunctionCallingOptions, ChatOptions {
112110
* A list of tools the model may call. Currently, only functions are supported as a tool. Use this to
113111
* provide a list of functions the model may generate JSON inputs for.
114112
*/
115-
@NestedConfigurationProperty
116113
private @JsonProperty("tools") List<MiniMaxApi.FunctionTool> tools;
117114
/**
118115
* Controls which (if any) function is called by the model. none means the model will not call a
@@ -129,7 +126,6 @@ public class MiniMaxChatOptions implements FunctionCallingOptions, ChatOptions {
129126
* For Default Options the functionCallbacks are registered but disabled by default. Use the enableFunctions to set the functions
130127
* from the registry to be used by the ChatModel chat completion requests.
131128
*/
132-
@NestedConfigurationProperty
133129
@JsonIgnore
134130
private List<FunctionCallback> functionCallbacks = new ArrayList<>();
135131

@@ -142,14 +138,12 @@ public class MiniMaxChatOptions implements FunctionCallingOptions, ChatOptions {
142138
* Note that function enabled with the default options are enabled for all chat completion requests. This could impact the token count and the billing.
143139
* If the functions is set in a prompt options, then the enabled functions are only active for the duration of this prompt execution.
144140
*/
145-
@NestedConfigurationProperty
146141
@JsonIgnore
147142
private Set<String> functions = new HashSet<>();
148143

149144
@JsonIgnore
150145
private Boolean proxyToolCalls;
151146

152-
@NestedConfigurationProperty
153147
@JsonIgnore
154148
private Map<String, Object> toolContext;
155149

models/spring-ai-minimax/src/main/java/org/springframework/ai/minimax/api/MiniMaxApi.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import org.springframework.ai.model.ChatModelDescription;
3333
import org.springframework.ai.model.ModelOptionsUtils;
3434
import org.springframework.ai.retry.RetryUtils;
35-
import org.springframework.boot.context.properties.bind.ConstructorBinding;
3635
import org.springframework.core.ParameterizedTypeReference;
3736
import org.springframework.http.HttpHeaders;
3837
import org.springframework.http.MediaType;
@@ -339,7 +338,6 @@ public record FunctionTool(
339338
* Create a tool of type 'function' and the given function definition.
340339
* @param function function definition.
341340
*/
342-
@ConstructorBinding
343341
public FunctionTool(Function function) {
344342
this(Type.FUNCTION, function);
345343
}
@@ -381,7 +379,6 @@ public record Function(
381379
* @param name tool function name.
382380
* @param parameters tool function schema.
383381
*/
384-
@ConstructorBinding
385382
public Function(String description, String name, Map<String, Object> parameters) {
386383
this(description, name, ModelOptionsUtils.toJsonString(parameters));
387384
}

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import org.springframework.ai.mistralai.api.MistralAiApi.FunctionTool;
3535
import org.springframework.ai.model.function.FunctionCallback;
3636
import org.springframework.ai.model.function.FunctionCallingOptions;
37-
import org.springframework.boot.context.properties.NestedConfigurationProperty;
3837
import org.springframework.util.Assert;
3938

4039
/**
@@ -94,23 +93,20 @@ public class MistralAiChatOptions implements FunctionCallingOptions, ChatOptions
9493
* Stop generation if this token is detected. Or if one of these tokens is detected
9594
* when providing an array.
9695
*/
97-
@NestedConfigurationProperty
9896
private @JsonProperty("stop") List<String> stop;
9997

10098
/**
10199
* A list of tools the model may call. Currently, only functions are supported as a
102100
* tool. Use this to provide a list of functions the model may generate JSON inputs
103101
* for.
104102
*/
105-
@NestedConfigurationProperty
106103
private @JsonProperty("tools") List<FunctionTool> tools;
107104

108105
/**
109106
* Controls which (if any) function is called by the model. none means the model will
110107
* not call a function and instead generates a message. auto means the model can pick
111108
* between generating a message or calling a function.
112109
*/
113-
@NestedConfigurationProperty
114110
private @JsonProperty("tool_choice") ToolChoice toolChoice;
115111

116112
/**
@@ -120,7 +116,6 @@ public class MistralAiChatOptions implements FunctionCallingOptions, ChatOptions
120116
* disabled by default. Use the enableFunctions to set the functions from the registry
121117
* to be used by the ChatModel chat completion requests.
122118
*/
123-
@NestedConfigurationProperty
124119
@JsonIgnore
125120
private List<FunctionCallback> functionCallbacks = new ArrayList<>();
126121

@@ -135,14 +130,12 @@ public class MistralAiChatOptions implements FunctionCallingOptions, ChatOptions
135130
* functions is set in a prompt options, then the enabled functions are only active
136131
* for the duration of this prompt execution.
137132
*/
138-
@NestedConfigurationProperty
139133
@JsonIgnore
140134
private Set<String> functions = new HashSet<>();
141135

142136
@JsonIgnore
143137
private Boolean proxyToolCalls;
144138

145-
@NestedConfigurationProperty
146139
@JsonIgnore
147140
private Map<String, Object> toolContext;
148141

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import org.springframework.ai.model.ModelOptionsUtils;
3535
import org.springframework.ai.observation.conventions.AiProvider;
3636
import org.springframework.ai.retry.RetryUtils;
37-
import org.springframework.boot.context.properties.bind.ConstructorBinding;
3837
import org.springframework.core.ParameterizedTypeReference;
3938
import org.springframework.http.HttpHeaders;
4039
import org.springframework.http.MediaType;
@@ -324,7 +323,6 @@ public record FunctionTool(@JsonProperty("type") Type type, @JsonProperty("funct
324323
* Create a tool of type 'function' and the given function definition.
325324
* @param function function definition.
326325
*/
327-
@ConstructorBinding
328326
public FunctionTool(Function function) {
329327
this(Type.FUNCTION, function);
330328
}
@@ -362,7 +360,6 @@ public record Function(@JsonProperty("description") String description, @JsonPro
362360
* @param name tool function name.
363361
* @param jsonSchema tool function schema as json.
364362
*/
365-
@ConstructorBinding
366363
public Function(String description, String name, String jsonSchema) {
367364
this(description, name, ModelOptionsUtils.jsonToMap(jsonSchema));
368365
}

models/spring-ai-moonshot/src/main/java/org/springframework/ai/moonshot/MoonshotChatOptions.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import org.springframework.ai.model.function.FunctionCallback;
3131
import org.springframework.ai.model.function.FunctionCallingOptions;
3232
import org.springframework.ai.moonshot.api.MoonshotApi;
33-
import org.springframework.boot.context.properties.NestedConfigurationProperty;
3433
import org.springframework.util.Assert;
3534

3635
/**
@@ -90,10 +89,8 @@ public class MoonshotChatOptions implements FunctionCallingOptions, ChatOptions
9089
/**
9190
* Up to 5 sequences where the API will stop generating further tokens.
9291
*/
93-
@NestedConfigurationProperty
9492
private @JsonProperty("stop") List<String> stop;
9593

96-
@NestedConfigurationProperty
9794
private @JsonProperty("tools") List<MoonshotApi.FunctionTool> tools;
9895

9996
/**
@@ -115,7 +112,6 @@ public class MoonshotChatOptions implements FunctionCallingOptions, ChatOptions
115112
* default. Use the enableFunctions to set the functions from the registry to be used
116113
* by the ChatModel chat completion requests.
117114
*/
118-
@NestedConfigurationProperty
119115
@JsonIgnore
120116
private List<FunctionCallback> functionCallbacks = new ArrayList<>();
121117

@@ -130,7 +126,6 @@ public class MoonshotChatOptions implements FunctionCallingOptions, ChatOptions
130126
* functions is set in a prompt options, then the enabled functions are only active
131127
* for the duration of this prompt execution.
132128
*/
133-
@NestedConfigurationProperty
134129
@JsonIgnore
135130
private Set<String> functions = new HashSet<>();
136131

@@ -143,7 +138,6 @@ public class MoonshotChatOptions implements FunctionCallingOptions, ChatOptions
143138
@JsonIgnore
144139
private Boolean proxyToolCalls;
145140

146-
@NestedConfigurationProperty
147141
@JsonIgnore
148142
private Map<String, Object> toolContext;
149143

models/spring-ai-moonshot/src/main/java/org/springframework/ai/moonshot/api/MoonshotApi.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import org.springframework.ai.model.ChatModelDescription;
3232
import org.springframework.ai.model.ModelOptionsUtils;
3333
import org.springframework.ai.retry.RetryUtils;
34-
import org.springframework.boot.context.properties.bind.ConstructorBinding;
3534
import org.springframework.http.HttpHeaders;
3635
import org.springframework.http.MediaType;
3736
import org.springframework.http.ResponseEntity;
@@ -600,7 +599,6 @@ public record FunctionTool(@JsonProperty("type") Type type, @JsonProperty("funct
600599
* Create a tool of type 'function' and the given function definition.
601600
* @param function function definition.
602601
*/
603-
@ConstructorBinding
604602
public FunctionTool(Function function) {
605603
this(Type.FUNCTION, function);
606604
}
@@ -638,7 +636,6 @@ public record Function(@JsonProperty("description") String description, @JsonPro
638636
* @param name tool function name.
639637
* @param jsonSchema tool function schema as json.
640638
*/
641-
@ConstructorBinding
642639
public Function(String description, String name, String jsonSchema) {
643640
this(description, name, ModelOptionsUtils.jsonToMap(jsonSchema));
644641
}

models/spring-ai-ollama/src/main/java/org/springframework/ai/ollama/api/OllamaApi.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434

3535
import org.springframework.ai.model.ModelOptionsUtils;
3636
import org.springframework.ai.observation.conventions.AiProvider;
37-
import org.springframework.boot.context.properties.bind.ConstructorBinding;
3837
import org.springframework.http.HttpHeaders;
3938
import org.springframework.http.HttpMethod;
4039
import org.springframework.http.MediaType;
@@ -654,7 +653,6 @@ public record Tool(
654653
* Create a tool of type 'function' and the given function definition.
655654
* @param function function definition.
656655
*/
657-
@ConstructorBinding
658656
public Tool(Function function) {
659657
this(Type.FUNCTION, function);
660658
}
@@ -690,7 +688,6 @@ public record Function(
690688
* @param name tool function name.
691689
* @param jsonSchema tool function schema as json.
692690
*/
693-
@ConstructorBinding
694691
public Function(String description, String name, String jsonSchema) {
695692
this(description, name, ModelOptionsUtils.jsonToMap(jsonSchema));
696693
}

models/spring-ai-ollama/src/main/java/org/springframework/ai/ollama/api/OllamaOptions.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import org.springframework.ai.model.ModelOptionsUtils;
3535
import org.springframework.ai.model.function.FunctionCallback;
3636
import org.springframework.ai.model.function.FunctionCallingOptions;
37-
import org.springframework.boot.context.properties.NestedConfigurationProperty;
3837
import org.springframework.util.Assert;
3938

4039
/**
@@ -280,7 +279,6 @@ public class OllamaOptions implements FunctionCallingOptions, ChatOptions, Embed
280279
* For Default Options the functionCallbacks are registered but disabled by default. Use the enableFunctions to set the functions
281280
* from the registry to be used by the ChatModel chat completion requests.
282281
*/
283-
@NestedConfigurationProperty
284282
@JsonIgnore
285283
private List<FunctionCallback> functionCallbacks = new ArrayList<>();
286284

@@ -292,14 +290,12 @@ public class OllamaOptions implements FunctionCallingOptions, ChatOptions, Embed
292290
* Note that function enabled with the default options are enabled for all chat completion requests. This could impact the token count and the billing.
293291
* If the functions is set in a prompt options, then the enabled functions are only active for the duration of this prompt execution.
294292
*/
295-
@NestedConfigurationProperty
296293
@JsonIgnore
297294
private Set<String> functions = new HashSet<>();
298295

299296
@JsonIgnore
300297
private Boolean proxyToolCalls;
301298

302-
@NestedConfigurationProperty
303299
@JsonIgnore
304300
private Map<String, Object> toolContext;
305301

models/spring-ai-openai/pom.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,6 @@
5151
<version>${project.parent.version}</version>
5252
</dependency>
5353

54-
<!-- NOTE: Required only by the @ConstructorBinding. -->
55-
<dependency>
56-
<groupId>org.springframework.boot</groupId>
57-
<artifactId>spring-boot</artifactId>
58-
</dependency>
59-
6054
<dependency>
6155
<groupId>io.rest-assured</groupId>
6256
<artifactId>json-path</artifactId>

0 commit comments

Comments
 (0)