001package com.box.sdk;
002
003import com.box.sdk.internal.utils.JsonUtils;
004import com.eclipsesource.json.JsonObject;
005
006/**
007 * Represents the AI agent basic tool used to generate text.
008 */
009public class BoxAIAgentTextGenBasicGen extends BoxJSONObject {
010    /**
011     * How the content should be included in a request to the LLM. Input for {content} is optional, depending on the use.
012     */
013    private String contentTemplate;
014    /**
015     * Embeddings used by the AI agent.
016     */
017    private BoxAIAgentEmbeddings embeddings;
018    /**
019     * The parameters for the LLM endpoint specific to OpenAI / Google models.
020     */
021    private BoxAIAgentLLMEndpointParams llmEndpointParams;
022    /**
023     * The model used for the AI Agent for generating text.
024     */
025    private String model;
026    /**
027     * The number of tokens for completion.
028     */
029    private int numTokensForCompletion;
030    /**
031     * The prompt template contains contextual information of the request and the user prompt.
032     * When passing prompt_template parameters, you must include inputs for {user_question} and {content}.
033     * Input for {current_date} is optional, depending on the use.
034     */
035    private String promptTemplate;
036    /**
037     * System messages try to help the LLM "understand" its role and what it is supposed to do.
038     */
039    private String systemMessage;
040
041    /**
042     * Constructs an AI agent with default settings.
043     * @param contentTemplate How the content should be included in a request to the LLM. Input for {content} is optional, depending on the use.
044     * @param embeddings Embeddings used by the AI agent.
045     * @param llmEndpointParams The parameters for the LLM endpoint specific to OpenAI / Google models.
046     * @param model The model used for the AI Agent for generating text.
047     * @param numTokensForCompletion The number of tokens for completion.
048     * @param promptTemplate The prompt template contains contextual information of the request and the user prompt.
049     *                       When passing prompt_template parameters, you must include inputs for {user_question} and {content}.
050     *                       Input for {current_date} is optional, depending on the use.
051     * @param systemMessage System messages try to help the LLM "understand" its role and what it is supposed to do.
052     */
053    public BoxAIAgentTextGenBasicGen(String contentTemplate, BoxAIAgentEmbeddings embeddings,
054                                     BoxAIAgentLLMEndpointParamsOpenAI llmEndpointParams, String model,
055                                     int numTokensForCompletion, String promptTemplate, String systemMessage) {
056        this.contentTemplate = contentTemplate;
057        this.embeddings = embeddings;
058        this.llmEndpointParams = llmEndpointParams;
059        this.model = model;
060        this.numTokensForCompletion = numTokensForCompletion;
061        this.promptTemplate = promptTemplate;
062        this.systemMessage = systemMessage;
063    }
064
065    /**
066     * Constructs an AI agent with default settings.
067     * @param jsonObject JSON object representing the AI agent.
068     */
069    public BoxAIAgentTextGenBasicGen(JsonObject jsonObject) {
070        super(jsonObject);
071    }
072
073    /**
074     * Gets how the content should be included in a request to the LLM. Input for {content} is optional,
075     * depending on the use.
076     * @return How the content should be included in a request to the LLM.
077     * Input for {content} is optional, depending on the use.
078     */
079    public String getContentTemplate() {
080        return contentTemplate;
081    }
082
083    /**
084     * Sets how the content should be included in a request to the LLM. Input for {content} is optional,
085     * depending on the use.
086     * @param contentTemplate How the content should be included in a request to the LLM.
087     *                        Input for {content} is optional, depending on the use.
088     */
089    public void setContentTemplate(String contentTemplate) {
090        this.contentTemplate = contentTemplate;
091    }
092
093    /**
094     * Gets the embeddings used by the AI agent.
095     * @return The embeddings used by the AI agent.
096     */
097    public BoxAIAgentEmbeddings getEmbeddings() {
098        return embeddings;
099    }
100
101    /**
102     * Sets the embeddings used by the AI agent.
103     * @param embeddings The embeddings used by the AI agent.
104     */
105    public void setEmbeddings(BoxAIAgentEmbeddings embeddings) {
106        this.embeddings = embeddings;
107    }
108
109    /**
110     * Gets the parameters for the LLM endpoint specific to OpenAI / Google models.
111     * @return The parameters for the LLM endpoint specific to OpenAI / Google models.
112     */
113    public BoxAIAgentLLMEndpointParams getLlmEndpointParams() {
114        return llmEndpointParams;
115    }
116
117    /**
118     * Sets the parameters for the LLM endpoint specific to OpenAI / Google models.
119     * @param llmEndpointParams The parameters for the LLM endpoint specific to OpenAI / Google models.
120     */
121    public void setLlmEndpointParams(BoxAIAgentLLMEndpointParamsOpenAI llmEndpointParams) {
122        this.llmEndpointParams = llmEndpointParams;
123    }
124
125    /**
126     * Gets the model used for the AI Agent for generating text.
127     * @return The model used for the AI Agent for generating text.
128     */
129    public String getModel() {
130        return model;
131    }
132
133    /**
134     * Sets the model used for the AI Agent for generating text.
135     * @param model The model used for the AI Agent for generating text.
136     */
137    public void setModel(String model) {
138        this.model = model;
139    }
140
141    /**
142     * Gets the number of tokens for completion.
143     * @return The number of tokens for completion.
144     */
145    public int getNumTokensForCompletion() {
146        return numTokensForCompletion;
147    }
148
149    /**
150     * Sets the number of tokens for completion.
151     * @param numTokensForCompletion The number of tokens for completion.
152     */
153    public void setNumTokensForCompletion(int numTokensForCompletion) {
154        this.numTokensForCompletion = numTokensForCompletion;
155    }
156
157    /**
158     * Gets the prompt template contains contextual information of the request and the user prompt.
159     * When passing prompt_template parameters, you must include inputs for {user_question} and {content}.
160     * Input for {current_date} is optional, depending on the use.
161     * @return The prompt template contains contextual information of the request and the user prompt.
162     */
163    public String getPromptTemplate() {
164        return promptTemplate;
165    }
166
167    /**
168     * Sets the prompt template contains contextual information of the request and the user prompt.
169     * When passing prompt_template parameters, you must include inputs for {user_question} and {content}.
170     * Input for {current_date} is optional, depending on the use.
171     * @param promptTemplate The prompt template contains contextual information of the request and the user prompt.
172     */
173    public void setPromptTemplate(String promptTemplate) {
174        this.promptTemplate = promptTemplate;
175    }
176
177    /**
178     * Gets the system messages try to help the LLM "understand" its role and what it is supposed to do.
179     * @return The system messages try to help the LLM "understand" its role and what it is supposed to do.
180     */
181    public String getSystemMessage() {
182        return systemMessage;
183    }
184
185    /**
186     * Sets the system messages try to help the LLM "understand" its role and what it is supposed to do.
187     * @param systemMessage The system messages try to help the LLM "understand" its role and what it is supposed to do.
188     */
189    public void setSystemMessage(String systemMessage) {
190        this.systemMessage = systemMessage;
191    }
192
193    @Override
194    void parseJSONMember(JsonObject.Member member) {
195        super.parseJSONMember(member);
196        String memberName = member.getName();
197        switch (memberName) {
198            case "content_template":
199                this.contentTemplate = member.getValue().asString();
200                break;
201            case "embeddings":
202                this.embeddings = new BoxAIAgentEmbeddings(member.getValue().asObject());
203                break;
204            case "llm_endpoint_params":
205                this.llmEndpointParams = BoxAIAgentLLMEndpointParams.parse(member.getValue().asObject());
206                break;
207            case "model":
208                this.model = member.getValue().asString();
209                break;
210            case "num_tokens_for_completion":
211                this.numTokensForCompletion = member.getValue().asInt();
212                break;
213            case "prompt_template":
214                this.promptTemplate = member.getValue().asString();
215                break;
216            case "system_message":
217                this.systemMessage = member.getValue().asString();
218                break;
219            default:
220                break;
221        }
222    }
223
224    public JsonObject getJSONObject() {
225        JsonObject jsonObject = new JsonObject();
226        JsonUtils.addIfNotNull(jsonObject, "content_template", this.contentTemplate);
227        JsonUtils.addIfNotNull(jsonObject, "embeddings", this.embeddings.getJSONObject());
228        JsonUtils.addIfNotNull(jsonObject, "llm_endpoint_params", this.llmEndpointParams.getJSONObject());
229        JsonUtils.addIfNotNull(jsonObject, "model", this.model);
230        JsonUtils.addIfNotNull(jsonObject, "num_tokens_for_completion", this.numTokensForCompletion);
231        JsonUtils.addIfNotNull(jsonObject, "prompt_template", this.promptTemplate);
232        JsonUtils.addIfNotNull(jsonObject, "system_message", this.systemMessage);
233        return jsonObject;
234    }
235}