1
1
/*
2
- * Copyright 2023-2024 the original author or authors.
2
+ * Copyright 2023-2025 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
32
32
import com .fasterxml .jackson .annotation .JsonInclude .Include ;
33
33
import com .fasterxml .jackson .annotation .JsonProperty ;
34
34
35
- import org .springframework .ai .chat .prompt .AbstractChatOptions ;
36
35
import org .springframework .ai .model .function .FunctionCallback ;
37
36
import org .springframework .ai .model .tool .ToolCallingChatOptions ;
38
37
import org .springframework .ai .tool .ToolCallback ;
51
50
* @author Alexandros Pappas
52
51
*/
53
52
@ JsonInclude (Include .NON_NULL )
54
- public class AzureOpenAiChatOptions extends AbstractChatOptions implements ToolCallingChatOptions {
53
+ public class AzureOpenAiChatOptions implements ToolCallingChatOptions {
54
+
55
+ /**
56
+ * The maximum number of tokens to generate.
57
+ */
58
+ @ JsonProperty ("max_tokens" )
59
+ private Integer maxTokens ;
60
+
61
+ /**
62
+ * The sampling temperature to use that controls the apparent creativity of generated
63
+ * completions. Higher values will make output more random while lower values will
64
+ * make results more focused and deterministic. It is not recommended to modify
65
+ * temperature and top_p for the same completions request as the interaction of these
66
+ * two settings is difficult to predict.
67
+ */
68
+ @ JsonProperty ("temperature" )
69
+ private Double temperature ;
70
+
71
+ /**
72
+ * An alternative to sampling with temperature called nucleus sampling. This value
73
+ * causes the model to consider the results of tokens with the provided probability
74
+ * mass. As an example, a value of 0.15 will cause only the tokens comprising the top
75
+ * 15% of probability mass to be considered. It is not recommended to modify
76
+ * temperature and top_p for the same completions request as the interaction of these
77
+ * two settings is difficult to predict.
78
+ */
79
+ @ JsonProperty ("top_p" )
80
+ private Double topP ;
55
81
56
82
/**
57
83
* A map between GPT token IDs and bias scores that influences the probability of
@@ -85,6 +111,24 @@ public class AzureOpenAiChatOptions extends AbstractChatOptions implements ToolC
85
111
@ JsonProperty ("stop" )
86
112
private List <String > stop ;
87
113
114
+ /**
115
+ * A value that influences the probability of generated tokens appearing based on
116
+ * their existing presence in generated text. Positive values will make tokens less
117
+ * likely to appear when they already exist and increase the model's likelihood to
118
+ * output new topics.
119
+ */
120
+ @ JsonProperty ("presence_penalty" )
121
+ private Double presencePenalty ;
122
+
123
+ /**
124
+ * A value that influences the probability of generated tokens appearing based on
125
+ * their cumulative frequency in generated text. Positive values will make tokens less
126
+ * likely to appear as their frequency increases and decrease the likelihood of the
127
+ * model repeating the same statements verbatim.
128
+ */
129
+ @ JsonProperty ("frequency_penalty" )
130
+ private Double frequencyPenalty ;
131
+
88
132
/**
89
133
* The deployment name as defined in Azure Open AI Studio when creating a deployment
90
134
* backed by an Azure OpenAI base model.
@@ -279,10 +323,20 @@ public void setStop(List<String> stop) {
279
323
this .stop = stop ;
280
324
}
281
325
326
+ @ Override
327
+ public Double getPresencePenalty () {
328
+ return this .presencePenalty ;
329
+ }
330
+
282
331
public void setPresencePenalty (Double presencePenalty ) {
283
332
this .presencePenalty = presencePenalty ;
284
333
}
285
334
335
+ @ Override
336
+ public Double getFrequencyPenalty () {
337
+ return this .frequencyPenalty ;
338
+ }
339
+
286
340
public void setFrequencyPenalty (Double frequencyPenalty ) {
287
341
this .frequencyPenalty = frequencyPenalty ;
288
342
}
@@ -306,6 +360,11 @@ public void setDeploymentName(String deploymentName) {
306
360
this .deploymentName = deploymentName ;
307
361
}
308
362
363
+ @ Override
364
+ public Double getTemperature () {
365
+ return this .temperature ;
366
+ }
367
+
309
368
public void setTemperature (Double temperature ) {
310
369
this .temperature = temperature ;
311
370
}
@@ -422,7 +481,7 @@ public void setStreamOptions(ChatCompletionStreamOptions streamOptions) {
422
481
}
423
482
424
483
@ Override
425
- @ SuppressWarnings ("" )
484
+ @ SuppressWarnings ("unchecked " )
426
485
public AzureOpenAiChatOptions copy () {
427
486
return fromOptions (this );
428
487
}
@@ -454,30 +513,10 @@ public boolean equals(Object o) {
454
513
455
514
@ Override
456
515
public int hashCode () {
457
- final int prime = 31 ;
458
- int result = 1 ;
459
- result = prime * result + (this .logitBias != null ? this .logitBias .hashCode () : 0 );
460
- result = prime * result + (this .user != null ? this .user .hashCode () : 0 );
461
- result = prime * result + (this .n != null ? this .n .hashCode () : 0 );
462
- result = prime * result + (this .stop != null ? this .stop .hashCode () : 0 );
463
- result = prime * result + (this .deploymentName != null ? this .deploymentName .hashCode () : 0 );
464
- result = prime * result + (this .responseFormat != null ? this .responseFormat .hashCode () : 0 );
465
- result = prime * result + (this .toolCallbacks != null ? this .toolCallbacks .hashCode () : 0 );
466
- result = prime * result + (this .toolNames != null ? this .toolNames .hashCode () : 0 );
467
- result = prime * result
468
- + (this .internalToolExecutionEnabled != null ? this .internalToolExecutionEnabled .hashCode () : 0 );
469
- result = prime * result + (this .seed != null ? this .seed .hashCode () : 0 );
470
- result = prime * result + (this .logprobs != null ? this .logprobs .hashCode () : 0 );
471
- result = prime * result + (this .topLogProbs != null ? this .topLogProbs .hashCode () : 0 );
472
- result = prime * result + (this .enhancements != null ? this .enhancements .hashCode () : 0 );
473
- result = prime * result + (this .streamOptions != null ? this .streamOptions .hashCode () : 0 );
474
- result = prime * result + (this .toolContext != null ? this .toolContext .hashCode () : 0 );
475
- result = prime * result + (this .maxTokens != null ? this .maxTokens .hashCode () : 0 );
476
- result = prime * result + (this .frequencyPenalty != null ? this .frequencyPenalty .hashCode () : 0 );
477
- result = prime * result + (this .presencePenalty != null ? this .presencePenalty .hashCode () : 0 );
478
- result = prime * result + (this .temperature != null ? this .temperature .hashCode () : 0 );
479
- result = prime * result + (this .topP != null ? this .topP .hashCode () : 0 );
480
- return result ;
516
+ return Objects .hash (this .logitBias , this .user , this .n , this .stop , this .deploymentName , this .responseFormat ,
517
+ this .toolCallbacks , this .toolNames , this .internalToolExecutionEnabled , this .seed , this .logprobs ,
518
+ this .topLogProbs , this .enhancements , this .streamOptions , this .toolContext , this .maxTokens ,
519
+ this .frequencyPenalty , this .presencePenalty , this .temperature , this .topP );
481
520
}
482
521
483
522
public static class Builder {
0 commit comments