@@ -6,10 +6,13 @@ import { serializeAiAsk } from '../schemas/aiAsk.generated.js';
6
6
import { deserializeAiAsk } from '../schemas/aiAsk.generated.js' ;
7
7
import { serializeAiTextGen } from '../schemas/aiTextGen.generated.js' ;
8
8
import { deserializeAiTextGen } from '../schemas/aiTextGen.generated.js' ;
9
+ import { serializeAiAgentAskOrAiAgentTextGen } from '../schemas/aiAgentAskOrAiAgentTextGen.generated.js' ;
10
+ import { deserializeAiAgentAskOrAiAgentTextGen } from '../schemas/aiAgentAskOrAiAgentTextGen.generated.js' ;
9
11
import { AiResponse } from '../schemas/aiResponse.generated.js' ;
10
12
import { ClientError } from '../schemas/clientError.generated.js' ;
11
13
import { AiAsk } from '../schemas/aiAsk.generated.js' ;
12
14
import { AiTextGen } from '../schemas/aiTextGen.generated.js' ;
15
+ import { AiAgentAskOrAiAgentTextGen } from '../schemas/aiAgentAskOrAiAgentTextGen.generated.js' ;
13
16
import { Authentication } from '../networking/auth.generated.js' ;
14
17
import { NetworkSession } from '../networking/network.generated.js' ;
15
18
import { prepareParams } from '../internal/utils.js' ;
@@ -20,6 +23,8 @@ import { FetchOptions } from '../networking/fetch.js';
20
23
import { FetchResponse } from '../networking/fetch.js' ;
21
24
import { fetch } from '../networking/fetch.js' ;
22
25
import { SerializedData } from '../serialization/json.js' ;
26
+ import { sdToJson } from '../serialization/json.js' ;
27
+ import { BoxSdkError } from '../box/errors.js' ;
23
28
import { sdIsEmpty } from '../serialization/json.js' ;
24
29
import { sdIsBoolean } from '../serialization/json.js' ;
25
30
import { sdIsNumber } from '../serialization/json.js' ;
@@ -64,6 +69,31 @@ export interface CreateAiTextGenOptionalsInput {
64
69
readonly headers ?: CreateAiTextGenHeaders ;
65
70
readonly cancellationToken ?: undefined | CancellationToken ;
66
71
}
72
+ export class GetAiAgentDefaultConfigOptionals {
73
+ readonly headers : GetAiAgentDefaultConfigHeaders =
74
+ new GetAiAgentDefaultConfigHeaders ( { } ) ;
75
+ readonly cancellationToken ?: CancellationToken = void 0 ;
76
+ constructor (
77
+ fields : Omit <
78
+ GetAiAgentDefaultConfigOptionals ,
79
+ 'headers' | 'cancellationToken'
80
+ > &
81
+ Partial <
82
+ Pick < GetAiAgentDefaultConfigOptionals , 'headers' | 'cancellationToken' >
83
+ >
84
+ ) {
85
+ if ( fields . headers ) {
86
+ this . headers = fields . headers ;
87
+ }
88
+ if ( fields . cancellationToken ) {
89
+ this . cancellationToken = fields . cancellationToken ;
90
+ }
91
+ }
92
+ }
93
+ export interface GetAiAgentDefaultConfigOptionalsInput {
94
+ readonly headers ?: GetAiAgentDefaultConfigHeaders ;
95
+ readonly cancellationToken ?: undefined | CancellationToken ;
96
+ }
67
97
export class CreateAiAskHeaders {
68
98
readonly extraHeaders ?: {
69
99
readonly [ key : string ] : undefined | string ;
@@ -104,13 +134,42 @@ export interface CreateAiTextGenHeadersInput {
104
134
readonly [ key : string ] : undefined | string ;
105
135
} ;
106
136
}
137
+ export type GetAiAgentDefaultConfigQueryParamsModeField = 'ask' | 'text_gen' ;
138
+ export interface GetAiAgentDefaultConfigQueryParams {
139
+ readonly mode : GetAiAgentDefaultConfigQueryParamsModeField ;
140
+ readonly language ?: string ;
141
+ readonly model ?: string ;
142
+ }
143
+ export class GetAiAgentDefaultConfigHeaders {
144
+ readonly extraHeaders ?: {
145
+ readonly [ key : string ] : undefined | string ;
146
+ } = { } ;
147
+ constructor (
148
+ fields : Omit < GetAiAgentDefaultConfigHeaders , 'extraHeaders' > &
149
+ Partial < Pick < GetAiAgentDefaultConfigHeaders , 'extraHeaders' > >
150
+ ) {
151
+ if ( fields . extraHeaders ) {
152
+ this . extraHeaders = fields . extraHeaders ;
153
+ }
154
+ }
155
+ }
156
+ export interface GetAiAgentDefaultConfigHeadersInput {
157
+ readonly extraHeaders ?:
158
+ | undefined
159
+ | {
160
+ readonly [ key : string ] : undefined | string ;
161
+ } ;
162
+ }
107
163
export class AiManager {
108
164
readonly auth ?: Authentication ;
109
165
readonly networkSession : NetworkSession = new NetworkSession ( { } ) ;
110
166
constructor (
111
167
fields : Omit <
112
168
AiManager ,
113
- 'networkSession' | 'createAiAsk' | 'createAiTextGen'
169
+ | 'networkSession'
170
+ | 'createAiAsk'
171
+ | 'createAiTextGen'
172
+ | 'getAiAgentDefaultConfig'
114
173
> &
115
174
Partial < Pick < AiManager , 'networkSession' > >
116
175
) {
@@ -180,8 +239,64 @@ export class AiManager {
180
239
) ) as FetchResponse ;
181
240
return deserializeAiResponse ( response . data ) ;
182
241
}
242
+ async getAiAgentDefaultConfig (
243
+ queryParams : GetAiAgentDefaultConfigQueryParams ,
244
+ optionalsInput : GetAiAgentDefaultConfigOptionalsInput = { }
245
+ ) : Promise < AiAgentAskOrAiAgentTextGen > {
246
+ const optionals : GetAiAgentDefaultConfigOptionals =
247
+ new GetAiAgentDefaultConfigOptionals ( {
248
+ headers : optionalsInput . headers ,
249
+ cancellationToken : optionalsInput . cancellationToken ,
250
+ } ) ;
251
+ const headers : any = optionals . headers ;
252
+ const cancellationToken : any = optionals . cancellationToken ;
253
+ const queryParamsMap : {
254
+ readonly [ key : string ] : string ;
255
+ } = prepareParams ( {
256
+ [ 'mode' ] : toString ( queryParams . mode ) as string ,
257
+ [ 'language' ] : toString ( queryParams . language ) as string ,
258
+ [ 'model' ] : toString ( queryParams . model ) as string ,
259
+ } ) ;
260
+ const headersMap : {
261
+ readonly [ key : string ] : string ;
262
+ } = prepareParams ( { ...{ } , ...headers . extraHeaders } ) ;
263
+ const response : FetchResponse = ( await fetch (
264
+ '' . concat (
265
+ this . networkSession . baseUrls . baseUrl ,
266
+ '/2.0/ai_agent_default'
267
+ ) as string ,
268
+ {
269
+ method : 'GET' ,
270
+ params : queryParamsMap ,
271
+ headers : headersMap ,
272
+ responseFormat : 'json' ,
273
+ auth : this . auth ,
274
+ networkSession : this . networkSession ,
275
+ cancellationToken : cancellationToken ,
276
+ } satisfies FetchOptions
277
+ ) ) as FetchResponse ;
278
+ return deserializeAiAgentAskOrAiAgentTextGen ( response . data ) ;
279
+ }
183
280
}
184
281
export interface AiManagerInput {
185
282
readonly auth ?: Authentication ;
186
283
readonly networkSession ?: NetworkSession ;
187
284
}
285
+ export function serializeGetAiAgentDefaultConfigQueryParamsModeField (
286
+ val : GetAiAgentDefaultConfigQueryParamsModeField
287
+ ) : SerializedData {
288
+ return val ;
289
+ }
290
+ export function deserializeGetAiAgentDefaultConfigQueryParamsModeField (
291
+ val : SerializedData
292
+ ) : GetAiAgentDefaultConfigQueryParamsModeField {
293
+ if ( val == 'ask' ) {
294
+ return val ;
295
+ }
296
+ if ( val == 'text_gen' ) {
297
+ return val ;
298
+ }
299
+ throw new BoxSdkError ( {
300
+ message : "Can't deserialize GetAiAgentDefaultConfigQueryParamsModeField" ,
301
+ } ) ;
302
+ }
0 commit comments