• 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

52.17
/src/main/java/com/box/sdk/BoxAIAgentLLMEndpointParamsOpenAI.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 LLM endpoint params OpenAI object.
8
 */
9
public class BoxAIAgentLLMEndpointParamsOpenAI extends BoxAIAgentLLMEndpointParams {
10

11
    /**
12
     * The type of the LLM endpoint parameters.
13
     */
14
    public static final String TYPE = "openai_params";
15

16
    /**
17
     * Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text
18
     * so far, decreasing the model's likelihood to repeat the same line verbatim.
19
     */
20
    private double frequencyPenalty;
21
    /**
22
     * Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far,
23
     * increasing the model's likelihood to talk about new topics.
24
     */
25
    private double presencePenalty;
26
    /**
27
     * Up to 4 sequences where the API will stop generating further tokens.
28
     */
29
    private String stop;
30
    /**
31
     * What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random,
32
     * while lower values like 0.2 will make it more focused and deterministic.
33
     * We generally recommend altering this or top_p but not both.
34
     */
35
    private double temperature;
36
    /**
37
     * An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of
38
     * the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass
39
     * are considered. We generally recommend altering this or temperature but not both.
40
     */
41
    private double topP;
42

43
    /**
44
     * Constructs an AI agent with default settings.
45
     * @param frequencyPenalty Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text
46
     *                         so far, decreasing the model's likelihood to repeat the same line verbatim.
47
     * @param presencePenalty Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far,
48
     *                        increasing the model's likelihood to talk about new topics.
49
     * @param stop Up to 4 sequences where the API will stop generating further tokens.
50
     * @param temperature What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random,
51
     *                   while lower values like 0.2 will make it more focused and deterministic.
52
     *                   We generally recommend altering this or top_p but not both.
53
     * @param topP An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of
54
     *             the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass
55
     *             are considered. We generally recommend altering this or temperature but not both.
56
     */
57
    public BoxAIAgentLLMEndpointParamsOpenAI(double frequencyPenalty,
58
                                             double presencePenalty,
59
                                             String stop,
60
                                             double temperature,
61
                                             double topP) {
NEW
62
        super(TYPE);
×
NEW
63
        this.frequencyPenalty = frequencyPenalty;
×
NEW
64
        this.presencePenalty = presencePenalty;
×
NEW
65
        this.stop = stop;
×
NEW
66
        this.temperature = temperature;
×
NEW
67
        this.topP = topP;
×
NEW
68
    }
×
69

70
    /**
71
     * Constructs an AI agent with default settings.
72
     * @param jsonObject JSON object representing the AI agent.
73
     */
74
    public BoxAIAgentLLMEndpointParamsOpenAI(JsonObject jsonObject) {
75
        super(jsonObject);
1✔
76
    }
1✔
77

78
    /**
79
     * Gets the frequency penalty.
80
     * @return The frequency penalty.
81
     */
82
    public double getFrequencyPenalty() {
NEW
83
        return frequencyPenalty;
×
84
    }
85

86
    /**
87
     * Sets the frequency penalty.
88
     * @param frequencyPenalty The frequency penalty.
89
     */
90
    public void setFrequencyPenalty(double frequencyPenalty) {
NEW
91
        this.frequencyPenalty = frequencyPenalty;
×
NEW
92
    }
×
93

94
    /**
95
     * Gets the presence penalty.
96
     * @return The presence penalty.
97
     */
98
    public double getPresencePenalty() {
NEW
99
        return presencePenalty;
×
100
    }
101

102
    /**
103
     * Sets the presence penalty.
104
     * @param presencePenalty The presence penalty.
105
     */
106
    public void setPresencePenalty(double presencePenalty) {
NEW
107
        this.presencePenalty = presencePenalty;
×
NEW
108
    }
×
109

110
    /**
111
     * Gets the stop.
112
     * @return The stop.
113
     */
114
    public String getStop() {
NEW
115
        return stop;
×
116
    }
117

118
    /**
119
     * Sets the stop.
120
     * @param stop The stop.
121
     */
122
    public void setStop(String stop) {
NEW
123
        this.stop = stop;
×
NEW
124
    }
×
125

126
    /**
127
     * Gets the temperature.
128
     * @return The temperature.
129
     */
130
    public double getTemperature() {
NEW
131
        return temperature;
×
132
    }
133

134
    /**
135
     * Sets the temperature.
136
     * @param temperature The temperature.
137
     */
138
    public void setTemperature(double temperature) {
NEW
139
        this.temperature = temperature;
×
NEW
140
    }
×
141

142
    /**
143
     * Gets the top-P.
144
     * @return The top-P.
145
     */
146
    public double getTopP() {
NEW
147
        return topP;
×
148
    }
149

150
    /**
151
     * Sets the top-P.
152
     * @param topP The top-P.
153
     */
154
    public void setTopP(double topP) {
NEW
155
        this.topP = topP;
×
NEW
156
    }
×
157

158
    @Override
159
    void parseJSONMember(JsonObject.Member member) {
160
        super.parseJSONMember(member);
1✔
161
        String memberName = member.getName();
1✔
162
        switch (memberName) {
1✔
163
            case "frequency_penalty":
164
                this.frequencyPenalty = member.getValue().asDouble();
1✔
165
                break;
1✔
166
            case "presence_penalty":
167
                this.presencePenalty = member.getValue().asDouble();
1✔
168
                break;
1✔
169
            case "stop":
170
                this.stop = member.getValue().asString();
1✔
171
                break;
1✔
172
            case "temperature":
173
                this.temperature = member.getValue().asDouble();
1✔
174
                break;
1✔
175
            case "top_p":
176
                this.topP = member.getValue().asDouble();
1✔
177
                break;
1✔
178
            default:
179
                break;
180
        }
181
    }
1✔
182

183
    public JsonObject getJSONObject() {
184
        JsonObject jsonObject = new JsonObject();
1✔
185
        JsonUtils.addIfNotNull(jsonObject, "type", this.getType());
1✔
186
        JsonUtils.addIfNotNull(jsonObject, "frequency_penalty", this.frequencyPenalty);
1✔
187
        JsonUtils.addIfNotNull(jsonObject, "presence_penalty", this.presencePenalty);
1✔
188
        JsonUtils.addIfNotNull(jsonObject, "stop", this.stop);
1✔
189
        JsonUtils.addIfNotNull(jsonObject, "temperature", this.temperature);
1✔
190
        JsonUtils.addIfNotNull(jsonObject, "top_p", this.topP);
1✔
191
        return jsonObject;
1✔
192
    }
193
}
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