Skip to content

Commit da45244

Browse files
ilayaperumalgmarkpollack
authored andcommitted
Refactor Azure model options builder methods
- Deprecate builder methods with the prefix `with` and add them without the prefix - Update references and docs
1 parent 93a7ba4 commit da45244

28 files changed

+505
-139
lines changed

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

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
* Options for audio transcription using Azure Open AI.
3232
*
3333
* @author Piotr Olaszewski
34+
* @author Ilayaperumal Gopinathan
3435
*/
3536
@JsonInclude(Include.NON_NULL)
3637
public class AzureOpenAiAudioTranscriptionOptions implements AudioTranscriptionOptions {
@@ -266,36 +267,99 @@ public Builder(AzureOpenAiAudioTranscriptionOptions options) {
266267
this.options = options;
267268
}
268269

270+
public Builder model(String model) {
271+
this.options.model = model;
272+
return this;
273+
}
274+
275+
public Builder deploymentName(String deploymentName) {
276+
this.options.setDeploymentName(deploymentName);
277+
return this;
278+
}
279+
280+
public Builder language(String language) {
281+
this.options.language = language;
282+
return this;
283+
}
284+
285+
public Builder prompt(String prompt) {
286+
this.options.prompt = prompt;
287+
return this;
288+
}
289+
290+
public Builder responseFormat(TranscriptResponseFormat responseFormat) {
291+
this.options.responseFormat = responseFormat;
292+
return this;
293+
}
294+
295+
public Builder temperature(Float temperature) {
296+
this.options.temperature = temperature;
297+
return this;
298+
}
299+
300+
public Builder granularityType(List<GranularityType> granularityType) {
301+
this.options.granularityType = granularityType;
302+
return this;
303+
}
304+
305+
/**
306+
* @deprecated use {@link #model(String)} instead.
307+
*/
308+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
269309
public Builder withModel(String model) {
270310
this.options.model = model;
271311
return this;
272312
}
273313

314+
/**
315+
* @deprecated use {@link #deploymentName(String)} instead.
316+
*/
317+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
274318
public Builder withDeploymentName(String deploymentName) {
275319
this.options.setDeploymentName(deploymentName);
276320
return this;
277321
}
278322

323+
/**
324+
* @deprecated use {@link #language(String)} instead.
325+
*/
326+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
279327
public Builder withLanguage(String language) {
280328
this.options.language = language;
281329
return this;
282330
}
283331

332+
/**
333+
* @deprecated use {@link #prompt(String)} instead.
334+
*/
335+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
284336
public Builder withPrompt(String prompt) {
285337
this.options.prompt = prompt;
286338
return this;
287339
}
288340

341+
/**
342+
* @deprecated use {@link #responseFormat(TranscriptResponseFormat)} instead.
343+
*/
344+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
289345
public Builder withResponseFormat(TranscriptResponseFormat responseFormat) {
290346
this.options.responseFormat = responseFormat;
291347
return this;
292348
}
293349

350+
/**
351+
* @deprecated use {@link #temperature(Float)} instead.
352+
*/
353+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
294354
public Builder withTemperature(Float temperature) {
295355
this.options.temperature = temperature;
296356
return this;
297357
}
298358

359+
/**
360+
* @deprecated use {@link #granularityType(List)} instead.
361+
*/
362+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
299363
public Builder withGranularityType(List<GranularityType> granularityType) {
300364
this.options.granularityType = granularityType;
301365
return this;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ public class AzureOpenAiChatModel extends AbstractToolCallSupport implements Cha
148148
public AzureOpenAiChatModel(OpenAIClientBuilder openAIClientBuilder) {
149149
this(openAIClientBuilder,
150150
AzureOpenAiChatOptions.builder()
151-
.withDeploymentName(DEFAULT_DEPLOYMENT_NAME)
152-
.withTemperature(DEFAULT_TEMPERATURE)
151+
.deploymentName(DEFAULT_DEPLOYMENT_NAME)
152+
.temperature(DEFAULT_TEMPERATURE)
153153
.build());
154154
}
155155

0 commit comments

Comments
 (0)