001package com.box.sdk; 002 003import com.box.sdk.internal.utils.JsonUtils; 004import com.eclipsesource.json.JsonObject; 005import com.eclipsesource.json.JsonValue; 006 007/** 008 * AI agent tool used to handle basic text. 009 */ 010public class BoxAIAgentAskBasicText extends BoxJSONObject { 011 /** 012 * The parameters for the LLM endpoint specific to OpenAI / Google models. 013 */ 014 private BoxAIAgentLLMEndpointParams llmEndpointParams; 015 /** 016 * The model used for the AI Agent for basic text. 017 */ 018 private String model; 019 /** 020 * The number of tokens for completion. 021 */ 022 private int numTokensForCompletion; 023 /** 024 * The prompt template contains contextual information of the request and the user prompt. 025 * When passing prompt_template parameters, you must include inputs for {user_question} and {content}. 026 * Input for {current_date} is optional, depending on the use. 027 */ 028 private String promptTemplate; 029 /** 030 * System messages try to help the LLM "understand" its role and what it is supposed to do. 031 */ 032 private String systemMessage; 033 034 /** 035 * Constructs an AI agent with default settings. 036 * @param llmEndpointParams The parameters for the LLM endpoint specific to OpenAI / Google models. 037 * @param model The model used for the AI Agent for basic text. 038 * @param numTokensForCompletion The number of tokens for completion. 039 * @param promptTemplate The prompt template contains contextual information of the request and the user prompt. 040 * When passing prompt_template parameters, you must include inputs for {user_question} and {content}. 041 * Input for {current_date} is optional, depending on the use. 042 * @param systemMessage System messages try to help the LLM "understand" its role and what it is supposed to do. 043 */ 044 public BoxAIAgentAskBasicText(BoxAIAgentLLMEndpointParams llmEndpointParams, String model, 045 int numTokensForCompletion, String promptTemplate, String systemMessage) { 046 super(); 047 this.llmEndpointParams = llmEndpointParams; 048 this.model = model; 049 this.numTokensForCompletion = numTokensForCompletion; 050 this.promptTemplate = promptTemplate; 051 this.systemMessage = systemMessage; 052 } 053 054 /** 055 * Constructs an AI agent with default settings. 056 * @param jsonObject JSON object representing the AI agent. 057 */ 058 public BoxAIAgentAskBasicText(JsonObject jsonObject) { 059 super(jsonObject); 060 } 061 062 /** 063 * Gets the parameters for the LLM endpoint specific to OpenAI / Google models. 064 * @return The parameters for the LLM endpoint specific to OpenAI / Google models. 065 */ 066 public BoxAIAgentLLMEndpointParams getLlmEndpointParams() { 067 return llmEndpointParams; 068 } 069 070 /** 071 * Sets the parameters for the LLM endpoint specific to OpenAI / Google models. 072 * @param llmEndpointParams The parameters for the LLM endpoint specific to OpenAI / Google models. 073 */ 074 public void setLlmEndpointParams(BoxAIAgentLLMEndpointParams llmEndpointParams) { 075 this.llmEndpointParams = llmEndpointParams; 076 } 077 078 /** 079 * Gets the model used for the AI Agent for basic text. 080 * @return The model used for the AI Agent for basic text. 081 */ 082 public String getModel() { 083 return model; 084 } 085 086 /** 087 * Sets the model used for the AI Agent for basic text. 088 * @param model The model used for the AI Agent for basic text. 089 */ 090 public void setModel(String model) { 091 this.model = model; 092 } 093 094 /** 095 * Gets the number of tokens for completion. 096 * @return The number of tokens for completion. 097 */ 098 public int getNumTokensForCompletion() { 099 return numTokensForCompletion; 100 } 101 102 /** 103 * Sets the number of tokens for completion. 104 * @param numTokensForCompletion The number of tokens for completion. 105 */ 106 public void setNumTokensForCompletion(int numTokensForCompletion) { 107 this.numTokensForCompletion = numTokensForCompletion; 108 } 109 110 /** 111 * Gets the prompt template contains contextual information of the request and the user prompt. 112 * When passing prompt_template parameters, you must include inputs for {user_question} and {content}. 113 * Input for {current_date} is optional, depending on the use. 114 * @return The prompt template contains contextual information of the request and the user prompt. 115 */ 116 public String getPromptTemplate() { 117 return promptTemplate; 118 } 119 120 /** 121 * Sets the prompt template contains contextual information of the request and the user prompt. 122 * When passing prompt_template parameters, you must include inputs for {user_question} and {content}. 123 * Input for {current_date} is optional, depending on the use. 124 * @param promptTemplate The prompt template contains contextual information of the request and the user prompt. 125 */ 126 public void setPromptTemplate(String promptTemplate) { 127 this.promptTemplate = promptTemplate; 128 } 129 130 /** 131 * Gets the system messages try to help the LLM "understand" its role and what it is supposed to do. 132 * @return The system messages try to help the LLM "understand" its role and what it is supposed to do. 133 */ 134 public String getSystemMessage() { 135 return systemMessage; 136 } 137 138 /** 139 * Sets the system messages try to help the LLM "understand" its role and what it is supposed to do. 140 * @param systemMessage The system messages try to help the LLM "understand" its role and what it is supposed to do. 141 */ 142 public void setSystemMessage(String systemMessage) { 143 this.systemMessage = systemMessage; 144 } 145 146 @Override 147 void parseJSONMember(JsonObject.Member member) { 148 super.parseJSONMember(member); 149 String memberName = member.getName(); 150 JsonValue memberValue = member.getValue(); 151 try { 152 switch (memberName) { 153 case "llm_endpoint_params": 154 this.llmEndpointParams = BoxAIAgentLLMEndpointParams.parse(memberValue.asObject()); 155 break; 156 case "model": 157 this.model = memberValue.asString(); 158 break; 159 case "num_tokens_for_completion": 160 this.numTokensForCompletion = memberValue.asInt(); 161 break; 162 case "prompt_template": 163 this.promptTemplate = memberValue.asString(); 164 break; 165 case "system_message": 166 this.systemMessage = memberValue.asString(); 167 break; 168 default: 169 break; 170 } 171 } catch (Exception e) { 172 throw new BoxDeserializationException(memberName, memberValue.toString(), e); 173 } 174 } 175 176 public JsonObject getJSONObject() { 177 JsonObject jsonObject = new JsonObject(); 178 JsonUtils.addIfNotNull(jsonObject, "llm_endpoint_params", this.llmEndpointParams.getJSONObject()); 179 JsonUtils.addIfNotNull(jsonObject, "model", this.model); 180 JsonUtils.addIfNotNull(jsonObject, "num_tokens_for_completion", this.numTokensForCompletion); 181 JsonUtils.addIfNotNull(jsonObject, "prompt_template", this.promptTemplate); 182 JsonUtils.addIfNotNull(jsonObject, "system_message", this.systemMessage); 183 return jsonObject; 184 } 185}