• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

box / box-java-sdk / #3996

06 Sep 2024 01:11PM UTC coverage: 71.703% (-0.7%) from 72.441%
#3996

push

github

web-flow
feat: Support AI Agent (#1265)

248 of 452 new or added lines in 14 files covered. (54.87%)

3 existing lines in 3 files now uncovered.

7921 of 11047 relevant lines covered (71.7%)

0.72 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

50.85
/src/main/java/com/box/sdk/BoxAIAgentTextGenBasicGen.java
1
package com.box.sdk;
2

3
import com.box.sdk.internal.utils.JsonUtils;
4
import com.eclipsesource.json.JsonObject;
5

6
/**
7
 * Represents the AI agent basic tool used to generate text.
8
 */
9
public class BoxAIAgentTextGenBasicGen extends BoxJSONObject {
10
    /**
11
     * How the content should be included in a request to the LLM. Input for {content} is optional, depending on the use.
12
     */
13
    private String contentTemplate;
14
    /**
15
     * Embeddings used by the AI agent.
16
     */
17
    private BoxAIAgentEmbeddings embeddings;
18
    /**
19
     * The parameters for the LLM endpoint specific to OpenAI / Google models.
20
     */
21
    private BoxAIAgentLLMEndpointParams llmEndpointParams;
22
    /**
23
     * The model used for the AI Agent for generating text.
24
     */
25
    private String model;
26
    /**
27
     * The number of tokens for completion.
28
     */
29
    private int numTokensForCompletion;
30
    /**
31
     * The prompt template contains contextual information of the request and the user prompt.
32
     * When passing prompt_template parameters, you must include inputs for {user_question} and {content}.
33
     * Input for {current_date} is optional, depending on the use.
34
     */
35
    private String promptTemplate;
36
    /**
37
     * System messages try to help the LLM "understand" its role and what it is supposed to do.
38
     */
39
    private String systemMessage;
40

41
    /**
42
     * Constructs an AI agent with default settings.
43
     * @param contentTemplate How the content should be included in a request to the LLM. Input for {content} is optional, depending on the use.
44
     * @param embeddings Embeddings used by the AI agent.
45
     * @param llmEndpointParams The parameters for the LLM endpoint specific to OpenAI / Google models.
46
     * @param model The model used for the AI Agent for generating text.
47
     * @param numTokensForCompletion The number of tokens for completion.
48
     * @param promptTemplate The prompt template contains contextual information of the request and the user prompt.
49
     *                       When passing prompt_template parameters, you must include inputs for {user_question} and {content}.
50
     *                       Input for {current_date} is optional, depending on the use.
51
     * @param systemMessage System messages try to help the LLM "understand" its role and what it is supposed to do.
52
     */
53
    public BoxAIAgentTextGenBasicGen(String contentTemplate, BoxAIAgentEmbeddings embeddings,
54
                                     BoxAIAgentLLMEndpointParamsOpenAI llmEndpointParams, String model,
NEW
55
                                     int numTokensForCompletion, String promptTemplate, String systemMessage) {
×
NEW
56
        this.contentTemplate = contentTemplate;
×
NEW
57
        this.embeddings = embeddings;
×
NEW
58
        this.llmEndpointParams = llmEndpointParams;
×
NEW
59
        this.model = model;
×
NEW
60
        this.numTokensForCompletion = numTokensForCompletion;
×
NEW
61
        this.promptTemplate = promptTemplate;
×
NEW
62
        this.systemMessage = systemMessage;
×
NEW
63
    }
×
64

65
    /**
66
     * Constructs an AI agent with default settings.
67
     * @param jsonObject JSON object representing the AI agent.
68
     */
69
    public BoxAIAgentTextGenBasicGen(JsonObject jsonObject) {
70
        super(jsonObject);
1✔
71
    }
1✔
72

73
    /**
74
     * Gets how the content should be included in a request to the LLM. Input for {content} is optional,
75
     * depending on the use.
76
     * @return How the content should be included in a request to the LLM.
77
     * Input for {content} is optional, depending on the use.
78
     */
79
    public String getContentTemplate() {
NEW
80
        return contentTemplate;
×
81
    }
82

83
    /**
84
     * Sets how the content should be included in a request to the LLM. Input for {content} is optional,
85
     * depending on the use.
86
     * @param contentTemplate How the content should be included in a request to the LLM.
87
     *                        Input for {content} is optional, depending on the use.
88
     */
89
    public void setContentTemplate(String contentTemplate) {
NEW
90
        this.contentTemplate = contentTemplate;
×
NEW
91
    }
×
92

93
    /**
94
     * Gets the embeddings used by the AI agent.
95
     * @return The embeddings used by the AI agent.
96
     */
97
    public BoxAIAgentEmbeddings getEmbeddings() {
NEW
98
        return embeddings;
×
99
    }
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) {
NEW
106
        this.embeddings = embeddings;
×
NEW
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() {
NEW
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) {
NEW
122
        this.llmEndpointParams = llmEndpointParams;
×
NEW
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;
1✔
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) {
NEW
138
        this.model = model;
×
NEW
139
    }
×
140

141
    /**
142
     * Gets the number of tokens for completion.
143
     * @return The number of tokens for completion.
144
     */
145
    public int getNumTokensForCompletion() {
NEW
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) {
NEW
154
        this.numTokensForCompletion = numTokensForCompletion;
×
NEW
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() {
NEW
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) {
NEW
174
        this.promptTemplate = promptTemplate;
×
NEW
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() {
NEW
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) {
NEW
190
        this.systemMessage = systemMessage;
×
NEW
191
    }
×
192

193
    @Override
194
    void parseJSONMember(JsonObject.Member member) {
195
        super.parseJSONMember(member);
1✔
196
        String memberName = member.getName();
1✔
197
        switch (memberName) {
1✔
198
            case "content_template":
199
                this.contentTemplate = member.getValue().asString();
1✔
200
                break;
1✔
201
            case "embeddings":
202
                this.embeddings = new BoxAIAgentEmbeddings(member.getValue().asObject());
1✔
203
                break;
1✔
204
            case "llm_endpoint_params":
205
                this.llmEndpointParams = BoxAIAgentLLMEndpointParams.parse(member.getValue().asObject());
1✔
206
                break;
1✔
207
            case "model":
208
                this.model = member.getValue().asString();
1✔
209
                break;
1✔
210
            case "num_tokens_for_completion":
211
                this.numTokensForCompletion = member.getValue().asInt();
1✔
212
                break;
1✔
213
            case "prompt_template":
214
                this.promptTemplate = member.getValue().asString();
1✔
215
                break;
1✔
216
            case "system_message":
217
                this.systemMessage = member.getValue().asString();
1✔
218
                break;
1✔
219
            default:
220
                break;
221
        }
222
    }
1✔
223

224
    public JsonObject getJSONObject() {
225
        JsonObject jsonObject = new JsonObject();
1✔
226
        JsonUtils.addIfNotNull(jsonObject, "content_template", this.contentTemplate);
1✔
227
        JsonUtils.addIfNotNull(jsonObject, "embeddings", this.embeddings.getJSONObject());
1✔
228
        JsonUtils.addIfNotNull(jsonObject, "llm_endpoint_params", this.llmEndpointParams.getJSONObject());
1✔
229
        JsonUtils.addIfNotNull(jsonObject, "model", this.model);
1✔
230
        JsonUtils.addIfNotNull(jsonObject, "num_tokens_for_completion", this.numTokensForCompletion);
1✔
231
        JsonUtils.addIfNotNull(jsonObject, "prompt_template", this.promptTemplate);
1✔
232
        JsonUtils.addIfNotNull(jsonObject, "system_message", this.systemMessage);
1✔
233
        return jsonObject;
1✔
234
    }
235
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc