Skip to content

Commit a7fe95f

Browse files
feat: Add aiAgent info to AiResponse (box/box-openapi#485) (#93)
1 parent f9d37a5 commit a7fe95f

File tree

6 files changed

+224
-6
lines changed

6 files changed

+224
-6
lines changed

.codegen.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "engineHash": "f073ce3", "specHash": "544d370", "version": "0.2.0" }
1+
{ "engineHash": "a839036", "specHash": "d7dfe68", "version": "0.2.0" }

docs/ai.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ The response depends on the agent configuration requested in this endpoint.
103103
## Extract metadata (freeform)
104104

105105
Sends an AI request to supported Large Language Models (LLMs) and extracts metadata in form of key-value pairs.
106-
Freeform metadata extraction does not require any metadata template setup before sending the request.
106+
In this request, both the prompt and the output can be freeform.
107+
Metadata template setup before sending the request is not required.
107108

108109
This operation is performed by calling function `createAiExtract`.
109110

@@ -133,7 +134,8 @@ A response including the answer from the LLM.
133134
## Extract metadata (structured)
134135

135136
Sends an AI request to supported Large Language Models (LLMs) and returns extracted metadata as a set of key-value pairs.
136-
For this request, you need to use an already defined metadata template or a define a schema yourself.
137+
For this request, you either need a metadata template or a list of fields you want to extract.
138+
Input is **either** a metadata template or a list of fields to ensure the structure.
137139
To learn more about creating templates, see [Creating metadata templates in the Admin Console](https://support.box.com/hc/en-us/articles/360044194033-Customizing-Metadata-Templates)
138140
or use the [metadata template API](g://metadata/templates/create).
139141

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
package com.box.sdkgen.schemas.aiagentinfo;
2+
3+
import com.box.sdkgen.internal.SerializableObject;
4+
import java.util.List;
5+
import java.util.Objects;
6+
7+
public class AiAgentInfo extends SerializableObject {
8+
9+
protected List<AiAgentInfoModelsField> models;
10+
11+
protected String processor;
12+
13+
public AiAgentInfo() {
14+
super();
15+
}
16+
17+
protected AiAgentInfo(AiAgentInfoBuilder builder) {
18+
super();
19+
this.models = builder.models;
20+
this.processor = builder.processor;
21+
}
22+
23+
public List<AiAgentInfoModelsField> getModels() {
24+
return models;
25+
}
26+
27+
public String getProcessor() {
28+
return processor;
29+
}
30+
31+
@Override
32+
public boolean equals(Object o) {
33+
if (this == o) {
34+
return true;
35+
}
36+
if (o == null || getClass() != o.getClass()) {
37+
return false;
38+
}
39+
AiAgentInfo casted = (AiAgentInfo) o;
40+
return Objects.equals(models, casted.models) && Objects.equals(processor, casted.processor);
41+
}
42+
43+
@Override
44+
public int hashCode() {
45+
return Objects.hash(models, processor);
46+
}
47+
48+
@Override
49+
public String toString() {
50+
return "AiAgentInfo{"
51+
+ "models='"
52+
+ models
53+
+ '\''
54+
+ ", "
55+
+ "processor='"
56+
+ processor
57+
+ '\''
58+
+ "}";
59+
}
60+
61+
public static class AiAgentInfoBuilder {
62+
63+
protected List<AiAgentInfoModelsField> models;
64+
65+
protected String processor;
66+
67+
public AiAgentInfoBuilder models(List<AiAgentInfoModelsField> models) {
68+
this.models = models;
69+
return this;
70+
}
71+
72+
public AiAgentInfoBuilder processor(String processor) {
73+
this.processor = processor;
74+
return this;
75+
}
76+
77+
public AiAgentInfo build() {
78+
return new AiAgentInfo(this);
79+
}
80+
}
81+
}
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
package com.box.sdkgen.schemas.aiagentinfo;
2+
3+
import com.box.sdkgen.internal.SerializableObject;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
5+
import java.util.Objects;
6+
7+
public class AiAgentInfoModelsField extends SerializableObject {
8+
9+
protected String name;
10+
11+
protected String provider;
12+
13+
@JsonProperty("supported_purpose")
14+
protected String supportedPurpose;
15+
16+
public AiAgentInfoModelsField() {
17+
super();
18+
}
19+
20+
protected AiAgentInfoModelsField(AiAgentInfoModelsFieldBuilder builder) {
21+
super();
22+
this.name = builder.name;
23+
this.provider = builder.provider;
24+
this.supportedPurpose = builder.supportedPurpose;
25+
}
26+
27+
public String getName() {
28+
return name;
29+
}
30+
31+
public String getProvider() {
32+
return provider;
33+
}
34+
35+
public String getSupportedPurpose() {
36+
return supportedPurpose;
37+
}
38+
39+
@Override
40+
public boolean equals(Object o) {
41+
if (this == o) {
42+
return true;
43+
}
44+
if (o == null || getClass() != o.getClass()) {
45+
return false;
46+
}
47+
AiAgentInfoModelsField casted = (AiAgentInfoModelsField) o;
48+
return Objects.equals(name, casted.name)
49+
&& Objects.equals(provider, casted.provider)
50+
&& Objects.equals(supportedPurpose, casted.supportedPurpose);
51+
}
52+
53+
@Override
54+
public int hashCode() {
55+
return Objects.hash(name, provider, supportedPurpose);
56+
}
57+
58+
@Override
59+
public String toString() {
60+
return "AiAgentInfoModelsField{"
61+
+ "name='"
62+
+ name
63+
+ '\''
64+
+ ", "
65+
+ "provider='"
66+
+ provider
67+
+ '\''
68+
+ ", "
69+
+ "supportedPurpose='"
70+
+ supportedPurpose
71+
+ '\''
72+
+ "}";
73+
}
74+
75+
public static class AiAgentInfoModelsFieldBuilder {
76+
77+
protected String name;
78+
79+
protected String provider;
80+
81+
protected String supportedPurpose;
82+
83+
public AiAgentInfoModelsFieldBuilder name(String name) {
84+
this.name = name;
85+
return this;
86+
}
87+
88+
public AiAgentInfoModelsFieldBuilder provider(String provider) {
89+
this.provider = provider;
90+
return this;
91+
}
92+
93+
public AiAgentInfoModelsFieldBuilder supportedPurpose(String supportedPurpose) {
94+
this.supportedPurpose = supportedPurpose;
95+
return this;
96+
}
97+
98+
public AiAgentInfoModelsField build() {
99+
return new AiAgentInfoModelsField(this);
100+
}
101+
}
102+
}

src/main/java/com/box/sdkgen/schemas/airesponse/AiResponse.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.box.sdkgen.schemas.airesponse;
22

33
import com.box.sdkgen.internal.SerializableObject;
4+
import com.box.sdkgen.schemas.aiagentinfo.AiAgentInfo;
45
import com.fasterxml.jackson.annotation.JsonProperty;
56
import java.util.Objects;
67

@@ -14,6 +15,9 @@ public class AiResponse extends SerializableObject {
1415
@JsonProperty("completion_reason")
1516
protected String completionReason;
1617

18+
@JsonProperty("ai_agent_info")
19+
protected AiAgentInfo aiAgentInfo;
20+
1721
public AiResponse(
1822
@JsonProperty("answer") String answer, @JsonProperty("created_at") String createdAt) {
1923
super();
@@ -26,6 +30,7 @@ protected AiResponse(AiResponseBuilder builder) {
2630
this.answer = builder.answer;
2731
this.createdAt = builder.createdAt;
2832
this.completionReason = builder.completionReason;
33+
this.aiAgentInfo = builder.aiAgentInfo;
2934
}
3035

3136
public String getAnswer() {
@@ -40,6 +45,10 @@ public String getCompletionReason() {
4045
return completionReason;
4146
}
4247

48+
public AiAgentInfo getAiAgentInfo() {
49+
return aiAgentInfo;
50+
}
51+
4352
@Override
4453
public boolean equals(Object o) {
4554
if (this == o) {
@@ -51,12 +60,13 @@ public boolean equals(Object o) {
5160
AiResponse casted = (AiResponse) o;
5261
return Objects.equals(answer, casted.answer)
5362
&& Objects.equals(createdAt, casted.createdAt)
54-
&& Objects.equals(completionReason, casted.completionReason);
63+
&& Objects.equals(completionReason, casted.completionReason)
64+
&& Objects.equals(aiAgentInfo, casted.aiAgentInfo);
5565
}
5666

5767
@Override
5868
public int hashCode() {
59-
return Objects.hash(answer, createdAt, completionReason);
69+
return Objects.hash(answer, createdAt, completionReason, aiAgentInfo);
6070
}
6171

6272
@Override
@@ -73,6 +83,10 @@ public String toString() {
7383
+ "completionReason='"
7484
+ completionReason
7585
+ '\''
86+
+ ", "
87+
+ "aiAgentInfo='"
88+
+ aiAgentInfo
89+
+ '\''
7690
+ "}";
7791
}
7892

@@ -84,6 +98,8 @@ public static class AiResponseBuilder {
8498

8599
protected String completionReason;
86100

101+
protected AiAgentInfo aiAgentInfo;
102+
87103
public AiResponseBuilder(String answer, String createdAt) {
88104
this.answer = answer;
89105
this.createdAt = createdAt;
@@ -94,6 +110,11 @@ public AiResponseBuilder completionReason(String completionReason) {
94110
return this;
95111
}
96112

113+
public AiResponseBuilder aiAgentInfo(AiAgentInfo aiAgentInfo) {
114+
this.aiAgentInfo = aiAgentInfo;
115+
return this;
116+
}
117+
97118
public AiResponse build() {
98119
return new AiResponse(this);
99120
}

src/main/java/com/box/sdkgen/schemas/airesponsefull/AiResponseFull.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.box.sdkgen.schemas.airesponsefull;
22

3+
import com.box.sdkgen.schemas.aiagentinfo.AiAgentInfo;
34
import com.box.sdkgen.schemas.aicitation.AiCitation;
45
import com.box.sdkgen.schemas.airesponse.AiResponse;
56
import com.fasterxml.jackson.annotation.JsonProperty;
@@ -36,12 +37,13 @@ public boolean equals(Object o) {
3637
return Objects.equals(answer, casted.answer)
3738
&& Objects.equals(createdAt, casted.createdAt)
3839
&& Objects.equals(completionReason, casted.completionReason)
40+
&& Objects.equals(aiAgentInfo, casted.aiAgentInfo)
3941
&& Objects.equals(citations, casted.citations);
4042
}
4143

4244
@Override
4345
public int hashCode() {
44-
return Objects.hash(answer, createdAt, completionReason, citations);
46+
return Objects.hash(answer, createdAt, completionReason, aiAgentInfo, citations);
4547
}
4648

4749
@Override
@@ -59,6 +61,10 @@ public String toString() {
5961
+ completionReason
6062
+ '\''
6163
+ ", "
64+
+ "aiAgentInfo='"
65+
+ aiAgentInfo
66+
+ '\''
67+
+ ", "
6268
+ "citations='"
6369
+ citations
6470
+ '\''
@@ -84,6 +90,12 @@ public AiResponseFullBuilder completionReason(String completionReason) {
8490
return this;
8591
}
8692

93+
@Override
94+
public AiResponseFullBuilder aiAgentInfo(AiAgentInfo aiAgentInfo) {
95+
this.aiAgentInfo = aiAgentInfo;
96+
return this;
97+
}
98+
8799
public AiResponseFull build() {
88100
return new AiResponseFull(this);
89101
}

0 commit comments

Comments
 (0)