001package com.box.sdk; 002 003import com.box.sdk.internal.utils.JsonUtils; 004import com.eclipsesource.json.JsonObject; 005 006/** Represents the AI LLM endpoint params Google object. */ 007public class BoxAIAgentLLMEndpointParamsGoogle extends BoxAIAgentLLMEndpointParams { 008 009 /** The type of the LLM endpoint parameters. */ 010 public static final String TYPE = "google_params"; 011 012 /** 013 * The temperature is used for sampling during response generation, which occurs when top-P and 014 * top-K are applied. Temperature controls the degree of randomness in token selection. 015 */ 016 private Double temperature; 017 /** 018 * Top-K changes how the model selects tokens for output. A top-K of 1 means the next selected 019 * token is the most probable among all tokens in the model's vocabulary (also called greedy 020 * decoding), while a top-K of 3 means that the next token is selected from among the three most 021 * probable tokens by using temperature. 022 */ 023 private Integer topK; 024 /** 025 * Top-P changes how the model selects tokens for output. Tokens are selected from the most (see 026 * top-K) to least probable until the sum of their probabilities equals the top-P value. 027 */ 028 private Double topP; 029 030 /** 031 * Constructs an AI agent with default settings. 032 * 033 * @param temperature The temperature is used for sampling during response generation, which 034 * occurs when top-P and top-K are applied. Temperature controls the degree of randomness in 035 * token selection. 036 * @param topK Top-K changes how the model selects tokens for output. A top-K of 1 means the next 037 * selected token is the most probable among all tokens in the model's vocabulary (also called 038 * greedy decoding), while a top-K of 3 means that the next token is selected from among the 039 * three most probable tokens by using temperature. 040 * @param topP Top-P changes how the model selects tokens for output. Tokens are selected from the 041 * most (see top-K) to least probable until the sum of their probabilities equals the top-P 042 * value. 043 */ 044 public BoxAIAgentLLMEndpointParamsGoogle(Double temperature, Integer topK, Double topP) { 045 super(TYPE); 046 this.temperature = temperature; 047 this.topK = topK; 048 this.topP = topP; 049 } 050 051 /** 052 * Constructs an AI agent with default settings. 053 * 054 * @param jsonObject JSON object representing the AI agent. 055 */ 056 public BoxAIAgentLLMEndpointParamsGoogle(JsonObject jsonObject) { 057 super(jsonObject); 058 } 059 060 /** 061 * Gets the temperature used for sampling during response generation, which occurs when top-P and 062 * top-K are applied. 063 * 064 * @return The temperature used for sampling during response generation, which occurs when top-P 065 * and top-K are applied. 066 */ 067 public Double getTemperature() { 068 return temperature; 069 } 070 071 /** 072 * Sets the temperature used for sampling during response generation, which occurs when top-P and 073 * top-K are applied. 074 * 075 * @param temperature The temperature used for sampling during response generation, which occurs 076 * when top-P and top-K are applied. 077 */ 078 public void setTemperature(Double temperature) { 079 this.temperature = temperature; 080 } 081 082 /** 083 * Gets the top-K value. 084 * 085 * @return The top-K value. 086 */ 087 public Integer getTopK() { 088 return topK; 089 } 090 091 /** 092 * Sets the top-K value. 093 * 094 * @param topK The top-K value. 095 */ 096 public void setTopK(Integer topK) { 097 this.topK = topK; 098 } 099 100 /** 101 * Gets the top-P value. 102 * 103 * @return The top-P value. 104 */ 105 public Double getTopP() { 106 return topP; 107 } 108 109 /** 110 * Sets the top-P value. 111 * 112 * @param topP The top-P value. 113 */ 114 public void setTopP(Double topP) { 115 this.topP = topP; 116 } 117 118 @Override 119 void parseJSONMember(JsonObject.Member member) { 120 super.parseJSONMember(member); 121 String memberName = member.getName(); 122 switch (memberName) { 123 case "temperature": 124 this.temperature = member.getValue().asDouble(); 125 break; 126 case "top_k": 127 this.topK = member.getValue().asInt(); 128 break; 129 case "top_p": 130 this.topP = member.getValue().asDouble(); 131 break; 132 default: 133 break; 134 } 135 } 136 137 public JsonObject getJSONObject() { 138 JsonObject jsonObject = new JsonObject(); 139 JsonUtils.addIfNotNull(jsonObject, "type", this.getType()); 140 JsonUtils.addIfNotNull(jsonObject, "temperature", this.temperature); 141 JsonUtils.addIfNotNull(jsonObject, "top_k", this.topK); 142 JsonUtils.addIfNotNull(jsonObject, "top_p", this.topP); 143 return jsonObject; 144 } 145}