@@ -20,7 +20,10 @@ public record CohereGenerative(
2020 @ SerializedName ("maxTokens" ) Integer maxTokens ,
2121 @ SerializedName ("temperature" ) Float temperature ,
2222 @ SerializedName ("returnLikelihoods" ) String returnLikelihoodsProperty ,
23- @ SerializedName ("stopSequences" ) List <String > stopSequences ) implements Generative {
23+ @ SerializedName ("stopSequences" ) List <String > stopSequences ,
24+ @ SerializedName ("P" ) Float topP ,
25+ @ SerializedName ("presencePenalty" ) Float presencePenalty ,
26+ @ SerializedName ("frequencyPenalty" ) Float frequencyPenalty ) implements Generative {
2427
2528 @ Override
2629 public Kind _kind () {
@@ -48,7 +51,10 @@ public CohereGenerative(Builder builder) {
4851 builder .maxTokens ,
4952 builder .temperature ,
5053 builder .returnLikelihoodsProperty ,
51- builder .stopSequences );
54+ builder .stopSequences ,
55+ builder .topP ,
56+ builder .presencePenalty ,
57+ builder .frequencyPenalty );
5258 }
5359
5460 public static class Builder implements ObjectBuilder <CohereGenerative > {
@@ -58,7 +64,10 @@ public static class Builder implements ObjectBuilder<CohereGenerative> {
5864 private Integer maxTokens ;
5965 private Float temperature ;
6066 private String returnLikelihoodsProperty ;
61- private List <String > stopSequences ;
67+ private final List <String > stopSequences = new ArrayList <>();
68+ private Float topP ;
69+ private Float presencePenalty ;
70+ private Float frequencyPenalty ;
6271
6372 /** Base URL of the generative provider. */
6473 public Builder baseUrl (String baseUrl ) {
@@ -72,6 +81,12 @@ public Builder topK(int topK) {
7281 return this ;
7382 }
7483
84+ /** Top P value for nucleus sampling. */
85+ public Builder topP (float topP ) {
86+ this .topP = topP ;
87+ return this ;
88+ }
89+
7590 /** Select generative model. */
7691 public Builder model (String model ) {
7792 this .model = model ;
@@ -100,9 +115,6 @@ public Builder stopSequences(String... stopSequences) {
100115 * Set tokens which should signal the model to stop generating further output.
101116 */
102117 public Builder stopSequences (List <String > stopSequences ) {
103- if (this .stopSequences == null ) {
104- this .stopSequences = new ArrayList <>();
105- }
106118 this .stopSequences .addAll (stopSequences );
107119 return this ;
108120 }
@@ -116,6 +128,16 @@ public Builder temperature(float temperature) {
116128 return this ;
117129 }
118130
131+ public Builder presencePenalty (float presencePenalty ) {
132+ this .presencePenalty = presencePenalty ;
133+ return this ;
134+ }
135+
136+ public Builder frequencyPenalty (float frequencyPenalty ) {
137+ this .frequencyPenalty = frequencyPenalty ;
138+ return this ;
139+ }
140+
119141 @ Override
120142 public CohereGenerative build () {
121143 return new CohereGenerative (this );
@@ -211,7 +233,7 @@ public static class Builder implements ObjectBuilder<CohereGenerative.Provider>
211233 private Float temperature ;
212234 private Float frequencyPenalty ;
213235 private Float presencePenalty ;
214- private List <String > stopSequences ;
236+ private final List <String > stopSequences = new ArrayList <>() ;
215237
216238 /** Base URL of the generative provider. */
217239 public Builder baseUrl (String baseUrl ) {
@@ -265,9 +287,6 @@ public Builder stopSequences(String... stopSequences) {
265287 * Set tokens which should signal the model to stop generating further output.
266288 */
267289 public Builder stopSequences (List <String > stopSequences ) {
268- if (this .stopSequences == null ) {
269- this .stopSequences = new ArrayList <>();
270- }
271290 this .stopSequences .addAll (stopSequences );
272291 return this ;
273292 }
0 commit comments