Skip to content

Commit d9664fd

Browse files
feat: Add new parameters to Box AI methods and introduce AiResponseFull variant (box/box-openapi#446) (#313)
1 parent 5d7e3d6 commit d9664fd

14 files changed

+603
-187
lines changed

.codegen.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "engineHash": "98d8b60", "specHash": "9919482", "version": "1.4.0" }
1+
{ "engineHash": "4ca165c", "specHash": "8d1ca31", "version": "1.3.0" }

docs/ai.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ await client.ai.createAiAsk({
4343

4444
### Returns
4545

46-
This function returns a value of type `AiResponse`.
46+
This function returns a value of type `AiResponseFull`.
4747

4848
A successful response including the answer from the LLM.
4949

@@ -74,12 +74,12 @@ await client.ai.createAiTextGen({
7474
prompt: 'What does the earth go around?',
7575
answer: 'The sun',
7676
createdAt: dateTimeFromString('2021-01-01T00:00:00Z'),
77-
} satisfies AiTextGenDialogueHistoryField,
77+
} satisfies AiDialogueHistory,
7878
{
7979
prompt: 'On Earth, where does the sun rise?',
8080
answer: 'East',
8181
createdAt: dateTimeFromString('2021-01-01T00:00:00Z'),
82-
} satisfies AiTextGenDialogueHistoryField,
82+
} satisfies AiDialogueHistory,
8383
],
8484
} satisfies AiTextGen);
8585
```

docs/integrationMappings.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# IntegrationMappingsManager
22

33
- [List Slack integration mappings](#list-slack-integration-mappings)
4-
- [Create Slack integration mapping](#create-slack-integration-mapping)
4+
- [Create integration mapping](#create-integration-mapping)
55
- [Update Slack integration mapping](#update-slack-integration-mapping)
66
- [Delete Slack integration mapping](#delete-slack-integration-mapping)
77

@@ -38,7 +38,7 @@ This function returns a value of type `IntegrationMappings`.
3838

3939
Returns a collection of integration mappings
4040

41-
## Create Slack integration mapping
41+
## Create integration mapping
4242

4343
Creates a [Slack integration mapping](https://support.box.com/hc/en-us/articles/4415585987859-Box-as-the-Content-Layer-for-Slack)
4444
by mapping a Slack channel to a Box item.

package-lock.json

+138-90
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/managers/ai.generated.ts

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1-
import { serializeAiResponse } from '../schemas/aiResponse.generated.js';
2-
import { deserializeAiResponse } from '../schemas/aiResponse.generated.js';
1+
import { serializeAiResponseFull } from '../schemas/aiResponseFull.generated.js';
2+
import { deserializeAiResponseFull } from '../schemas/aiResponseFull.generated.js';
33
import { serializeClientError } from '../schemas/clientError.generated.js';
44
import { deserializeClientError } from '../schemas/clientError.generated.js';
55
import { serializeAiAsk } from '../schemas/aiAsk.generated.js';
66
import { deserializeAiAsk } from '../schemas/aiAsk.generated.js';
7+
import { serializeAiResponse } from '../schemas/aiResponse.generated.js';
8+
import { deserializeAiResponse } from '../schemas/aiResponse.generated.js';
79
import { serializeAiTextGen } from '../schemas/aiTextGen.generated.js';
810
import { deserializeAiTextGen } from '../schemas/aiTextGen.generated.js';
911
import { serializeAiAgentAskOrAiAgentTextGen } from '../schemas/aiAgentAskOrAiAgentTextGen.generated.js';
1012
import { deserializeAiAgentAskOrAiAgentTextGen } from '../schemas/aiAgentAskOrAiAgentTextGen.generated.js';
11-
import { AiResponse } from '../schemas/aiResponse.generated.js';
13+
import { AiResponseFull } from '../schemas/aiResponseFull.generated.js';
1214
import { ClientError } from '../schemas/clientError.generated.js';
1315
import { AiAsk } from '../schemas/aiAsk.generated.js';
16+
import { AiResponse } from '../schemas/aiResponse.generated.js';
1417
import { AiTextGen } from '../schemas/aiTextGen.generated.js';
1518
import { AiAgentAskOrAiAgentTextGen } from '../schemas/aiAgentAskOrAiAgentTextGen.generated.js';
1619
import { Authentication } from '../networking/auth.generated.js';
@@ -203,12 +206,12 @@ export class AiManager {
203206
* Sends an AI request to supported LLMs and returns an answer specifically focused on the user's question given the provided context.
204207
* @param {AiAsk} requestBody Request body of createAiAsk method
205208
* @param {CreateAiAskOptionalsInput} optionalsInput
206-
* @returns {Promise<AiResponse>}
209+
* @returns {Promise<AiResponseFull>}
207210
*/
208211
async createAiAsk(
209212
requestBody: AiAsk,
210213
optionalsInput: CreateAiAskOptionalsInput = {}
211-
): Promise<AiResponse> {
214+
): Promise<AiResponseFull> {
212215
const optionals: CreateAiAskOptionals = new CreateAiAskOptionals({
213216
headers: optionalsInput.headers,
214217
cancellationToken: optionalsInput.cancellationToken,
@@ -231,7 +234,7 @@ export class AiManager {
231234
cancellationToken: cancellationToken,
232235
} satisfies FetchOptions
233236
)) as FetchResponse;
234-
return deserializeAiResponse(response.data);
237+
return deserializeAiResponseFull(response.data);
235238
}
236239
/**
237240
* Sends an AI request to supported LLMs and returns an answer specifically focused on the creation of new text.

src/networking/version.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const sdkVersion = '1.4.0';
1+
export const sdkVersion = '1.3.0';

src/schemas/aiAgentAsk.generated.ts

+89-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,35 @@ import { sdIsString } from '../serialization/json.js';
1313
import { sdIsList } from '../serialization/json.js';
1414
import { sdIsMap } from '../serialization/json.js';
1515
export type AiAgentAskTypeField = 'ai_agent_ask';
16-
export interface AiAgentAsk {
16+
export class AiAgentAsk {
17+
/**
18+
* The type of AI agent used to handle queries. */
19+
readonly type: AiAgentAskTypeField = 'ai_agent_ask' as AiAgentAskTypeField;
20+
readonly longText?: AiAgentLongTextTool;
21+
readonly basicText?: AiAgentBasicTextToolAsk;
22+
readonly longTextMulti?: AiAgentLongTextTool;
23+
readonly basicTextMulti?: AiAgentBasicTextToolAsk;
24+
constructor(
25+
fields: Omit<AiAgentAsk, 'type'> & Partial<Pick<AiAgentAsk, 'type'>>
26+
) {
27+
if (fields.type) {
28+
this.type = fields.type;
29+
}
30+
if (fields.longText) {
31+
this.longText = fields.longText;
32+
}
33+
if (fields.basicText) {
34+
this.basicText = fields.basicText;
35+
}
36+
if (fields.longTextMulti) {
37+
this.longTextMulti = fields.longTextMulti;
38+
}
39+
if (fields.basicTextMulti) {
40+
this.basicTextMulti = fields.basicTextMulti;
41+
}
42+
}
43+
}
44+
export interface AiAgentAskInput {
1745
/**
1846
* The type of AI agent used to handle queries. */
1947
readonly type?: AiAgentAskTypeField;
@@ -37,8 +65,7 @@ export function deserializeAiAgentAskTypeField(
3765
}
3866
export function serializeAiAgentAsk(val: AiAgentAsk): SerializedData {
3967
return {
40-
['type']:
41-
val.type == void 0 ? void 0 : serializeAiAgentAskTypeField(val.type),
68+
['type']: serializeAiAgentAskTypeField(val.type),
4269
['long_text']:
4370
val.longText == void 0
4471
? void 0
@@ -61,6 +88,64 @@ export function deserializeAiAgentAsk(val: SerializedData): AiAgentAsk {
6188
if (!sdIsMap(val)) {
6289
throw new BoxSdkError({ message: 'Expecting a map for "AiAgentAsk"' });
6390
}
91+
if (val.type == void 0) {
92+
throw new BoxSdkError({
93+
message: 'Expecting "type" of type "AiAgentAsk" to be defined',
94+
});
95+
}
96+
const type: AiAgentAskTypeField = deserializeAiAgentAskTypeField(val.type);
97+
const longText: undefined | AiAgentLongTextTool =
98+
val.long_text == void 0
99+
? void 0
100+
: deserializeAiAgentLongTextTool(val.long_text);
101+
const basicText: undefined | AiAgentBasicTextToolAsk =
102+
val.basic_text == void 0
103+
? void 0
104+
: deserializeAiAgentBasicTextToolAsk(val.basic_text);
105+
const longTextMulti: undefined | AiAgentLongTextTool =
106+
val.long_text_multi == void 0
107+
? void 0
108+
: deserializeAiAgentLongTextTool(val.long_text_multi);
109+
const basicTextMulti: undefined | AiAgentBasicTextToolAsk =
110+
val.basic_text_multi == void 0
111+
? void 0
112+
: deserializeAiAgentBasicTextToolAsk(val.basic_text_multi);
113+
return {
114+
type: type,
115+
longText: longText,
116+
basicText: basicText,
117+
longTextMulti: longTextMulti,
118+
basicTextMulti: basicTextMulti,
119+
} satisfies AiAgentAsk;
120+
}
121+
export function serializeAiAgentAskInput(val: AiAgentAskInput): SerializedData {
122+
return {
123+
['type']:
124+
val.type == void 0 ? void 0 : serializeAiAgentAskTypeField(val.type),
125+
['long_text']:
126+
val.longText == void 0
127+
? void 0
128+
: serializeAiAgentLongTextTool(val.longText),
129+
['basic_text']:
130+
val.basicText == void 0
131+
? void 0
132+
: serializeAiAgentBasicTextToolAsk(val.basicText),
133+
['long_text_multi']:
134+
val.longTextMulti == void 0
135+
? void 0
136+
: serializeAiAgentLongTextTool(val.longTextMulti),
137+
['basic_text_multi']:
138+
val.basicTextMulti == void 0
139+
? void 0
140+
: serializeAiAgentBasicTextToolAsk(val.basicTextMulti),
141+
};
142+
}
143+
export function deserializeAiAgentAskInput(
144+
val: SerializedData
145+
): AiAgentAskInput {
146+
if (!sdIsMap(val)) {
147+
throw new BoxSdkError({ message: 'Expecting a map for "AiAgentAskInput"' });
148+
}
64149
const type: undefined | AiAgentAskTypeField =
65150
val.type == void 0 ? void 0 : deserializeAiAgentAskTypeField(val.type);
66151
const longText: undefined | AiAgentLongTextTool =
@@ -85,5 +170,5 @@ export function deserializeAiAgentAsk(val: SerializedData): AiAgentAsk {
85170
basicText: basicText,
86171
longTextMulti: longTextMulti,
87172
basicTextMulti: basicTextMulti,
88-
} satisfies AiAgentAsk;
173+
} satisfies AiAgentAskInput;
89174
}

src/schemas/aiAgentTextGen.generated.ts

+54-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,24 @@ import { sdIsString } from '../serialization/json.js';
1010
import { sdIsList } from '../serialization/json.js';
1111
import { sdIsMap } from '../serialization/json.js';
1212
export type AiAgentTextGenTypeField = 'ai_agent_text_gen';
13-
export interface AiAgentTextGen {
13+
export class AiAgentTextGen {
14+
/**
15+
* The type of AI agent used for generating text. */
16+
readonly type: AiAgentTextGenTypeField =
17+
'ai_agent_text_gen' as AiAgentTextGenTypeField;
18+
readonly basicGen?: AiAgentBasicGenTool;
19+
constructor(
20+
fields: Omit<AiAgentTextGen, 'type'> & Partial<Pick<AiAgentTextGen, 'type'>>
21+
) {
22+
if (fields.type) {
23+
this.type = fields.type;
24+
}
25+
if (fields.basicGen) {
26+
this.basicGen = fields.basicGen;
27+
}
28+
}
29+
}
30+
export interface AiAgentTextGenInput {
1431
/**
1532
* The type of AI agent used for generating text. */
1633
readonly type?: AiAgentTextGenTypeField;
@@ -33,8 +50,7 @@ export function deserializeAiAgentTextGenTypeField(
3350
}
3451
export function serializeAiAgentTextGen(val: AiAgentTextGen): SerializedData {
3552
return {
36-
['type']:
37-
val.type == void 0 ? void 0 : serializeAiAgentTextGenTypeField(val.type),
53+
['type']: serializeAiAgentTextGenTypeField(val.type),
3854
['basic_gen']:
3955
val.basicGen == void 0
4056
? void 0
@@ -45,11 +61,45 @@ export function deserializeAiAgentTextGen(val: SerializedData): AiAgentTextGen {
4561
if (!sdIsMap(val)) {
4662
throw new BoxSdkError({ message: 'Expecting a map for "AiAgentTextGen"' });
4763
}
64+
if (val.type == void 0) {
65+
throw new BoxSdkError({
66+
message: 'Expecting "type" of type "AiAgentTextGen" to be defined',
67+
});
68+
}
69+
const type: AiAgentTextGenTypeField = deserializeAiAgentTextGenTypeField(
70+
val.type
71+
);
72+
const basicGen: undefined | AiAgentBasicGenTool =
73+
val.basic_gen == void 0
74+
? void 0
75+
: deserializeAiAgentBasicGenTool(val.basic_gen);
76+
return { type: type, basicGen: basicGen } satisfies AiAgentTextGen;
77+
}
78+
export function serializeAiAgentTextGenInput(
79+
val: AiAgentTextGenInput
80+
): SerializedData {
81+
return {
82+
['type']:
83+
val.type == void 0 ? void 0 : serializeAiAgentTextGenTypeField(val.type),
84+
['basic_gen']:
85+
val.basicGen == void 0
86+
? void 0
87+
: serializeAiAgentBasicGenTool(val.basicGen),
88+
};
89+
}
90+
export function deserializeAiAgentTextGenInput(
91+
val: SerializedData
92+
): AiAgentTextGenInput {
93+
if (!sdIsMap(val)) {
94+
throw new BoxSdkError({
95+
message: 'Expecting a map for "AiAgentTextGenInput"',
96+
});
97+
}
4898
const type: undefined | AiAgentTextGenTypeField =
4999
val.type == void 0 ? void 0 : deserializeAiAgentTextGenTypeField(val.type);
50100
const basicGen: undefined | AiAgentBasicGenTool =
51101
val.basic_gen == void 0
52102
? void 0
53103
: deserializeAiAgentBasicGenTool(val.basic_gen);
54-
return { type: type, basicGen: basicGen } satisfies AiAgentTextGen;
104+
return { type: type, basicGen: basicGen } satisfies AiAgentTextGenInput;
55105
}

src/schemas/aiAsk.generated.ts

+46
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
import { serializeAiDialogueHistory } from './aiDialogueHistory.generated.js';
2+
import { deserializeAiDialogueHistory } from './aiDialogueHistory.generated.js';
13
import { serializeAiAgentAsk } from './aiAgentAsk.generated.js';
24
import { deserializeAiAgentAsk } from './aiAgentAsk.generated.js';
5+
import { AiDialogueHistory } from './aiDialogueHistory.generated.js';
36
import { AiAgentAsk } from './aiAgentAsk.generated.js';
47
import { BoxSdkError } from '../box/errors.js';
58
import { SerializedData } from '../serialization/json.js';
@@ -61,6 +64,12 @@ export interface AiAsk {
6164
* If the file size exceeds 1MB, the first 1MB of text representation will be processed.
6265
* If you set `mode` parameter to `single_item_qa`, the `items` array can have one element only. */
6366
readonly items: readonly AiAskItemsField[];
67+
/**
68+
* The history of prompts and answers previously passed to the LLM. This provides additional context to the LLM in generating the response. */
69+
readonly dialogueHistory?: readonly AiDialogueHistory[];
70+
/**
71+
* A flag to indicate whether citations should be returned. */
72+
readonly includeCitations?: boolean;
6473
readonly aiAgent?: AiAgentAsk;
6574
}
6675
export function serializeAiAskModeField(val: AiAskModeField): SerializedData {
@@ -178,6 +187,16 @@ export function serializeAiAsk(val: AiAsk): SerializedData {
178187
['items']: val.items.map(function (item: AiAskItemsField): SerializedData {
179188
return serializeAiAskItemsField(item);
180189
}) as readonly any[],
190+
['dialogue_history']:
191+
val.dialogueHistory == void 0
192+
? void 0
193+
: (val.dialogueHistory.map(function (
194+
item: AiDialogueHistory
195+
): SerializedData {
196+
return serializeAiDialogueHistory(item);
197+
}) as readonly any[]),
198+
['include_citations']:
199+
val.includeCitations == void 0 ? void 0 : val.includeCitations,
181200
['ai_agent']:
182201
val.aiAgent == void 0 ? void 0 : serializeAiAgentAsk(val.aiAgent),
183202
};
@@ -218,12 +237,39 @@ export function deserializeAiAsk(val: SerializedData): AiAsk {
218237
return deserializeAiAskItemsField(itm);
219238
}) as readonly any[])
220239
: [];
240+
if (!(val.dialogue_history == void 0) && !sdIsList(val.dialogue_history)) {
241+
throw new BoxSdkError({
242+
message: 'Expecting array for "dialogue_history" of type "AiAsk"',
243+
});
244+
}
245+
const dialogueHistory: undefined | readonly AiDialogueHistory[] =
246+
val.dialogue_history == void 0
247+
? void 0
248+
: sdIsList(val.dialogue_history)
249+
? (val.dialogue_history.map(function (
250+
itm: SerializedData
251+
): AiDialogueHistory {
252+
return deserializeAiDialogueHistory(itm);
253+
}) as readonly any[])
254+
: [];
255+
if (
256+
!(val.include_citations == void 0) &&
257+
!sdIsBoolean(val.include_citations)
258+
) {
259+
throw new BoxSdkError({
260+
message: 'Expecting boolean for "include_citations" of type "AiAsk"',
261+
});
262+
}
263+
const includeCitations: undefined | boolean =
264+
val.include_citations == void 0 ? void 0 : val.include_citations;
221265
const aiAgent: undefined | AiAgentAsk =
222266
val.ai_agent == void 0 ? void 0 : deserializeAiAgentAsk(val.ai_agent);
223267
return {
224268
mode: mode,
225269
prompt: prompt,
226270
items: items,
271+
dialogueHistory: dialogueHistory,
272+
includeCitations: includeCitations,
227273
aiAgent: aiAgent,
228274
} satisfies AiAsk;
229275
}

0 commit comments

Comments
 (0)