@@ -100,6 +100,28 @@ public class MistralAiChatOptions implements ToolCallingChatOptions {
100
100
*/
101
101
private @ JsonProperty ("stop" ) List <String > stop ;
102
102
103
+ /**
104
+ * Number between -2.0 and 2.0. frequency_penalty penalizes the repetition of words
105
+ * based on their frequency in the generated text. A higher frequency penalty
106
+ * discourages the model from repeating words that have already appeared frequently in
107
+ * the output, promoting diversity and reducing repetition.
108
+ */
109
+ private @ JsonProperty ("frequency_penalty" ) Double frequencyPenalty ;
110
+
111
+ /**
112
+ * Number between -2.0 and 2.0. presence_penalty determines how much the model
113
+ * penalizes the repetition of words or phrases. A higher presence penalty encourages
114
+ * the model to use a wider variety of words and phrases, making the output more
115
+ * diverse and creative.
116
+ */
117
+ private @ JsonProperty ("presence_penalty" ) Double presencePenalty ;
118
+
119
+ /**
120
+ * Number of completions to return for each request, input tokens are only billed
121
+ * once.
122
+ */
123
+ private @ JsonProperty ("n" ) Integer n ;
124
+
103
125
/**
104
126
* A list of tools the model may call. Currently, only functions are supported as a
105
127
* tool. Use this to provide a list of functions the model may generate JSON inputs
@@ -150,6 +172,9 @@ public static MistralAiChatOptions fromOptions(MistralAiChatOptions fromOptions)
150
172
.topP (fromOptions .getTopP ())
151
173
.responseFormat (fromOptions .getResponseFormat ())
152
174
.stop (fromOptions .getStop ())
175
+ .frequencyPenalty (fromOptions .getFrequencyPenalty ())
176
+ .presencePenalty (fromOptions .getPresencePenalty ())
177
+ .n (fromOptions .getN ())
153
178
.tools (fromOptions .getTools ())
154
179
.toolChoice (fromOptions .getToolChoice ())
155
180
.toolCallbacks (fromOptions .getToolCallbacks ())
@@ -254,6 +279,32 @@ public void setTopP(Double topP) {
254
279
this .topP = topP ;
255
280
}
256
281
282
+ @ Override
283
+ public Double getFrequencyPenalty () {
284
+ return this .frequencyPenalty ;
285
+ }
286
+
287
+ public void setFrequencyPenalty (Double frequencyPenalty ) {
288
+ this .frequencyPenalty = frequencyPenalty ;
289
+ }
290
+
291
+ @ Override
292
+ public Double getPresencePenalty () {
293
+ return this .presencePenalty ;
294
+ }
295
+
296
+ public void setPresencePenalty (Double presencePenalty ) {
297
+ this .presencePenalty = presencePenalty ;
298
+ }
299
+
300
+ public Integer getN () {
301
+ return this .n ;
302
+ }
303
+
304
+ public void setN (Integer n ) {
305
+ this .n = n ;
306
+ }
307
+
257
308
@ Override
258
309
@ JsonIgnore
259
310
public List <ToolCallback > getToolCallbacks () {
@@ -296,18 +347,6 @@ public void setInternalToolExecutionEnabled(@Nullable Boolean internalToolExecut
296
347
this .internalToolExecutionEnabled = internalToolExecutionEnabled ;
297
348
}
298
349
299
- @ Override
300
- @ JsonIgnore
301
- public Double getFrequencyPenalty () {
302
- return null ;
303
- }
304
-
305
- @ Override
306
- @ JsonIgnore
307
- public Double getPresencePenalty () {
308
- return null ;
309
- }
310
-
311
350
@ Override
312
351
@ JsonIgnore
313
352
public Integer getTopK () {
@@ -334,8 +373,8 @@ public MistralAiChatOptions copy() {
334
373
@ Override
335
374
public int hashCode () {
336
375
return Objects .hash (this .model , this .temperature , this .topP , this .maxTokens , this .safePrompt , this .randomSeed ,
337
- this .responseFormat , this .stop , this .tools , this .toolChoice , this .toolCallbacks , this .tools ,
338
- this .internalToolExecutionEnabled , this .toolContext );
376
+ this .responseFormat , this .stop , this .frequencyPenalty , this .presencePenalty , this .n , this .tools ,
377
+ this .toolChoice , this . toolCallbacks , this . tools , this . internalToolExecutionEnabled , this .toolContext );
339
378
}
340
379
341
380
@ Override
@@ -355,6 +394,8 @@ public boolean equals(Object obj) {
355
394
&& Objects .equals (this .safePrompt , other .safePrompt )
356
395
&& Objects .equals (this .randomSeed , other .randomSeed )
357
396
&& Objects .equals (this .responseFormat , other .responseFormat ) && Objects .equals (this .stop , other .stop )
397
+ && Objects .equals (this .frequencyPenalty , other .frequencyPenalty )
398
+ && Objects .equals (this .presencePenalty , other .presencePenalty ) && Objects .equals (this .n , other .n )
358
399
&& Objects .equals (this .tools , other .tools ) && Objects .equals (this .toolChoice , other .toolChoice )
359
400
&& Objects .equals (this .toolCallbacks , other .toolCallbacks )
360
401
&& Objects .equals (this .toolNames , other .toolNames )
@@ -396,6 +437,21 @@ public Builder stop(List<String> stop) {
396
437
return this ;
397
438
}
398
439
440
+ public Builder frequencyPenalty (Double frequencyPenalty ) {
441
+ this .options .frequencyPenalty = frequencyPenalty ;
442
+ return this ;
443
+ }
444
+
445
+ public Builder presencePenalty (Double presencePenalty ) {
446
+ this .options .presencePenalty = presencePenalty ;
447
+ return this ;
448
+ }
449
+
450
+ public Builder n (Integer n ) {
451
+ this .options .n = n ;
452
+ return this ;
453
+ }
454
+
399
455
public Builder temperature (Double temperature ) {
400
456
this .options .setTemperature (temperature );
401
457
return this ;
0 commit comments