@@ -16,6 +16,7 @@ import { serializeAiExtractResponse } from '../schemas/aiExtractResponse.generat
16
16
import { deserializeAiExtractResponse } from '../schemas/aiExtractResponse.generated.js' ;
17
17
import { serializeAiExtractStructured } from '../schemas/aiExtractStructured.generated.js' ;
18
18
import { deserializeAiExtractStructured } from '../schemas/aiExtractStructured.generated.js' ;
19
+ import { ResponseFormat } from '../networking/fetchOptions.generated.js' ;
19
20
import { AiResponseFull } from '../schemas/aiResponseFull.generated.js' ;
20
21
import { ClientError } from '../schemas/clientError.generated.js' ;
21
22
import { AiAsk } from '../schemas/aiAsk.generated.js' ;
@@ -31,8 +32,8 @@ import { prepareParams } from '../internal/utils.js';
31
32
import { toString } from '../internal/utils.js' ;
32
33
import { ByteStream } from '../internal/utils.js' ;
33
34
import { CancellationToken } from '../internal/utils.js' ;
34
- import { FetchOptions } from '../networking/fetch .js' ;
35
- import { FetchResponse } from '../networking/fetch .js' ;
35
+ import { FetchOptions } from '../networking/fetchOptions.generated .js' ;
36
+ import { FetchResponse } from '../networking/fetchResponse.generated .js' ;
36
37
import { fetch } from '../networking/fetch.js' ;
37
38
import { SerializedData } from '../serialization/json.js' ;
38
39
import { sdToJson } from '../serialization/json.js' ;
@@ -331,23 +332,25 @@ export class AiManager {
331
332
const headersMap : {
332
333
readonly [ key : string ] : string ;
333
334
} = prepareParams ( { ...{ } , ...headers . extraHeaders } ) ;
334
- const response : FetchResponse = ( await fetch ( {
335
- url : '' . concat (
336
- this . networkSession . baseUrls . baseUrl ,
337
- '/2.0/ai/ask' ,
338
- ) as string ,
339
- method : 'POST' ,
340
- headers : headersMap ,
341
- data : serializeAiAsk ( requestBody ) ,
342
- contentType : 'application/json' ,
343
- responseFormat : 'json' ,
344
- auth : this . auth ,
345
- networkSession : this . networkSession ,
346
- cancellationToken : cancellationToken ,
347
- } satisfies FetchOptions ) ) as FetchResponse ;
335
+ const response : FetchResponse = ( await fetch (
336
+ new FetchOptions ( {
337
+ url : '' . concat (
338
+ this . networkSession . baseUrls . baseUrl ,
339
+ '/2.0/ai/ask' ,
340
+ ) as string ,
341
+ method : 'POST' ,
342
+ headers : headersMap ,
343
+ data : serializeAiAsk ( requestBody ) ,
344
+ contentType : 'application/json' ,
345
+ responseFormat : 'json' as ResponseFormat ,
346
+ auth : this . auth ,
347
+ networkSession : this . networkSession ,
348
+ cancellationToken : cancellationToken ,
349
+ } ) ,
350
+ ) ) as FetchResponse ;
348
351
return {
349
- ...deserializeAiResponseFull ( response . data ) ,
350
- rawData : response . data ,
352
+ ...deserializeAiResponseFull ( response . data ! ) ,
353
+ rawData : response . data ! ,
351
354
} ;
352
355
}
353
356
/**
@@ -369,23 +372,25 @@ export class AiManager {
369
372
const headersMap : {
370
373
readonly [ key : string ] : string ;
371
374
} = prepareParams ( { ...{ } , ...headers . extraHeaders } ) ;
372
- const response : FetchResponse = ( await fetch ( {
373
- url : '' . concat (
374
- this . networkSession . baseUrls . baseUrl ,
375
- '/2.0/ai/text_gen' ,
376
- ) as string ,
377
- method : 'POST' ,
378
- headers : headersMap ,
379
- data : serializeAiTextGen ( requestBody ) ,
380
- contentType : 'application/json' ,
381
- responseFormat : 'json' ,
382
- auth : this . auth ,
383
- networkSession : this . networkSession ,
384
- cancellationToken : cancellationToken ,
385
- } satisfies FetchOptions ) ) as FetchResponse ;
375
+ const response : FetchResponse = ( await fetch (
376
+ new FetchOptions ( {
377
+ url : '' . concat (
378
+ this . networkSession . baseUrls . baseUrl ,
379
+ '/2.0/ai/text_gen' ,
380
+ ) as string ,
381
+ method : 'POST' ,
382
+ headers : headersMap ,
383
+ data : serializeAiTextGen ( requestBody ) ,
384
+ contentType : 'application/json' ,
385
+ responseFormat : 'json' as ResponseFormat ,
386
+ auth : this . auth ,
387
+ networkSession : this . networkSession ,
388
+ cancellationToken : cancellationToken ,
389
+ } ) ,
390
+ ) ) as FetchResponse ;
386
391
return {
387
- ...deserializeAiResponse ( response . data ) ,
388
- rawData : response . data ,
392
+ ...deserializeAiResponse ( response . data ! ) ,
393
+ rawData : response . data ! ,
389
394
} ;
390
395
}
391
396
/**
@@ -415,24 +420,26 @@ export class AiManager {
415
420
const headersMap : {
416
421
readonly [ key : string ] : string ;
417
422
} = prepareParams ( { ...{ } , ...headers . extraHeaders } ) ;
418
- const response : FetchResponse = ( await fetch ( {
419
- url : '' . concat (
420
- this . networkSession . baseUrls . baseUrl ,
421
- '/2.0/ai_agent_default' ,
422
- ) as string ,
423
- method : 'GET' ,
424
- params : queryParamsMap ,
425
- headers : headersMap ,
426
- responseFormat : 'json' ,
427
- auth : this . auth ,
428
- networkSession : this . networkSession ,
429
- cancellationToken : cancellationToken ,
430
- } satisfies FetchOptions ) ) as FetchResponse ;
423
+ const response : FetchResponse = ( await fetch (
424
+ new FetchOptions ( {
425
+ url : '' . concat (
426
+ this . networkSession . baseUrls . baseUrl ,
427
+ '/2.0/ai_agent_default' ,
428
+ ) as string ,
429
+ method : 'GET' ,
430
+ params : queryParamsMap ,
431
+ headers : headersMap ,
432
+ responseFormat : 'json' as ResponseFormat ,
433
+ auth : this . auth ,
434
+ networkSession : this . networkSession ,
435
+ cancellationToken : cancellationToken ,
436
+ } ) ,
437
+ ) ) as FetchResponse ;
431
438
return {
432
439
...deserializeAiAgentAskOrAiAgentExtractOrAiAgentExtractStructuredOrAiAgentTextGen (
433
- response . data ,
440
+ response . data ! ,
434
441
) ,
435
- rawData : response . data ,
442
+ rawData : response . data ! ,
436
443
} ;
437
444
}
438
445
/**
@@ -455,23 +462,25 @@ export class AiManager {
455
462
const headersMap : {
456
463
readonly [ key : string ] : string ;
457
464
} = prepareParams ( { ...{ } , ...headers . extraHeaders } ) ;
458
- const response : FetchResponse = ( await fetch ( {
459
- url : '' . concat (
460
- this . networkSession . baseUrls . baseUrl ,
461
- '/2.0/ai/extract' ,
462
- ) as string ,
463
- method : 'POST' ,
464
- headers : headersMap ,
465
- data : serializeAiExtract ( requestBody ) ,
466
- contentType : 'application/json' ,
467
- responseFormat : 'json' ,
468
- auth : this . auth ,
469
- networkSession : this . networkSession ,
470
- cancellationToken : cancellationToken ,
471
- } satisfies FetchOptions ) ) as FetchResponse ;
465
+ const response : FetchResponse = ( await fetch (
466
+ new FetchOptions ( {
467
+ url : '' . concat (
468
+ this . networkSession . baseUrls . baseUrl ,
469
+ '/2.0/ai/extract' ,
470
+ ) as string ,
471
+ method : 'POST' ,
472
+ headers : headersMap ,
473
+ data : serializeAiExtract ( requestBody ) ,
474
+ contentType : 'application/json' ,
475
+ responseFormat : 'json' as ResponseFormat ,
476
+ auth : this . auth ,
477
+ networkSession : this . networkSession ,
478
+ cancellationToken : cancellationToken ,
479
+ } ) ,
480
+ ) ) as FetchResponse ;
472
481
return {
473
- ...deserializeAiResponse ( response . data ) ,
474
- rawData : response . data ,
482
+ ...deserializeAiResponse ( response . data ! ) ,
483
+ rawData : response . data ! ,
475
484
} ;
476
485
}
477
486
/**
@@ -497,23 +506,25 @@ export class AiManager {
497
506
const headersMap : {
498
507
readonly [ key : string ] : string ;
499
508
} = prepareParams ( { ...{ } , ...headers . extraHeaders } ) ;
500
- const response : FetchResponse = ( await fetch ( {
501
- url : '' . concat (
502
- this . networkSession . baseUrls . baseUrl ,
503
- '/2.0/ai/extract_structured' ,
504
- ) as string ,
505
- method : 'POST' ,
506
- headers : headersMap ,
507
- data : serializeAiExtractStructured ( requestBody ) ,
508
- contentType : 'application/json' ,
509
- responseFormat : 'json' ,
510
- auth : this . auth ,
511
- networkSession : this . networkSession ,
512
- cancellationToken : cancellationToken ,
513
- } satisfies FetchOptions ) ) as FetchResponse ;
509
+ const response : FetchResponse = ( await fetch (
510
+ new FetchOptions ( {
511
+ url : '' . concat (
512
+ this . networkSession . baseUrls . baseUrl ,
513
+ '/2.0/ai/extract_structured' ,
514
+ ) as string ,
515
+ method : 'POST' ,
516
+ headers : headersMap ,
517
+ data : serializeAiExtractStructured ( requestBody ) ,
518
+ contentType : 'application/json' ,
519
+ responseFormat : 'json' as ResponseFormat ,
520
+ auth : this . auth ,
521
+ networkSession : this . networkSession ,
522
+ cancellationToken : cancellationToken ,
523
+ } ) ,
524
+ ) ) as FetchResponse ;
514
525
return {
515
- ...deserializeAiExtractResponse ( response . data ) ,
516
- rawData : response . data ,
526
+ ...deserializeAiExtractResponse ( response . data ! ) ,
527
+ rawData : response . data ! ,
517
528
} ;
518
529
}
519
530
}
0 commit comments