@@ -101,6 +101,26 @@ public class MistralAiChatOptions implements ToolCallingChatOptions {
101
101
*/
102
102
private @ JsonProperty ("stop" ) List <String > stop ;
103
103
104
+ /**
105
+ * Number between -2.0 and 2.0. frequency_penalty penalizes the repetition of words
106
+ * based on their frequency in the generated text. A higher frequency penalty discourages
107
+ * the model from repeating words that have already appeared frequently in the
108
+ * output, promoting diversity and reducing repetition.
109
+ */
110
+ private @ JsonProperty ("frequency_penalty" ) Double frequencyPenalty ;
111
+
112
+ /**
113
+ * Number between -2.0 and 2.0. presence_penalty determines how much the model penalizes
114
+ * the repetition of words or phrases. A higher presence penalty encourages the model to
115
+ * use a wider variety of words and phrases, making the output more 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 once.
121
+ */
122
+ private @ JsonProperty ("n" ) Integer n ;
123
+
104
124
/**
105
125
* A list of tools the model may call. Currently, only functions are supported as a
106
126
* tool. Use this to provide a list of functions the model may generate JSON inputs
@@ -151,6 +171,9 @@ public static MistralAiChatOptions fromOptions(MistralAiChatOptions fromOptions)
151
171
.topP (fromOptions .getTopP ())
152
172
.responseFormat (fromOptions .getResponseFormat ())
153
173
.stop (fromOptions .getStop ())
174
+ .frequencyPenalty (fromOptions .getFrequencyPenalty ())
175
+ .presencePenalty (fromOptions .getPresencePenalty ())
176
+ .N (fromOptions .getN ())
154
177
.tools (fromOptions .getTools ())
155
178
.toolChoice (fromOptions .getToolChoice ())
156
179
.toolCallbacks (fromOptions .getToolCallbacks ())
@@ -255,6 +278,32 @@ public void setTopP(Double topP) {
255
278
this .topP = topP ;
256
279
}
257
280
281
+ @ Override
282
+ public Double getFrequencyPenalty () {
283
+ return this .frequencyPenalty ;
284
+ }
285
+
286
+ public void setFrequencyPenalty (Double frequencyPenalty ) {
287
+ this .frequencyPenalty = frequencyPenalty ;
288
+ }
289
+
290
+ @ Override
291
+ public Double getPresencePenalty () {
292
+ return this .presencePenalty ;
293
+ }
294
+
295
+ public void setPresencePenalty (Double presencePenalty ) {
296
+ this .presencePenalty = presencePenalty ;
297
+ }
298
+
299
+ public Integer getN () {
300
+ return this .n ;
301
+ }
302
+
303
+ public void setN (Integer n ) {
304
+ this .n = n ;
305
+ }
306
+
258
307
@ Override
259
308
@ JsonIgnore
260
309
public List <FunctionCallback > getToolCallbacks () {
@@ -325,18 +374,6 @@ public void setFunctions(Set<String> functionNames) {
325
374
this .setToolNames (functionNames );
326
375
}
327
376
328
- @ Override
329
- @ JsonIgnore
330
- public Double getFrequencyPenalty () {
331
- return null ;
332
- }
333
-
334
- @ Override
335
- @ JsonIgnore
336
- public Double getPresencePenalty () {
337
- return null ;
338
- }
339
-
340
377
@ Override
341
378
@ JsonIgnore
342
379
public Integer getTopK () {
@@ -376,8 +413,8 @@ public MistralAiChatOptions copy() {
376
413
@ Override
377
414
public int hashCode () {
378
415
return Objects .hash (this .model , this .temperature , this .topP , this .maxTokens , this .safePrompt , this .randomSeed ,
379
- this .responseFormat , this .stop , this .tools , this .toolChoice , this .toolCallbacks , this .tools ,
380
- this .internalToolExecutionEnabled , this .toolContext );
416
+ this .responseFormat , this .stop , this .frequencyPenalty , this .presencePenalty , this .n , this .tools ,
417
+ this .toolChoice , this . toolCallbacks , this . tools , this . internalToolExecutionEnabled , this .toolContext );
381
418
}
382
419
383
420
@ Override
@@ -397,6 +434,9 @@ public boolean equals(Object obj) {
397
434
&& Objects .equals (this .safePrompt , other .safePrompt )
398
435
&& Objects .equals (this .randomSeed , other .randomSeed )
399
436
&& Objects .equals (this .responseFormat , other .responseFormat ) && Objects .equals (this .stop , other .stop )
437
+ && Objects .equals (this .frequencyPenalty , other .frequencyPenalty )
438
+ && Objects .equals (this .presencePenalty , other .presencePenalty )
439
+ && Objects .equals (this .n , other .n )
400
440
&& Objects .equals (this .tools , other .tools ) && Objects .equals (this .toolChoice , other .toolChoice )
401
441
&& Objects .equals (this .toolCallbacks , other .toolCallbacks )
402
442
&& Objects .equals (this .toolNames , other .toolNames )
@@ -438,6 +478,21 @@ public Builder stop(List<String> stop) {
438
478
return this ;
439
479
}
440
480
481
+ public Builder frequencyPenalty (Double frequencyPenalty ) {
482
+ this .options .frequencyPenalty = frequencyPenalty ;
483
+ return this ;
484
+ }
485
+
486
+ public Builder presencePenalty (Double presencePenalty ) {
487
+ this .options .presencePenalty = presencePenalty ;
488
+ return this ;
489
+ }
490
+
491
+ public Builder N (Integer n ) {
492
+ this .options .n = n ;
493
+ return this ;
494
+ }
495
+
441
496
public Builder temperature (Double temperature ) {
442
497
this .options .setTemperature (temperature );
443
498
return this ;
0 commit comments