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