18
18
19
19
import java .util .ArrayList ;
20
20
import java .util .Arrays ;
21
+ import java .util .Collections ;
21
22
import java .util .HashMap ;
22
23
import java .util .HashSet ;
23
24
import java .util .List ;
24
25
import java .util .Map ;
26
+ import java .util .Objects ;
25
27
import java .util .Set ;
26
28
27
29
import com .fasterxml .jackson .annotation .JsonIgnore ;
45
47
* @author Geng Rong
46
48
* @author Thomas Vitale
47
49
* @author Ilayaperumal Gopinathan
50
+ * @author Alexandros Pappas
48
51
* @since 1.0.0 M1
49
52
*/
50
53
@ JsonInclude (Include .NON_NULL )
@@ -167,11 +170,11 @@ public static MiniMaxChatOptions fromOptions(MiniMaxChatOptions fromOptions) {
167
170
.presencePenalty (fromOptions .getPresencePenalty ())
168
171
.responseFormat (fromOptions .getResponseFormat ())
169
172
.seed (fromOptions .getSeed ())
170
- .stop (fromOptions .getStop ())
173
+ .stop (fromOptions .getStop () != null ? new ArrayList <>( fromOptions . getStop ()) : null )
171
174
.temperature (fromOptions .getTemperature ())
172
175
.topP (fromOptions .getTopP ())
173
176
.maskSensitiveInfo (fromOptions .getMaskSensitiveInfo ())
174
- .tools (fromOptions .getTools ())
177
+ .tools (fromOptions .getTools () != null ? new ArrayList <>( fromOptions . getTools ()) : null )
175
178
.toolChoice (fromOptions .getToolChoice ())
176
179
.toolCallbacks (fromOptions .getToolCallbacks ())
177
180
.toolNames (fromOptions .getToolNames ())
@@ -252,7 +255,7 @@ public void setStopSequences(List<String> stopSequences) {
252
255
}
253
256
254
257
public List <String > getStop () {
255
- return this .stop ;
258
+ return ( this .stop != null ) ? Collections . unmodifiableList ( this . stop ) : null ;
256
259
}
257
260
258
261
public void setStop (List <String > stop ) {
@@ -286,7 +289,7 @@ public void setMaskSensitiveInfo(Boolean maskSensitiveInfo) {
286
289
}
287
290
288
291
public List <MiniMaxApi .FunctionTool > getTools () {
289
- return this .tools ;
292
+ return ( this .tools != null ) ? Collections . unmodifiableList ( this . tools ) : null ;
290
293
}
291
294
292
295
public void setTools (List <MiniMaxApi .FunctionTool > tools ) {
@@ -310,7 +313,7 @@ public Integer getTopK() {
310
313
@ Override
311
314
@ JsonIgnore
312
315
public List <ToolCallback > getToolCallbacks () {
313
- return this .toolCallbacks ;
316
+ return Collections . unmodifiableList ( this .toolCallbacks ) ;
314
317
}
315
318
316
319
@ Override
@@ -324,7 +327,7 @@ public void setToolCallbacks(List<ToolCallback> toolCallbacks) {
324
327
@ Override
325
328
@ JsonIgnore
326
329
public Set <String > getToolNames () {
327
- return this .toolNames ;
330
+ return Collections . unmodifiableSet ( this .toolNames ) ;
328
331
}
329
332
330
333
@ Override
@@ -351,7 +354,7 @@ public void setInternalToolExecutionEnabled(@Nullable Boolean internalToolExecut
351
354
352
355
@ Override
353
356
public Map <String , Object > getToolContext () {
354
- return this .toolContext ;
357
+ return ( this .toolContext != null ) ? Collections . unmodifiableMap ( this . toolContext ) : null ;
355
358
}
356
359
357
360
@ Override
@@ -361,182 +364,28 @@ public void setToolContext(Map<String, Object> toolContext) {
361
364
362
365
@ Override
363
366
public int hashCode () {
364
- final int prime = 31 ;
365
- int result = 1 ;
366
- result = prime * result + ((this .model == null ) ? 0 : this .model .hashCode ());
367
- result = prime * result + ((this .frequencyPenalty == null ) ? 0 : this .frequencyPenalty .hashCode ());
368
- result = prime * result + ((this .maxTokens == null ) ? 0 : this .maxTokens .hashCode ());
369
- result = prime * result + ((this .n == null ) ? 0 : this .n .hashCode ());
370
- result = prime * result + ((this .presencePenalty == null ) ? 0 : this .presencePenalty .hashCode ());
371
- result = prime * result + ((this .responseFormat == null ) ? 0 : this .responseFormat .hashCode ());
372
- result = prime * result + ((this .seed == null ) ? 0 : this .seed .hashCode ());
373
- result = prime * result + ((this .stop == null ) ? 0 : this .stop .hashCode ());
374
- result = prime * result + ((this .temperature == null ) ? 0 : this .temperature .hashCode ());
375
- result = prime * result + ((this .topP == null ) ? 0 : this .topP .hashCode ());
376
- result = prime * result + ((this .maskSensitiveInfo == null ) ? 0 : this .maskSensitiveInfo .hashCode ());
377
- result = prime * result + ((this .tools == null ) ? 0 : this .tools .hashCode ());
378
- result = prime * result + ((this .toolChoice == null ) ? 0 : this .toolChoice .hashCode ());
379
- result = prime * result + ((this .toolCallbacks == null ) ? 0 : this .toolCallbacks .hashCode ());
380
- result = prime * result + ((this .toolNames == null ) ? 0 : this .toolNames .hashCode ());
381
- result = prime * result
382
- + ((this .internalToolExecutionEnabled == null ) ? 0 : this .internalToolExecutionEnabled .hashCode ());
383
- result = prime * result + ((this .toolContext == null ) ? 0 : this .toolContext .hashCode ());
384
- return result ;
367
+ return Objects .hash (model , frequencyPenalty , maxTokens , n , presencePenalty , responseFormat , seed , stop ,
368
+ temperature , topP , maskSensitiveInfo , tools , toolChoice , toolCallbacks , toolNames , toolContext ,
369
+ internalToolExecutionEnabled );
385
370
}
386
371
387
372
@ Override
388
- public boolean equals (Object obj ) {
389
- if (this == obj ) {
373
+ public boolean equals (Object o ) {
374
+ if (this == o )
390
375
return true ;
391
- }
392
- if (obj == null ) {
393
- return false ;
394
- }
395
- if (getClass () != obj .getClass ()) {
396
- return false ;
397
- }
398
- MiniMaxChatOptions other = (MiniMaxChatOptions ) obj ;
399
- if (this .model == null ) {
400
- if (other .model != null ) {
401
- return false ;
402
- }
403
- }
404
- else if (!this .model .equals (other .model )) {
405
- return false ;
406
- }
407
- if (this .frequencyPenalty == null ) {
408
- if (other .frequencyPenalty != null ) {
409
- return false ;
410
- }
411
- }
412
- else if (!this .frequencyPenalty .equals (other .frequencyPenalty )) {
413
- return false ;
414
- }
415
- if (this .maxTokens == null ) {
416
- if (other .maxTokens != null ) {
417
- return false ;
418
- }
419
- }
420
- else if (!this .maxTokens .equals (other .maxTokens )) {
421
- return false ;
422
- }
423
- if (this .n == null ) {
424
- if (other .n != null ) {
425
- return false ;
426
- }
427
- }
428
- else if (!this .n .equals (other .n )) {
429
- return false ;
430
- }
431
- if (this .presencePenalty == null ) {
432
- if (other .presencePenalty != null ) {
433
- return false ;
434
- }
435
- }
436
- else if (!this .presencePenalty .equals (other .presencePenalty )) {
437
- return false ;
438
- }
439
- if (this .responseFormat == null ) {
440
- if (other .responseFormat != null ) {
441
- return false ;
442
- }
443
- }
444
- else if (!this .responseFormat .equals (other .responseFormat )) {
445
- return false ;
446
- }
447
- if (this .seed == null ) {
448
- if (other .seed != null ) {
449
- return false ;
450
- }
451
- }
452
- else if (!this .seed .equals (other .seed )) {
453
- return false ;
454
- }
455
- if (this .stop == null ) {
456
- if (other .stop != null ) {
457
- return false ;
458
- }
459
- }
460
- else if (!this .stop .equals (other .stop )) {
461
- return false ;
462
- }
463
- if (this .temperature == null ) {
464
- if (other .temperature != null ) {
465
- return false ;
466
- }
467
- }
468
- else if (!this .temperature .equals (other .temperature )) {
469
- return false ;
470
- }
471
- if (this .topP == null ) {
472
- if (other .topP != null ) {
473
- return false ;
474
- }
475
- }
476
- else if (!this .topP .equals (other .topP )) {
477
- return false ;
478
- }
479
- if (this .maskSensitiveInfo == null ) {
480
- if (other .maskSensitiveInfo != null ) {
481
- return false ;
482
- }
483
- }
484
- else if (!this .maskSensitiveInfo .equals (other .maskSensitiveInfo )) {
485
- return false ;
486
- }
487
- if (this .tools == null ) {
488
- if (other .tools != null ) {
489
- return false ;
490
- }
491
- }
492
- else if (!this .tools .equals (other .tools )) {
493
- return false ;
494
- }
495
- if (this .toolChoice == null ) {
496
- if (other .toolChoice != null ) {
497
- return false ;
498
- }
499
- }
500
- else if (!this .toolChoice .equals (other .toolChoice )) {
501
- return false ;
502
- }
503
- if (this .internalToolExecutionEnabled == null ) {
504
- if (other .internalToolExecutionEnabled != null ) {
505
- return false ;
506
- }
507
- }
508
- else if (!this .internalToolExecutionEnabled .equals (other .internalToolExecutionEnabled )) {
509
- return false ;
510
- }
511
-
512
- if (this .toolNames == null ) {
513
- if (other .toolNames != null ) {
514
- return false ;
515
- }
516
- }
517
- else if (!this .toolNames .equals (other .toolNames )) {
376
+ if (o == null || getClass () != o .getClass ())
518
377
return false ;
519
- }
520
-
521
- if (this .toolCallbacks == null ) {
522
- if (other .toolCallbacks != null ) {
523
- return false ;
524
- }
525
- }
526
- else if (!this .toolCallbacks .equals (other .toolCallbacks )) {
527
- return false ;
528
- }
529
-
530
- if (this .toolContext == null ) {
531
- if (other .toolContext != null ) {
532
- return false ;
533
- }
534
- }
535
- else if (!this .toolContext .equals (other .toolContext )) {
536
- return false ;
537
- }
538
-
539
- return true ;
378
+ MiniMaxChatOptions that = (MiniMaxChatOptions ) o ;
379
+ return Objects .equals (model , that .model ) && Objects .equals (frequencyPenalty , that .frequencyPenalty )
380
+ && Objects .equals (maxTokens , that .maxTokens ) && Objects .equals (n , that .n )
381
+ && Objects .equals (presencePenalty , that .presencePenalty )
382
+ && Objects .equals (responseFormat , that .responseFormat ) && Objects .equals (seed , that .seed )
383
+ && Objects .equals (stop , that .stop ) && Objects .equals (temperature , that .temperature )
384
+ && Objects .equals (topP , that .topP ) && Objects .equals (maskSensitiveInfo , that .maskSensitiveInfo )
385
+ && Objects .equals (tools , that .tools ) && Objects .equals (toolChoice , that .toolChoice )
386
+ && Objects .equals (toolCallbacks , that .toolCallbacks ) && Objects .equals (toolNames , that .toolNames )
387
+ && Objects .equals (toolContext , that .toolContext )
388
+ && Objects .equals (internalToolExecutionEnabled , that .internalToolExecutionEnabled );
540
389
}
541
390
542
391
@ Override
0 commit comments