3636 *
3737 * @author Geng Rong
3838 * @author Thomas Vitale
39+ * @author Alexandros Pappas
3940 */
4041@ JsonInclude (JsonInclude .Include .NON_NULL )
4142public class MoonshotChatOptions implements FunctionCallingOptions {
@@ -281,21 +282,21 @@ public void setToolContext(Map<String, Object> toolContext) {
281282
282283 @ Override
283284 public MoonshotChatOptions copy () {
284- return builder ().withModel (this .model )
285- .withMaxTokens (this .maxTokens )
286- .withTemperature (this .temperature )
287- .withTopP (this .topP )
288- .withN (this .n )
289- .withPresencePenalty (this .presencePenalty )
290- .withFrequencyPenalty (this .frequencyPenalty )
291- .withStop (this .stop )
292- .withUser (this .user )
293- .withTools (this .tools )
294- .withToolChoice (this .toolChoice )
295- .withFunctionCallbacks (this .functionCallbacks )
296- .withFunctions (this .functions )
297- .withProxyToolCalls (this .proxyToolCalls )
298- .withToolContext (this .toolContext )
285+ return builder ().model (this .model )
286+ .maxTokens (this .maxTokens )
287+ .temperature (this .temperature )
288+ .topP (this .topP )
289+ .N (this .n )
290+ .presencePenalty (this .presencePenalty )
291+ .frequencyPenalty (this .frequencyPenalty )
292+ .stop (this .stop )
293+ .user (this .user )
294+ .tools (this .tools )
295+ .toolChoice (this .toolChoice )
296+ .functionCallbacks (this .functionCallbacks )
297+ .functions (this .functions )
298+ .proxyToolCalls (this .proxyToolCalls )
299+ .toolContext (this .toolContext )
299300 .build ();
300301 }
301302
@@ -416,94 +417,89 @@ else if (!this.toolContext.equals(other.toolContext)) {
416417
417418 public static class Builder {
418419
419- protected MoonshotChatOptions options ;
420+ private final MoonshotChatOptions options = new MoonshotChatOptions () ;
420421
421- public Builder () {
422- this .options = new MoonshotChatOptions ();
423- }
424-
425- public Builder (MoonshotChatOptions options ) {
426- this .options = options ;
427- }
428-
429- public Builder withModel (String model ) {
422+ public Builder model (String model ) {
430423 this .options .model = model ;
431424 return this ;
432425 }
433426
434- public Builder withMaxTokens (Integer maxTokens ) {
427+ public Builder maxTokens (Integer maxTokens ) {
435428 this .options .maxTokens = maxTokens ;
436429 return this ;
437430 }
438431
439- public Builder withTemperature (Double temperature ) {
432+ public Builder temperature (Double temperature ) {
440433 this .options .temperature = temperature ;
441434 return this ;
442435 }
443436
444- public Builder withTopP (Double topP ) {
437+ public Builder topP (Double topP ) {
445438 this .options .topP = topP ;
446439 return this ;
447440 }
448441
449- public Builder withN (Integer n ) {
442+ public Builder N (Integer n ) {
450443 this .options .n = n ;
451444 return this ;
452445 }
453446
454- public Builder withPresencePenalty (Double presencePenalty ) {
447+ public Builder presencePenalty (Double presencePenalty ) {
455448 this .options .presencePenalty = presencePenalty ;
456449 return this ;
457450 }
458451
459- public Builder withFrequencyPenalty (Double frequencyPenalty ) {
452+ public Builder frequencyPenalty (Double frequencyPenalty ) {
460453 this .options .frequencyPenalty = frequencyPenalty ;
461454 return this ;
462455 }
463456
464- public Builder withStop (List <String > stop ) {
457+ public Builder stop (List <String > stop ) {
465458 this .options .stop = stop ;
466459 return this ;
467460 }
468461
469- public Builder withUser (String user ) {
462+ public Builder user (String user ) {
470463 this .options .user = user ;
471464 return this ;
472465 }
473466
474- public Builder withTools (List <MoonshotApi .FunctionTool > tools ) {
467+ public Builder tools (List <MoonshotApi .FunctionTool > tools ) {
475468 this .options .tools = tools ;
476469 return this ;
477470 }
478471
479- public Builder withToolChoice (String toolChoice ) {
472+ public Builder toolChoice (String toolChoice ) {
480473 this .options .toolChoice = toolChoice ;
481474 return this ;
482475 }
483476
484- public Builder withFunctionCallbacks (List <FunctionCallback > functionCallbacks ) {
477+ public Builder functionCallbacks (List <FunctionCallback > functionCallbacks ) {
485478 this .options .functionCallbacks = functionCallbacks ;
486479 return this ;
487480 }
488481
489- public Builder withFunctions (Set <String > functionNames ) {
482+ public Builder functions (Set <String > functionNames ) {
490483 Assert .notNull (functionNames , "Function names must not be null" );
491484 this .options .functions = functionNames ;
492485 return this ;
493486 }
494487
495- public Builder withFunction (String functionName ) {
488+ public Builder function (String functionName ) {
496489 Assert .hasText (functionName , "Function name must not be empty" );
490+ if (this .options .functions == null ) {
491+ this .options .functions = new HashSet <>();
492+ }
497493 this .options .functions .add (functionName );
498494 return this ;
499495 }
500496
501- public Builder withProxyToolCalls (Boolean proxyToolCalls ) {
497+ public Builder proxyToolCalls (Boolean proxyToolCalls ) {
502498 this .options .proxyToolCalls = proxyToolCalls ;
503499 return this ;
504500 }
505501
506- public Builder withToolContext (Map <String , Object > toolContext ) {
502+ public Builder toolContext (Map <String , Object > toolContext ) {
507503 if (this .options .toolContext == null ) {
508504 this .options .toolContext = toolContext ;
509505 }
@@ -513,6 +509,134 @@ public Builder withToolContext(Map<String, Object> toolContext) {
513509 return this ;
514510 }
515511
512+ /**
513+ * @deprecated use {@link #functions(Set)} instead.
514+ */
515+ @ Deprecated (forRemoval = true , since = "1.0.0-M5" )
516+ public Builder withFunctions (Set <String > functionNames ) {
517+ return functions (functionNames );
518+ }
519+
520+ /**
521+ * @deprecated use {@link #function(String)} instead.
522+ */
523+ @ Deprecated (forRemoval = true , since = "1.0.0-M5" )
524+ public Builder withFunction (String functionName ) {
525+ return function (functionName );
526+ }
527+
528+ /**
529+ * @deprecated use {@link #model(String)} instead.
530+ */
531+ @ Deprecated (forRemoval = true , since = "1.0.0-M5" )
532+ public Builder withModel (String model ) {
533+ return model (model );
534+ }
535+
536+ /**
537+ * @deprecated use {@link #maxTokens(Integer)} instead.
538+ */
539+ @ Deprecated (forRemoval = true , since = "1.0.0-M5" )
540+ public Builder withMaxTokens (Integer maxTokens ) {
541+ return maxTokens (maxTokens );
542+ }
543+
544+ /**
545+ * @deprecated use {@link #temperature(Double)} instead.
546+ */
547+ @ Deprecated (forRemoval = true , since = "1.0.0-M5" )
548+ public Builder withTemperature (Double temperature ) {
549+ return temperature (temperature );
550+ }
551+
552+ /**
553+ * @deprecated use {@link #topP(Double)} instead.
554+ */
555+ @ Deprecated (forRemoval = true , since = "1.0.0-M5" )
556+ public Builder withTopP (Double topP ) {
557+ return topP (topP );
558+ }
559+
560+ /**
561+ * @deprecated use {@link #N(Integer)} instead.
562+ */
563+ @ Deprecated (forRemoval = true , since = "1.0.0-M5" )
564+ public Builder withN (Integer n ) {
565+ return N (n );
566+ }
567+
568+ /**
569+ * @deprecated use {@link #presencePenalty(Double)} instead.
570+ */
571+ @ Deprecated (forRemoval = true , since = "1.0.0-M5" )
572+ public Builder withPresencePenalty (Double presencePenalty ) {
573+ return presencePenalty (presencePenalty );
574+ }
575+
576+ /**
577+ * @deprecated use {@link #frequencyPenalty(Double)} instead.
578+ */
579+ @ Deprecated (forRemoval = true , since = "1.0.0-M5" )
580+ public Builder withFrequencyPenalty (Double frequencyPenalty ) {
581+ return frequencyPenalty (frequencyPenalty );
582+ }
583+
584+ /**
585+ * @deprecated use {@link #stop(List)} instead.
586+ */
587+ @ Deprecated (forRemoval = true , since = "1.0.0-M5" )
588+ public Builder withStop (List <String > stop ) {
589+ return stop (stop );
590+ }
591+
592+ /**
593+ * @deprecated use {@link #user(String)} instead.
594+ */
595+ @ Deprecated (forRemoval = true , since = "1.0.0-M5" )
596+ public Builder withUser (String user ) {
597+ return user (user );
598+ }
599+
600+ /**
601+ * @deprecated use {@link #tools(List)} instead.
602+ */
603+ @ Deprecated (forRemoval = true , since = "1.0.0-M5" )
604+ public Builder withTools (List <MoonshotApi .FunctionTool > tools ) {
605+ return tools (tools );
606+ }
607+
608+ /**
609+ * @deprecated use {@link #toolChoice(String)} instead.
610+ */
611+ @ Deprecated (forRemoval = true , since = "1.0.0-M5" )
612+ public Builder withToolChoice (String toolChoice ) {
613+ return toolChoice (toolChoice );
614+ }
615+
616+ /**
617+ * @deprecated use {@link #functionCallbacks(List)} instead.
618+ */
619+ @ Deprecated (forRemoval = true , since = "1.0.0-M5" )
620+ public Builder withFunctionCallbacks (List <FunctionCallback > functionCallbacks ) {
621+ return functionCallbacks (functionCallbacks );
622+ }
623+
624+ /**
625+ * @deprecated use {@link #proxyToolCalls(Boolean)} instead.
626+ */
627+ @ Deprecated (forRemoval = true , since = "1.0.0-M5" )
628+ public Builder withProxyToolCalls (Boolean proxyToolCalls ) {
629+ return proxyToolCalls (proxyToolCalls );
630+ }
631+
632+ /**
633+ * @deprecated use {@link #toolContext(Map)} instead.
634+ */
635+ @ Deprecated (forRemoval = true , since = "1.0.0-M5" )
636+ public Builder withToolContext (Map <String , Object > toolContext ) {
637+ return toolContext (toolContext );
638+ }
639+
516640 public MoonshotChatOptions build () {
517641 return this .options ;
518642 }
0 commit comments