001package com.box.sdkgen.schemas.aillmendpointparamsopenai; 002 003import com.box.sdkgen.internal.Nullable; 004import com.box.sdkgen.internal.NullableFieldTracker; 005import com.box.sdkgen.internal.SerializableObject; 006import com.box.sdkgen.serialization.json.EnumWrapper; 007import com.fasterxml.jackson.annotation.JsonFilter; 008import com.fasterxml.jackson.annotation.JsonProperty; 009import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 010import com.fasterxml.jackson.databind.annotation.JsonSerialize; 011import java.util.Objects; 012 013/** AI LLM endpoint params OpenAI object. */ 014@JsonFilter("nullablePropertyFilter") 015public class AiLlmEndpointParamsOpenAi extends SerializableObject { 016 017 /** The type of the AI LLM endpoint params object for OpenAI. This parameter is **required**. */ 018 @JsonDeserialize( 019 using = 020 AiLlmEndpointParamsOpenAiTypeField.AiLlmEndpointParamsOpenAiTypeFieldDeserializer.class) 021 @JsonSerialize( 022 using = AiLlmEndpointParamsOpenAiTypeField.AiLlmEndpointParamsOpenAiTypeFieldSerializer.class) 023 protected EnumWrapper<AiLlmEndpointParamsOpenAiTypeField> type; 024 025 /** 026 * What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output 027 * more random, while lower values like 0.2 will make it more focused and deterministic. We 028 * generally recommend altering this or `top_p` but not both. 029 */ 030 @Nullable protected Double temperature; 031 032 /** 033 * An alternative to sampling with temperature, called nucleus sampling, where the model considers 034 * the results of the tokens with `top_p` probability mass. So 0.1 means only the tokens 035 * comprising the top 10% probability mass are considered. We generally recommend altering this or 036 * temperature but not both. 037 */ 038 @JsonProperty("top_p") 039 @Nullable 040 protected Double topP; 041 042 /** 043 * A number between -2.0 and 2.0. Positive values penalize new tokens based on their existing 044 * frequency in the text so far, decreasing the model's likelihood to repeat the same line 045 * verbatim. 046 */ 047 @JsonProperty("frequency_penalty") 048 @Nullable 049 protected Double frequencyPenalty; 050 051 /** 052 * A number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear 053 * in the text so far, increasing the model's likelihood to talk about new topics. 054 */ 055 @JsonProperty("presence_penalty") 056 @Nullable 057 protected Double presencePenalty; 058 059 /** Up to 4 sequences where the API will stop generating further tokens. */ 060 @Nullable protected String stop; 061 062 public AiLlmEndpointParamsOpenAi() { 063 super(); 064 this.type = 065 new EnumWrapper<AiLlmEndpointParamsOpenAiTypeField>( 066 AiLlmEndpointParamsOpenAiTypeField.OPENAI_PARAMS); 067 } 068 069 protected AiLlmEndpointParamsOpenAi(Builder builder) { 070 super(); 071 this.type = builder.type; 072 this.temperature = builder.temperature; 073 this.topP = builder.topP; 074 this.frequencyPenalty = builder.frequencyPenalty; 075 this.presencePenalty = builder.presencePenalty; 076 this.stop = builder.stop; 077 markNullableFieldsAsSet(builder.getExplicitlySetNullableFields()); 078 } 079 080 public EnumWrapper<AiLlmEndpointParamsOpenAiTypeField> getType() { 081 return type; 082 } 083 084 public Double getTemperature() { 085 return temperature; 086 } 087 088 public Double getTopP() { 089 return topP; 090 } 091 092 public Double getFrequencyPenalty() { 093 return frequencyPenalty; 094 } 095 096 public Double getPresencePenalty() { 097 return presencePenalty; 098 } 099 100 public String getStop() { 101 return stop; 102 } 103 104 @Override 105 public boolean equals(Object o) { 106 if (this == o) { 107 return true; 108 } 109 if (o == null || getClass() != o.getClass()) { 110 return false; 111 } 112 AiLlmEndpointParamsOpenAi casted = (AiLlmEndpointParamsOpenAi) o; 113 return Objects.equals(type, casted.type) 114 && Objects.equals(temperature, casted.temperature) 115 && Objects.equals(topP, casted.topP) 116 && Objects.equals(frequencyPenalty, casted.frequencyPenalty) 117 && Objects.equals(presencePenalty, casted.presencePenalty) 118 && Objects.equals(stop, casted.stop); 119 } 120 121 @Override 122 public int hashCode() { 123 return Objects.hash(type, temperature, topP, frequencyPenalty, presencePenalty, stop); 124 } 125 126 @Override 127 public String toString() { 128 return "AiLlmEndpointParamsOpenAi{" 129 + "type='" 130 + type 131 + '\'' 132 + ", " 133 + "temperature='" 134 + temperature 135 + '\'' 136 + ", " 137 + "topP='" 138 + topP 139 + '\'' 140 + ", " 141 + "frequencyPenalty='" 142 + frequencyPenalty 143 + '\'' 144 + ", " 145 + "presencePenalty='" 146 + presencePenalty 147 + '\'' 148 + ", " 149 + "stop='" 150 + stop 151 + '\'' 152 + "}"; 153 } 154 155 public static class Builder extends NullableFieldTracker { 156 157 protected EnumWrapper<AiLlmEndpointParamsOpenAiTypeField> type; 158 159 protected Double temperature; 160 161 protected Double topP; 162 163 protected Double frequencyPenalty; 164 165 protected Double presencePenalty; 166 167 protected String stop; 168 169 public Builder() { 170 super(); 171 } 172 173 public Builder type(AiLlmEndpointParamsOpenAiTypeField type) { 174 this.type = new EnumWrapper<AiLlmEndpointParamsOpenAiTypeField>(type); 175 return this; 176 } 177 178 public Builder type(EnumWrapper<AiLlmEndpointParamsOpenAiTypeField> type) { 179 this.type = type; 180 return this; 181 } 182 183 public Builder temperature(Double temperature) { 184 this.temperature = temperature; 185 this.markNullableFieldAsSet("temperature"); 186 return this; 187 } 188 189 public Builder topP(Double topP) { 190 this.topP = topP; 191 this.markNullableFieldAsSet("top_p"); 192 return this; 193 } 194 195 public Builder frequencyPenalty(Double frequencyPenalty) { 196 this.frequencyPenalty = frequencyPenalty; 197 this.markNullableFieldAsSet("frequency_penalty"); 198 return this; 199 } 200 201 public Builder presencePenalty(Double presencePenalty) { 202 this.presencePenalty = presencePenalty; 203 this.markNullableFieldAsSet("presence_penalty"); 204 return this; 205 } 206 207 public Builder stop(String stop) { 208 this.stop = stop; 209 this.markNullableFieldAsSet("stop"); 210 return this; 211 } 212 213 public AiLlmEndpointParamsOpenAi build() { 214 if (this.type == null) { 215 this.type = 216 new EnumWrapper<AiLlmEndpointParamsOpenAiTypeField>( 217 AiLlmEndpointParamsOpenAiTypeField.OPENAI_PARAMS); 218 } 219 return new AiLlmEndpointParamsOpenAi(this); 220 } 221 } 222}