@@ -101,6 +101,28 @@ 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
114
+ * penalizes the repetition of words or phrases. A higher presence penalty encourages
115
+ * the model to use a wider variety of words and phrases, making the output more
116
+ * diverse and creative.
117
+ */
118
+ private @ JsonProperty ("presence_penalty" ) Double presencePenalty ;
119
+
120
+ /**
121
+ * Number of completions to return for each request, input tokens are only billed
122
+ * once.
123
+ */
124
+ private @ JsonProperty ("n" ) Integer n ;
125
+
104
126
/**
105
127
* A list of tools the model may call. Currently, only functions are supported as a
106
128
* tool. Use this to provide a list of functions the model may generate JSON inputs
@@ -151,6 +173,9 @@ public static MistralAiChatOptions fromOptions(MistralAiChatOptions fromOptions)
151
173
.topP (fromOptions .getTopP ())
152
174
.responseFormat (fromOptions .getResponseFormat ())
153
175
.stop (fromOptions .getStop ())
176
+ .frequencyPenalty (fromOptions .getFrequencyPenalty ())
177
+ .presencePenalty (fromOptions .getPresencePenalty ())
178
+ .N (fromOptions .getN ())
154
179
.tools (fromOptions .getTools ())
155
180
.toolChoice (fromOptions .getToolChoice ())
156
181
.toolCallbacks (fromOptions .getToolCallbacks ())
@@ -255,6 +280,32 @@ public void setTopP(Double topP) {
255
280
this .topP = topP ;
256
281
}
257
282
283
+ @ Override
284
+ public Double getFrequencyPenalty () {
285
+ return this .frequencyPenalty ;
286
+ }
287
+
288
+ public void setFrequencyPenalty (Double frequencyPenalty ) {
289
+ this .frequencyPenalty = frequencyPenalty ;
290
+ }
291
+
292
+ @ Override
293
+ public Double getPresencePenalty () {
294
+ return this .presencePenalty ;
295
+ }
296
+
297
+ public void setPresencePenalty (Double presencePenalty ) {
298
+ this .presencePenalty = presencePenalty ;
299
+ }
300
+
301
+ public Integer getN () {
302
+ return this .n ;
303
+ }
304
+
305
+ public void setN (Integer n ) {
306
+ this .n = n ;
307
+ }
308
+
258
309
@ Override
259
310
@ JsonIgnore
260
311
public List <FunctionCallback > getToolCallbacks () {
@@ -325,18 +376,6 @@ public void setFunctions(Set<String> functionNames) {
325
376
this .setToolNames (functionNames );
326
377
}
327
378
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
379
@ Override
341
380
@ JsonIgnore
342
381
public Integer getTopK () {
@@ -376,8 +415,8 @@ public MistralAiChatOptions copy() {
376
415
@ Override
377
416
public int hashCode () {
378
417
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 );
418
+ this .responseFormat , this .stop , this .frequencyPenalty , this .presencePenalty , this .n , this .tools ,
419
+ this .toolChoice , this . toolCallbacks , this . tools , this . internalToolExecutionEnabled , this .toolContext );
381
420
}
382
421
383
422
@ Override
@@ -397,6 +436,8 @@ public boolean equals(Object obj) {
397
436
&& Objects .equals (this .safePrompt , other .safePrompt )
398
437
&& Objects .equals (this .randomSeed , other .randomSeed )
399
438
&& Objects .equals (this .responseFormat , other .responseFormat ) && Objects .equals (this .stop , other .stop )
439
+ && Objects .equals (this .frequencyPenalty , other .frequencyPenalty )
440
+ && Objects .equals (this .presencePenalty , other .presencePenalty ) && Objects .equals (this .n , other .n )
400
441
&& Objects .equals (this .tools , other .tools ) && Objects .equals (this .toolChoice , other .toolChoice )
401
442
&& Objects .equals (this .toolCallbacks , other .toolCallbacks )
402
443
&& Objects .equals (this .toolNames , other .toolNames )
@@ -438,6 +479,21 @@ public Builder stop(List<String> stop) {
438
479
return this ;
439
480
}
440
481
482
+ public Builder frequencyPenalty (Double frequencyPenalty ) {
483
+ this .options .frequencyPenalty = frequencyPenalty ;
484
+ return this ;
485
+ }
486
+
487
+ public Builder presencePenalty (Double presencePenalty ) {
488
+ this .options .presencePenalty = presencePenalty ;
489
+ return this ;
490
+ }
491
+
492
+ public Builder N (Integer n ) {
493
+ this .options .n = n ;
494
+ return this ;
495
+ }
496
+
441
497
public Builder temperature (Double temperature ) {
442
498
this .options .setTemperature (temperature );
443
499
return this ;
0 commit comments