• 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

49.09
/src/main/java/com/box/sdk/BoxAIAgentAskLongText.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 an AI agent tool used to handle longer text.
8
 */
9
public class BoxAIAgentAskLongText extends BoxJSONObject {
10
    /**
11
     * Embeddings used by the AI agent.
12
     */
13
    private BoxAIAgentEmbeddings embeddings;
14
    /**
15
     * The parameters for the LLM endpoint specific to OpenAI / Google models.
16
     */
17
    private BoxAIAgentLLMEndpointParams llmEndpointParams;
18
    /**
19
     * The model used for the AI Agent for basic text.
20
     */
21
    private String model;
22
    /**
23
     * The number of tokens for completion.
24
     */
25
    private int numTokensForCompletion;
26
    /**
27
     * The prompt template contains contextual information of the request and the user prompt.
28
     * When passing prompt_template parameters, you must include inputs for {user_question} and {content}.
29
     * Input for {current_date} is optional, depending on the use.
30
     */
31
    private String promptTemplate;
32
    /**
33
     * System messages try to help the LLM "understand" its role and what it is supposed to do.
34
     */
35
    private String systemMessage;
36

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

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

70
    /**
71
     * Gets the embeddings used by the AI agent.
72
     * @return The embeddings used by the AI agent.
73
     */
74
    public BoxAIAgentEmbeddings getEmbeddings() {
NEW
75
        return embeddings;
×
76
    }
77

78
    /**
79
     * Sets the embeddings used by the AI agent.
80
     * @param embeddings The embeddings used by the AI agent.
81
     */
82
    public void setEmbeddings(BoxAIAgentEmbeddings embeddings) {
NEW
83
        this.embeddings = embeddings;
×
NEW
84
    }
×
85

86
    /**
87
     * Gets the parameters for the LLM endpoint specific to OpenAI / Google models.
88
     * @return The parameters for the LLM endpoint specific to OpenAI / Google models.
89
     */
90
    public BoxAIAgentLLMEndpointParams getLlmEndpointParams() {
NEW
91
        return llmEndpointParams;
×
92
    }
93

94
    /**
95
     * Sets the parameters for the LLM endpoint specific to OpenAI / Google models.
96
     * @param llmEndpointParams The parameters for the LLM endpoint specific to OpenAI / Google models.
97
     */
98
    public void setLlmEndpointParams(BoxAIAgentLLMEndpointParams llmEndpointParams) {
NEW
99
        this.llmEndpointParams = llmEndpointParams;
×
NEW
100
    }
×
101

102
    /**
103
     * Gets the model used for the AI Agent for basic text.
104
     * @return The model used for the AI Agent for basic text.
105
     */
106
    public String getModel() {
NEW
107
        return model;
×
108
    }
109

110
    /**
111
     * Sets the model used for the AI Agent for basic text.
112
     * @param model The model used for the AI Agent for basic text.
113
     */
114
    public void setModel(String model) {
NEW
115
        this.model = model;
×
NEW
116
    }
×
117

118
    /**
119
     * Gets the number of tokens for completion.
120
     * @return The number of tokens for completion.
121
     */
122
    public int getNumTokensForCompletion() {
NEW
123
        return numTokensForCompletion;
×
124
    }
125

126
    /**
127
     * Sets the number of tokens for completion.
128
     * @param numTokensForCompletion The number of tokens for completion.
129
     */
130
    public void setNumTokensForCompletion(int numTokensForCompletion) {
NEW
131
        this.numTokensForCompletion = numTokensForCompletion;
×
NEW
132
    }
×
133

134
    /**
135
     * Gets the prompt template contains contextual information of the request and the user prompt.
136
     * When passing prompt_template parameters, you must include inputs for {user_question} and {content}.
137
     * Input for {current_date} is optional, depending on the use.
138
     * @return The prompt template contains contextual information of the request and the user prompt.
139
     */
140
    public String getPromptTemplate() {
NEW
141
        return promptTemplate;
×
142
    }
143

144
    /**
145
     * Sets the prompt template contains contextual information of the request and the user prompt.
146
     * When passing prompt_template parameters, you must include inputs for {user_question} and {content}.
147
     * Input for {current_date} is optional, depending on the use.
148
     * @param promptTemplate The prompt template contains contextual information of the request and the user prompt.
149
     */
150
    public void setPromptTemplate(String promptTemplate) {
NEW
151
        this.promptTemplate = promptTemplate;
×
NEW
152
    }
×
153

154
    /**
155
     * Gets the system messages try to help the LLM "understand" its role and what it is supposed to do.
156
     * @return The system messages try to help the LLM "understand" its role and what it is supposed to do.
157
     */
158
    public String getSystemMessage() {
NEW
159
        return systemMessage;
×
160
    }
161

162
    /**
163
     * Sets the system messages try to help the LLM "understand" its role and what it is supposed to do.
164
     * @param systemMessage The system messages try to help the LLM "understand" its role and what it is supposed to do.
165
     */
166
    public void setSystemMessage(String systemMessage) {
NEW
167
        this.systemMessage = systemMessage;
×
NEW
168
    }
×
169

170
    @Override
171
    void parseJSONMember(JsonObject.Member member) {
172
        super.parseJSONMember(member);
1✔
173
        String memberName = member.getName();
1✔
174
        try {
175
            switch (memberName) {
1✔
176
                case "embeddings":
177
                    this.embeddings = new BoxAIAgentEmbeddings(member.getValue().asObject());
1✔
178
                    break;
1✔
179
                case "llm_endpoint_params":
180
                    this.llmEndpointParams = BoxAIAgentLLMEndpointParams.parse(member.getValue().asObject());
1✔
181
                    break;
1✔
182
                case "model":
183
                    this.model = member.getValue().asString();
1✔
184
                    break;
1✔
185
                case "num_tokens_for_completion":
186
                    this.numTokensForCompletion = member.getValue().asInt();
1✔
187
                    break;
1✔
188
                case "prompt_template":
189
                    this.promptTemplate = member.getValue().asString();
1✔
190
                    break;
1✔
191
                case "system_message":
192
                    this.systemMessage = member.getValue().asString();
1✔
193
                    break;
1✔
194
                default:
195
                    break;
196
            }
NEW
197
        } catch (Exception e) {
×
NEW
198
            throw new BoxAPIException("Could not parse JSON response.", e);
×
199
        }
1✔
200
    }
1✔
201

202
    public JsonObject getJSONObject() {
203
        JsonObject jsonObject = new JsonObject();
1✔
204
        JsonUtils.addIfNotNull(jsonObject, "embeddings", this.embeddings.getJSONObject());
1✔
205
        JsonUtils.addIfNotNull(jsonObject, "llm_endpoint_params", this.llmEndpointParams.getJSONObject());
1✔
206
        JsonUtils.addIfNotNull(jsonObject, "model", this.model);
1✔
207
        JsonUtils.addIfNotNull(jsonObject, "num_tokens_for_completion", this.numTokensForCompletion);
1✔
208
        JsonUtils.addIfNotNull(jsonObject, "prompt_template", this.promptTemplate);
1✔
209
        JsonUtils.addIfNotNull(jsonObject, "system_message", this.systemMessage);
1✔
210
        return jsonObject;
1✔
211
    }
212
}
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