Skip to content

Commit e29d38d

Browse files
sobychackomarkpollack
authored andcommitted
Remove unnecessary null checks in AzureOpenAiChatOptions.Builder
This is related to #889 This commit addresses a bug where certain fields were being made indirectly mandatory due to Assert.notNull checks in the Builder's with* methods. Specifically: - Removed Assert.notNull checks from withResponseFormat, withSeed, withLogprobs, withTopLogprobs, and withEnhancements methods. These checks were causing exceptions in AzureOpenAiChatModel.getDefaultOptions when not all fields were set, leading to failures in methods like ChatClient.create, even when using the AzureOpenAiChatModel constructor with OpenAIClient. The removal of these checks aligns with the @JsonInclude(Include.NON_NULL) annotation on AzureOpenAiChatOptions, which already ignores null options. This change maintains the intended flexibility while preventing unintended mandatory requirements.
1 parent ccf190c commit e29d38d

File tree

1 file changed

+0
-5
lines changed

1 file changed

+0
-5
lines changed

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,6 @@ public Builder withFunction(String functionName) {
283283
}
284284

285285
public Builder withResponseFormat(AzureOpenAiResponseFormat responseFormat) {
286-
Assert.notNull(responseFormat, "responseFormat must not be null");
287286
this.options.responseFormat = responseFormat;
288287
return this;
289288
}
@@ -294,25 +293,21 @@ public Builder withProxyToolCalls(Boolean proxyToolCalls) {
294293
}
295294

296295
public Builder withSeed(Long seed) {
297-
Assert.notNull(seed, "seed must not be null");
298296
this.options.seed = seed;
299297
return this;
300298
}
301299

302300
public Builder withLogprobs(Boolean logprobs) {
303-
Assert.notNull(logprobs, "logprobs must not be null");
304301
this.options.logprobs = logprobs;
305302
return this;
306303
}
307304

308305
public Builder withTopLogprobs(Integer topLogprobs) {
309-
Assert.notNull(topLogprobs, "topLogprobs must not be null");
310306
this.options.topLogProbs = topLogprobs;
311307
return this;
312308
}
313309

314310
public Builder withEnhancements(AzureChatEnhancementConfiguration enhancements) {
315-
Assert.notNull(enhancements, "enhancements must not be null");
316311
this.options.enhancements = enhancements;
317312
return this;
318313
}

0 commit comments

Comments
 (0)