@google/genai 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/genai.d.ts +21 -12
- package/dist/index.js +101 -221
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +102 -221
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.js +101 -221
- package/dist/node/index.js.map +1 -1
- package/dist/node/node.d.ts +21 -12
- package/dist/web/index.mjs +105 -221
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +21 -12
- package/package.json +1 -1
package/dist/node/index.js
CHANGED
|
@@ -378,9 +378,6 @@ function processSchema(apiClient, schema) {
|
|
|
378
378
|
}
|
|
379
379
|
}
|
|
380
380
|
if ('anyOf' in schema) {
|
|
381
|
-
if (!apiClient.isVertexAI()) {
|
|
382
|
-
throw new Error('AnyOf is not supported in the response schema for the Gemini API.');
|
|
383
|
-
}
|
|
384
381
|
if (schema['anyOf'] !== undefined) {
|
|
385
382
|
for (const subSchema of schema['anyOf']) {
|
|
386
383
|
processSchema(apiClient, subSchema);
|
|
@@ -934,17 +931,6 @@ function createPartFromBase64(data, mimeType) {
|
|
|
934
931
|
},
|
|
935
932
|
};
|
|
936
933
|
}
|
|
937
|
-
/**
|
|
938
|
-
* Creates a `Part` object from the `startOffset` and `endOffset` of a `VideoMetadata` object.
|
|
939
|
-
*/
|
|
940
|
-
function createPartFromVideoMetadata(startOffset, endOffset) {
|
|
941
|
-
return {
|
|
942
|
-
videoMetadata: {
|
|
943
|
-
startOffset: startOffset,
|
|
944
|
-
endOffset: endOffset,
|
|
945
|
-
},
|
|
946
|
-
};
|
|
947
|
-
}
|
|
948
934
|
/**
|
|
949
935
|
* Creates a `Part` object from the `outcome` and `output` of a `CodeExecutionResult` object.
|
|
950
936
|
*/
|
|
@@ -1482,7 +1468,7 @@ class Caches extends BaseModule {
|
|
|
1482
1468
|
return httpResponse.json();
|
|
1483
1469
|
});
|
|
1484
1470
|
return response.then((apiResponse) => {
|
|
1485
|
-
const resp = deleteCachedContentResponseFromVertex(
|
|
1471
|
+
const resp = deleteCachedContentResponseFromVertex();
|
|
1486
1472
|
const typedResp = new DeleteCachedContentResponse();
|
|
1487
1473
|
Object.assign(typedResp, resp);
|
|
1488
1474
|
return typedResp;
|
|
@@ -1507,7 +1493,7 @@ class Caches extends BaseModule {
|
|
|
1507
1493
|
return httpResponse.json();
|
|
1508
1494
|
});
|
|
1509
1495
|
return response.then((apiResponse) => {
|
|
1510
|
-
const resp = deleteCachedContentResponseFromMldev(
|
|
1496
|
+
const resp = deleteCachedContentResponseFromMldev();
|
|
1511
1497
|
const typedResp = new DeleteCachedContentResponse();
|
|
1512
1498
|
Object.assign(typedResp, resp);
|
|
1513
1499
|
return typedResp;
|
|
@@ -1780,18 +1766,10 @@ function schemaToVertex$1(apiClient, fromObject) {
|
|
|
1780
1766
|
if (fromPattern != null) {
|
|
1781
1767
|
setValueByPath(toObject, ['pattern'], fromPattern);
|
|
1782
1768
|
}
|
|
1783
|
-
const fromMinimum = getValueByPath(fromObject, ['minimum']);
|
|
1784
|
-
if (fromMinimum != null) {
|
|
1785
|
-
setValueByPath(toObject, ['minimum'], fromMinimum);
|
|
1786
|
-
}
|
|
1787
1769
|
const fromDefault = getValueByPath(fromObject, ['default']);
|
|
1788
1770
|
if (fromDefault != null) {
|
|
1789
1771
|
setValueByPath(toObject, ['default'], fromDefault);
|
|
1790
1772
|
}
|
|
1791
|
-
const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
|
|
1792
|
-
if (fromAnyOf != null) {
|
|
1793
|
-
setValueByPath(toObject, ['anyOf'], fromAnyOf);
|
|
1794
|
-
}
|
|
1795
1773
|
const fromMaxLength = getValueByPath(fromObject, ['maxLength']);
|
|
1796
1774
|
if (fromMaxLength != null) {
|
|
1797
1775
|
setValueByPath(toObject, ['maxLength'], fromMaxLength);
|
|
@@ -1810,16 +1788,16 @@ function schemaToVertex$1(apiClient, fromObject) {
|
|
|
1810
1788
|
if (fromMinProperties != null) {
|
|
1811
1789
|
setValueByPath(toObject, ['minProperties'], fromMinProperties);
|
|
1812
1790
|
}
|
|
1813
|
-
const fromMaximum = getValueByPath(fromObject, ['maximum']);
|
|
1814
|
-
if (fromMaximum != null) {
|
|
1815
|
-
setValueByPath(toObject, ['maximum'], fromMaximum);
|
|
1816
|
-
}
|
|
1817
1791
|
const fromMaxProperties = getValueByPath(fromObject, [
|
|
1818
1792
|
'maxProperties',
|
|
1819
1793
|
]);
|
|
1820
1794
|
if (fromMaxProperties != null) {
|
|
1821
1795
|
setValueByPath(toObject, ['maxProperties'], fromMaxProperties);
|
|
1822
1796
|
}
|
|
1797
|
+
const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
|
|
1798
|
+
if (fromAnyOf != null) {
|
|
1799
|
+
setValueByPath(toObject, ['anyOf'], fromAnyOf);
|
|
1800
|
+
}
|
|
1823
1801
|
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
1824
1802
|
if (fromDescription != null) {
|
|
1825
1803
|
setValueByPath(toObject, ['description'], fromDescription);
|
|
@@ -1840,10 +1818,18 @@ function schemaToVertex$1(apiClient, fromObject) {
|
|
|
1840
1818
|
if (fromMaxItems != null) {
|
|
1841
1819
|
setValueByPath(toObject, ['maxItems'], fromMaxItems);
|
|
1842
1820
|
}
|
|
1821
|
+
const fromMaximum = getValueByPath(fromObject, ['maximum']);
|
|
1822
|
+
if (fromMaximum != null) {
|
|
1823
|
+
setValueByPath(toObject, ['maximum'], fromMaximum);
|
|
1824
|
+
}
|
|
1843
1825
|
const fromMinItems = getValueByPath(fromObject, ['minItems']);
|
|
1844
1826
|
if (fromMinItems != null) {
|
|
1845
1827
|
setValueByPath(toObject, ['minItems'], fromMinItems);
|
|
1846
1828
|
}
|
|
1829
|
+
const fromMinimum = getValueByPath(fromObject, ['minimum']);
|
|
1830
|
+
if (fromMinimum != null) {
|
|
1831
|
+
setValueByPath(toObject, ['minimum'], fromMinimum);
|
|
1832
|
+
}
|
|
1847
1833
|
const fromNullable = getValueByPath(fromObject, ['nullable']);
|
|
1848
1834
|
if (fromNullable != null) {
|
|
1849
1835
|
setValueByPath(toObject, ['nullable'], fromNullable);
|
|
@@ -1907,11 +1893,11 @@ function functionDeclarationToVertex$1(apiClient, fromObject) {
|
|
|
1907
1893
|
}
|
|
1908
1894
|
return toObject;
|
|
1909
1895
|
}
|
|
1910
|
-
function googleSearchToMldev$1(
|
|
1896
|
+
function googleSearchToMldev$1() {
|
|
1911
1897
|
const toObject = {};
|
|
1912
1898
|
return toObject;
|
|
1913
1899
|
}
|
|
1914
|
-
function googleSearchToVertex$1(
|
|
1900
|
+
function googleSearchToVertex$1() {
|
|
1915
1901
|
const toObject = {};
|
|
1916
1902
|
return toObject;
|
|
1917
1903
|
}
|
|
@@ -2410,11 +2396,11 @@ function cachedContentFromVertex(apiClient, fromObject) {
|
|
|
2410
2396
|
}
|
|
2411
2397
|
return toObject;
|
|
2412
2398
|
}
|
|
2413
|
-
function deleteCachedContentResponseFromMldev(
|
|
2399
|
+
function deleteCachedContentResponseFromMldev() {
|
|
2414
2400
|
const toObject = {};
|
|
2415
2401
|
return toObject;
|
|
2416
2402
|
}
|
|
2417
|
-
function deleteCachedContentResponseFromVertex(
|
|
2403
|
+
function deleteCachedContentResponseFromVertex() {
|
|
2418
2404
|
const toObject = {};
|
|
2419
2405
|
return toObject;
|
|
2420
2406
|
}
|
|
@@ -3301,7 +3287,7 @@ class Models extends BaseModule {
|
|
|
3301
3287
|
* ```
|
|
3302
3288
|
*/
|
|
3303
3289
|
async computeTokens(params) {
|
|
3304
|
-
var _a
|
|
3290
|
+
var _a;
|
|
3305
3291
|
let response;
|
|
3306
3292
|
let path = '';
|
|
3307
3293
|
let queryParams = {};
|
|
@@ -3331,29 +3317,7 @@ class Models extends BaseModule {
|
|
|
3331
3317
|
});
|
|
3332
3318
|
}
|
|
3333
3319
|
else {
|
|
3334
|
-
|
|
3335
|
-
path = formatMap('None', body['_url']);
|
|
3336
|
-
queryParams = body['_query'];
|
|
3337
|
-
delete body['config'];
|
|
3338
|
-
delete body['_url'];
|
|
3339
|
-
delete body['_query'];
|
|
3340
|
-
response = this.apiClient
|
|
3341
|
-
.request({
|
|
3342
|
-
path: path,
|
|
3343
|
-
queryParams: queryParams,
|
|
3344
|
-
body: JSON.stringify(body),
|
|
3345
|
-
httpMethod: 'POST',
|
|
3346
|
-
httpOptions: (_b = params.config) === null || _b === void 0 ? void 0 : _b.httpOptions,
|
|
3347
|
-
})
|
|
3348
|
-
.then((httpResponse) => {
|
|
3349
|
-
return httpResponse.json();
|
|
3350
|
-
});
|
|
3351
|
-
return response.then((apiResponse) => {
|
|
3352
|
-
const resp = computeTokensResponseFromMldev(this.apiClient, apiResponse);
|
|
3353
|
-
const typedResp = new ComputeTokensResponse();
|
|
3354
|
-
Object.assign(typedResp, resp);
|
|
3355
|
-
return typedResp;
|
|
3356
|
-
});
|
|
3320
|
+
throw new Error('This method is only supported by the Vertex AI.');
|
|
3357
3321
|
}
|
|
3358
3322
|
}
|
|
3359
3323
|
}
|
|
@@ -3498,15 +3462,9 @@ function schemaToMldev(apiClient, fromObject) {
|
|
|
3498
3462
|
if (getValueByPath(fromObject, ['pattern']) !== undefined) {
|
|
3499
3463
|
throw new Error('pattern parameter is not supported in Gemini API.');
|
|
3500
3464
|
}
|
|
3501
|
-
if (getValueByPath(fromObject, ['minimum']) !== undefined) {
|
|
3502
|
-
throw new Error('minimum parameter is not supported in Gemini API.');
|
|
3503
|
-
}
|
|
3504
3465
|
if (getValueByPath(fromObject, ['default']) !== undefined) {
|
|
3505
3466
|
throw new Error('default parameter is not supported in Gemini API.');
|
|
3506
3467
|
}
|
|
3507
|
-
if (getValueByPath(fromObject, ['anyOf']) !== undefined) {
|
|
3508
|
-
throw new Error('anyOf parameter is not supported in Gemini API.');
|
|
3509
|
-
}
|
|
3510
3468
|
if (getValueByPath(fromObject, ['maxLength']) !== undefined) {
|
|
3511
3469
|
throw new Error('maxLength parameter is not supported in Gemini API.');
|
|
3512
3470
|
}
|
|
@@ -3519,12 +3477,13 @@ function schemaToMldev(apiClient, fromObject) {
|
|
|
3519
3477
|
if (getValueByPath(fromObject, ['minProperties']) !== undefined) {
|
|
3520
3478
|
throw new Error('minProperties parameter is not supported in Gemini API.');
|
|
3521
3479
|
}
|
|
3522
|
-
if (getValueByPath(fromObject, ['maximum']) !== undefined) {
|
|
3523
|
-
throw new Error('maximum parameter is not supported in Gemini API.');
|
|
3524
|
-
}
|
|
3525
3480
|
if (getValueByPath(fromObject, ['maxProperties']) !== undefined) {
|
|
3526
3481
|
throw new Error('maxProperties parameter is not supported in Gemini API.');
|
|
3527
3482
|
}
|
|
3483
|
+
const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
|
|
3484
|
+
if (fromAnyOf != null) {
|
|
3485
|
+
setValueByPath(toObject, ['anyOf'], fromAnyOf);
|
|
3486
|
+
}
|
|
3528
3487
|
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
3529
3488
|
if (fromDescription != null) {
|
|
3530
3489
|
setValueByPath(toObject, ['description'], fromDescription);
|
|
@@ -3545,10 +3504,18 @@ function schemaToMldev(apiClient, fromObject) {
|
|
|
3545
3504
|
if (fromMaxItems != null) {
|
|
3546
3505
|
setValueByPath(toObject, ['maxItems'], fromMaxItems);
|
|
3547
3506
|
}
|
|
3507
|
+
const fromMaximum = getValueByPath(fromObject, ['maximum']);
|
|
3508
|
+
if (fromMaximum != null) {
|
|
3509
|
+
setValueByPath(toObject, ['maximum'], fromMaximum);
|
|
3510
|
+
}
|
|
3548
3511
|
const fromMinItems = getValueByPath(fromObject, ['minItems']);
|
|
3549
3512
|
if (fromMinItems != null) {
|
|
3550
3513
|
setValueByPath(toObject, ['minItems'], fromMinItems);
|
|
3551
3514
|
}
|
|
3515
|
+
const fromMinimum = getValueByPath(fromObject, ['minimum']);
|
|
3516
|
+
if (fromMinimum != null) {
|
|
3517
|
+
setValueByPath(toObject, ['minimum'], fromMinimum);
|
|
3518
|
+
}
|
|
3552
3519
|
const fromNullable = getValueByPath(fromObject, ['nullable']);
|
|
3553
3520
|
if (fromNullable != null) {
|
|
3554
3521
|
setValueByPath(toObject, ['nullable'], fromNullable);
|
|
@@ -3583,18 +3550,10 @@ function schemaToVertex(apiClient, fromObject) {
|
|
|
3583
3550
|
if (fromPattern != null) {
|
|
3584
3551
|
setValueByPath(toObject, ['pattern'], fromPattern);
|
|
3585
3552
|
}
|
|
3586
|
-
const fromMinimum = getValueByPath(fromObject, ['minimum']);
|
|
3587
|
-
if (fromMinimum != null) {
|
|
3588
|
-
setValueByPath(toObject, ['minimum'], fromMinimum);
|
|
3589
|
-
}
|
|
3590
3553
|
const fromDefault = getValueByPath(fromObject, ['default']);
|
|
3591
3554
|
if (fromDefault != null) {
|
|
3592
3555
|
setValueByPath(toObject, ['default'], fromDefault);
|
|
3593
3556
|
}
|
|
3594
|
-
const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
|
|
3595
|
-
if (fromAnyOf != null) {
|
|
3596
|
-
setValueByPath(toObject, ['anyOf'], fromAnyOf);
|
|
3597
|
-
}
|
|
3598
3557
|
const fromMaxLength = getValueByPath(fromObject, ['maxLength']);
|
|
3599
3558
|
if (fromMaxLength != null) {
|
|
3600
3559
|
setValueByPath(toObject, ['maxLength'], fromMaxLength);
|
|
@@ -3613,16 +3572,16 @@ function schemaToVertex(apiClient, fromObject) {
|
|
|
3613
3572
|
if (fromMinProperties != null) {
|
|
3614
3573
|
setValueByPath(toObject, ['minProperties'], fromMinProperties);
|
|
3615
3574
|
}
|
|
3616
|
-
const fromMaximum = getValueByPath(fromObject, ['maximum']);
|
|
3617
|
-
if (fromMaximum != null) {
|
|
3618
|
-
setValueByPath(toObject, ['maximum'], fromMaximum);
|
|
3619
|
-
}
|
|
3620
3575
|
const fromMaxProperties = getValueByPath(fromObject, [
|
|
3621
3576
|
'maxProperties',
|
|
3622
3577
|
]);
|
|
3623
3578
|
if (fromMaxProperties != null) {
|
|
3624
3579
|
setValueByPath(toObject, ['maxProperties'], fromMaxProperties);
|
|
3625
3580
|
}
|
|
3581
|
+
const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
|
|
3582
|
+
if (fromAnyOf != null) {
|
|
3583
|
+
setValueByPath(toObject, ['anyOf'], fromAnyOf);
|
|
3584
|
+
}
|
|
3626
3585
|
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
3627
3586
|
if (fromDescription != null) {
|
|
3628
3587
|
setValueByPath(toObject, ['description'], fromDescription);
|
|
@@ -3643,10 +3602,18 @@ function schemaToVertex(apiClient, fromObject) {
|
|
|
3643
3602
|
if (fromMaxItems != null) {
|
|
3644
3603
|
setValueByPath(toObject, ['maxItems'], fromMaxItems);
|
|
3645
3604
|
}
|
|
3605
|
+
const fromMaximum = getValueByPath(fromObject, ['maximum']);
|
|
3606
|
+
if (fromMaximum != null) {
|
|
3607
|
+
setValueByPath(toObject, ['maximum'], fromMaximum);
|
|
3608
|
+
}
|
|
3646
3609
|
const fromMinItems = getValueByPath(fromObject, ['minItems']);
|
|
3647
3610
|
if (fromMinItems != null) {
|
|
3648
3611
|
setValueByPath(toObject, ['minItems'], fromMinItems);
|
|
3649
3612
|
}
|
|
3613
|
+
const fromMinimum = getValueByPath(fromObject, ['minimum']);
|
|
3614
|
+
if (fromMinimum != null) {
|
|
3615
|
+
setValueByPath(toObject, ['minimum'], fromMinimum);
|
|
3616
|
+
}
|
|
3650
3617
|
const fromNullable = getValueByPath(fromObject, ['nullable']);
|
|
3651
3618
|
if (fromNullable != null) {
|
|
3652
3619
|
setValueByPath(toObject, ['nullable'], fromNullable);
|
|
@@ -3741,11 +3708,11 @@ function functionDeclarationToVertex(apiClient, fromObject) {
|
|
|
3741
3708
|
}
|
|
3742
3709
|
return toObject;
|
|
3743
3710
|
}
|
|
3744
|
-
function googleSearchToMldev(
|
|
3711
|
+
function googleSearchToMldev() {
|
|
3745
3712
|
const toObject = {};
|
|
3746
3713
|
return toObject;
|
|
3747
3714
|
}
|
|
3748
|
-
function googleSearchToVertex(
|
|
3715
|
+
function googleSearchToVertex() {
|
|
3749
3716
|
const toObject = {};
|
|
3750
3717
|
return toObject;
|
|
3751
3718
|
}
|
|
@@ -4694,21 +4661,6 @@ function countTokensParametersToVertex(apiClient, fromObject) {
|
|
|
4694
4661
|
}
|
|
4695
4662
|
return toObject;
|
|
4696
4663
|
}
|
|
4697
|
-
function computeTokensParametersToMldev(apiClient, fromObject) {
|
|
4698
|
-
const toObject = {};
|
|
4699
|
-
const fromModel = getValueByPath(fromObject, ['model']);
|
|
4700
|
-
if (fromModel != null) {
|
|
4701
|
-
setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
|
|
4702
|
-
}
|
|
4703
|
-
if (getValueByPath(fromObject, ['contents']) !== undefined) {
|
|
4704
|
-
throw new Error('contents parameter is not supported in Gemini API.');
|
|
4705
|
-
}
|
|
4706
|
-
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
4707
|
-
if (fromConfig != null) {
|
|
4708
|
-
setValueByPath(toObject, ['config'], fromConfig);
|
|
4709
|
-
}
|
|
4710
|
-
return toObject;
|
|
4711
|
-
}
|
|
4712
4664
|
function computeTokensParametersToVertex(apiClient, fromObject) {
|
|
4713
4665
|
const toObject = {};
|
|
4714
4666
|
const fromModel = getValueByPath(fromObject, ['model']);
|
|
@@ -5078,7 +5030,7 @@ function contentEmbeddingFromVertex(apiClient, fromObject) {
|
|
|
5078
5030
|
}
|
|
5079
5031
|
return toObject;
|
|
5080
5032
|
}
|
|
5081
|
-
function embedContentMetadataFromMldev(
|
|
5033
|
+
function embedContentMetadataFromMldev() {
|
|
5082
5034
|
const toObject = {};
|
|
5083
5035
|
return toObject;
|
|
5084
5036
|
}
|
|
@@ -5165,6 +5117,42 @@ function imageFromVertex(apiClient, fromObject) {
|
|
|
5165
5117
|
}
|
|
5166
5118
|
return toObject;
|
|
5167
5119
|
}
|
|
5120
|
+
function safetyAttributesFromMldev(apiClient, fromObject) {
|
|
5121
|
+
const toObject = {};
|
|
5122
|
+
const fromCategories = getValueByPath(fromObject, [
|
|
5123
|
+
'safetyAttributes',
|
|
5124
|
+
'categories',
|
|
5125
|
+
]);
|
|
5126
|
+
if (fromCategories != null) {
|
|
5127
|
+
setValueByPath(toObject, ['categories'], fromCategories);
|
|
5128
|
+
}
|
|
5129
|
+
const fromScores = getValueByPath(fromObject, [
|
|
5130
|
+
'safetyAttributes',
|
|
5131
|
+
'scores',
|
|
5132
|
+
]);
|
|
5133
|
+
if (fromScores != null) {
|
|
5134
|
+
setValueByPath(toObject, ['scores'], fromScores);
|
|
5135
|
+
}
|
|
5136
|
+
return toObject;
|
|
5137
|
+
}
|
|
5138
|
+
function safetyAttributesFromVertex(apiClient, fromObject) {
|
|
5139
|
+
const toObject = {};
|
|
5140
|
+
const fromCategories = getValueByPath(fromObject, [
|
|
5141
|
+
'safetyAttributes',
|
|
5142
|
+
'categories',
|
|
5143
|
+
]);
|
|
5144
|
+
if (fromCategories != null) {
|
|
5145
|
+
setValueByPath(toObject, ['categories'], fromCategories);
|
|
5146
|
+
}
|
|
5147
|
+
const fromScores = getValueByPath(fromObject, [
|
|
5148
|
+
'safetyAttributes',
|
|
5149
|
+
'scores',
|
|
5150
|
+
]);
|
|
5151
|
+
if (fromScores != null) {
|
|
5152
|
+
setValueByPath(toObject, ['scores'], fromScores);
|
|
5153
|
+
}
|
|
5154
|
+
return toObject;
|
|
5155
|
+
}
|
|
5168
5156
|
function generatedImageFromMldev(apiClient, fromObject) {
|
|
5169
5157
|
const toObject = {};
|
|
5170
5158
|
const fromImage = getValueByPath(fromObject, ['_self']);
|
|
@@ -5177,6 +5165,10 @@ function generatedImageFromMldev(apiClient, fromObject) {
|
|
|
5177
5165
|
if (fromRaiFilteredReason != null) {
|
|
5178
5166
|
setValueByPath(toObject, ['raiFilteredReason'], fromRaiFilteredReason);
|
|
5179
5167
|
}
|
|
5168
|
+
const fromSafetyAttributes = getValueByPath(fromObject, ['_self']);
|
|
5169
|
+
if (fromSafetyAttributes != null) {
|
|
5170
|
+
setValueByPath(toObject, ['safetyAttributes'], safetyAttributesFromMldev(apiClient, fromSafetyAttributes));
|
|
5171
|
+
}
|
|
5180
5172
|
return toObject;
|
|
5181
5173
|
}
|
|
5182
5174
|
function generatedImageFromVertex(apiClient, fromObject) {
|
|
@@ -5191,6 +5183,10 @@ function generatedImageFromVertex(apiClient, fromObject) {
|
|
|
5191
5183
|
if (fromRaiFilteredReason != null) {
|
|
5192
5184
|
setValueByPath(toObject, ['raiFilteredReason'], fromRaiFilteredReason);
|
|
5193
5185
|
}
|
|
5186
|
+
const fromSafetyAttributes = getValueByPath(fromObject, ['_self']);
|
|
5187
|
+
if (fromSafetyAttributes != null) {
|
|
5188
|
+
setValueByPath(toObject, ['safetyAttributes'], safetyAttributesFromVertex(apiClient, fromSafetyAttributes));
|
|
5189
|
+
}
|
|
5194
5190
|
const fromEnhancedPrompt = getValueByPath(fromObject, ['prompt']);
|
|
5195
5191
|
if (fromEnhancedPrompt != null) {
|
|
5196
5192
|
setValueByPath(toObject, ['enhancedPrompt'], fromEnhancedPrompt);
|
|
@@ -5253,14 +5249,6 @@ function countTokensResponseFromVertex(apiClient, fromObject) {
|
|
|
5253
5249
|
}
|
|
5254
5250
|
return toObject;
|
|
5255
5251
|
}
|
|
5256
|
-
function computeTokensResponseFromMldev(apiClient, fromObject) {
|
|
5257
|
-
const toObject = {};
|
|
5258
|
-
const fromTokensInfo = getValueByPath(fromObject, ['tokensInfo']);
|
|
5259
|
-
if (fromTokensInfo != null) {
|
|
5260
|
-
setValueByPath(toObject, ['tokensInfo'], fromTokensInfo);
|
|
5261
|
-
}
|
|
5262
|
-
return toObject;
|
|
5263
|
-
}
|
|
5264
5252
|
function computeTokensResponseFromVertex(apiClient, fromObject) {
|
|
5265
5253
|
const toObject = {};
|
|
5266
5254
|
const fromTokensInfo = getValueByPath(fromObject, ['tokensInfo']);
|
|
@@ -5894,7 +5882,7 @@ function mapToHeaders(map) {
|
|
|
5894
5882
|
const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
5895
5883
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
5896
5884
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
5897
|
-
const SDK_VERSION = '0.
|
|
5885
|
+
const SDK_VERSION = '0.4.0'; // x-release-please-version
|
|
5898
5886
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
5899
5887
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
5900
5888
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -6384,34 +6372,12 @@ class Files extends BaseModule {
|
|
|
6384
6372
|
});
|
|
6385
6373
|
}
|
|
6386
6374
|
async listInternal(params) {
|
|
6387
|
-
var _a
|
|
6375
|
+
var _a;
|
|
6388
6376
|
let response;
|
|
6389
6377
|
let path = '';
|
|
6390
6378
|
let queryParams = {};
|
|
6391
6379
|
if (this.apiClient.isVertexAI()) {
|
|
6392
|
-
|
|
6393
|
-
path = formatMap('None', body['_url']);
|
|
6394
|
-
queryParams = body['_query'];
|
|
6395
|
-
delete body['config'];
|
|
6396
|
-
delete body['_url'];
|
|
6397
|
-
delete body['_query'];
|
|
6398
|
-
response = this.apiClient
|
|
6399
|
-
.request({
|
|
6400
|
-
path: path,
|
|
6401
|
-
queryParams: queryParams,
|
|
6402
|
-
body: JSON.stringify(body),
|
|
6403
|
-
httpMethod: 'GET',
|
|
6404
|
-
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
6405
|
-
})
|
|
6406
|
-
.then((httpResponse) => {
|
|
6407
|
-
return httpResponse.json();
|
|
6408
|
-
});
|
|
6409
|
-
return response.then((apiResponse) => {
|
|
6410
|
-
const resp = listFilesResponseFromVertex(this.apiClient);
|
|
6411
|
-
const typedResp = new ListFilesResponse();
|
|
6412
|
-
Object.assign(typedResp, resp);
|
|
6413
|
-
return typedResp;
|
|
6414
|
-
});
|
|
6380
|
+
throw new Error('This method is only supported by the Gemini Developer API.');
|
|
6415
6381
|
}
|
|
6416
6382
|
else {
|
|
6417
6383
|
const body = listFilesParametersToMldev(this.apiClient, params);
|
|
@@ -6426,7 +6392,7 @@ class Files extends BaseModule {
|
|
|
6426
6392
|
queryParams: queryParams,
|
|
6427
6393
|
body: JSON.stringify(body),
|
|
6428
6394
|
httpMethod: 'GET',
|
|
6429
|
-
httpOptions: (
|
|
6395
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
6430
6396
|
})
|
|
6431
6397
|
.then((httpResponse) => {
|
|
6432
6398
|
return httpResponse.json();
|
|
@@ -6440,34 +6406,12 @@ class Files extends BaseModule {
|
|
|
6440
6406
|
}
|
|
6441
6407
|
}
|
|
6442
6408
|
async createInternal(params) {
|
|
6443
|
-
var _a
|
|
6409
|
+
var _a;
|
|
6444
6410
|
let response;
|
|
6445
6411
|
let path = '';
|
|
6446
6412
|
let queryParams = {};
|
|
6447
6413
|
if (this.apiClient.isVertexAI()) {
|
|
6448
|
-
|
|
6449
|
-
path = formatMap('', body['_url']);
|
|
6450
|
-
queryParams = body['_query'];
|
|
6451
|
-
delete body['config'];
|
|
6452
|
-
delete body['_url'];
|
|
6453
|
-
delete body['_query'];
|
|
6454
|
-
response = this.apiClient
|
|
6455
|
-
.request({
|
|
6456
|
-
path: path,
|
|
6457
|
-
queryParams: queryParams,
|
|
6458
|
-
body: JSON.stringify(body),
|
|
6459
|
-
httpMethod: 'POST',
|
|
6460
|
-
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
6461
|
-
})
|
|
6462
|
-
.then((httpResponse) => {
|
|
6463
|
-
return httpResponse.json();
|
|
6464
|
-
});
|
|
6465
|
-
return response.then((apiResponse) => {
|
|
6466
|
-
const resp = createFileResponseFromVertex(this.apiClient, apiResponse);
|
|
6467
|
-
const typedResp = new CreateFileResponse();
|
|
6468
|
-
Object.assign(typedResp, resp);
|
|
6469
|
-
return typedResp;
|
|
6470
|
-
});
|
|
6414
|
+
throw new Error('This method is only supported by the Gemini Developer API.');
|
|
6471
6415
|
}
|
|
6472
6416
|
else {
|
|
6473
6417
|
const body = createFileParametersToMldev(this.apiClient, params);
|
|
@@ -6482,7 +6426,7 @@ class Files extends BaseModule {
|
|
|
6482
6426
|
queryParams: queryParams,
|
|
6483
6427
|
body: JSON.stringify(body),
|
|
6484
6428
|
httpMethod: 'POST',
|
|
6485
|
-
httpOptions: (
|
|
6429
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
6486
6430
|
})
|
|
6487
6431
|
.then((httpResponse) => {
|
|
6488
6432
|
return httpResponse.json();
|
|
@@ -6511,32 +6455,12 @@ class Files extends BaseModule {
|
|
|
6511
6455
|
* ```
|
|
6512
6456
|
*/
|
|
6513
6457
|
async get(params) {
|
|
6514
|
-
var _a
|
|
6458
|
+
var _a;
|
|
6515
6459
|
let response;
|
|
6516
6460
|
let path = '';
|
|
6517
6461
|
let queryParams = {};
|
|
6518
6462
|
if (this.apiClient.isVertexAI()) {
|
|
6519
|
-
|
|
6520
|
-
path = formatMap('None', body['_url']);
|
|
6521
|
-
queryParams = body['_query'];
|
|
6522
|
-
delete body['config'];
|
|
6523
|
-
delete body['_url'];
|
|
6524
|
-
delete body['_query'];
|
|
6525
|
-
response = this.apiClient
|
|
6526
|
-
.request({
|
|
6527
|
-
path: path,
|
|
6528
|
-
queryParams: queryParams,
|
|
6529
|
-
body: JSON.stringify(body),
|
|
6530
|
-
httpMethod: 'GET',
|
|
6531
|
-
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
6532
|
-
})
|
|
6533
|
-
.then((httpResponse) => {
|
|
6534
|
-
return httpResponse.json();
|
|
6535
|
-
});
|
|
6536
|
-
return response.then((apiResponse) => {
|
|
6537
|
-
const resp = fileFromVertex(this.apiClient);
|
|
6538
|
-
return resp;
|
|
6539
|
-
});
|
|
6463
|
+
throw new Error('This method is only supported by the Gemini Developer API.');
|
|
6540
6464
|
}
|
|
6541
6465
|
else {
|
|
6542
6466
|
const body = getFileParametersToMldev(this.apiClient, params);
|
|
@@ -6551,7 +6475,7 @@ class Files extends BaseModule {
|
|
|
6551
6475
|
queryParams: queryParams,
|
|
6552
6476
|
body: JSON.stringify(body),
|
|
6553
6477
|
httpMethod: 'GET',
|
|
6554
|
-
httpOptions: (
|
|
6478
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
6555
6479
|
})
|
|
6556
6480
|
.then((httpResponse) => {
|
|
6557
6481
|
return httpResponse.json();
|
|
@@ -6583,13 +6507,6 @@ function listFilesParametersToMldev(apiClient, fromObject) {
|
|
|
6583
6507
|
}
|
|
6584
6508
|
return toObject;
|
|
6585
6509
|
}
|
|
6586
|
-
function listFilesParametersToVertex(apiClient, fromObject) {
|
|
6587
|
-
const toObject = {};
|
|
6588
|
-
if (getValueByPath(fromObject, ['config']) !== undefined) {
|
|
6589
|
-
throw new Error('config parameter is not supported in Vertex AI.');
|
|
6590
|
-
}
|
|
6591
|
-
return toObject;
|
|
6592
|
-
}
|
|
6593
6510
|
function fileStatusToMldev(apiClient, fromObject) {
|
|
6594
6511
|
const toObject = {};
|
|
6595
6512
|
const fromDetails = getValueByPath(fromObject, ['details']);
|
|
@@ -6682,16 +6599,6 @@ function createFileParametersToMldev(apiClient, fromObject) {
|
|
|
6682
6599
|
}
|
|
6683
6600
|
return toObject;
|
|
6684
6601
|
}
|
|
6685
|
-
function createFileParametersToVertex(apiClient, fromObject) {
|
|
6686
|
-
const toObject = {};
|
|
6687
|
-
if (getValueByPath(fromObject, ['file']) !== undefined) {
|
|
6688
|
-
throw new Error('file parameter is not supported in Vertex AI.');
|
|
6689
|
-
}
|
|
6690
|
-
if (getValueByPath(fromObject, ['config']) !== undefined) {
|
|
6691
|
-
throw new Error('config parameter is not supported in Vertex AI.');
|
|
6692
|
-
}
|
|
6693
|
-
return toObject;
|
|
6694
|
-
}
|
|
6695
6602
|
function getFileParametersToMldev(apiClient, fromObject) {
|
|
6696
6603
|
const toObject = {};
|
|
6697
6604
|
const fromName = getValueByPath(fromObject, ['name']);
|
|
@@ -6704,16 +6611,6 @@ function getFileParametersToMldev(apiClient, fromObject) {
|
|
|
6704
6611
|
}
|
|
6705
6612
|
return toObject;
|
|
6706
6613
|
}
|
|
6707
|
-
function getFileParametersToVertex(apiClient, fromObject) {
|
|
6708
|
-
const toObject = {};
|
|
6709
|
-
if (getValueByPath(fromObject, ['name']) !== undefined) {
|
|
6710
|
-
throw new Error('name parameter is not supported in Vertex AI.');
|
|
6711
|
-
}
|
|
6712
|
-
if (getValueByPath(fromObject, ['config']) !== undefined) {
|
|
6713
|
-
throw new Error('config parameter is not supported in Vertex AI.');
|
|
6714
|
-
}
|
|
6715
|
-
return toObject;
|
|
6716
|
-
}
|
|
6717
6614
|
function fileStatusFromMldev(apiClient, fromObject) {
|
|
6718
6615
|
const toObject = {};
|
|
6719
6616
|
const fromDetails = getValueByPath(fromObject, ['details']);
|
|
@@ -6794,10 +6691,6 @@ function fileFromMldev(apiClient, fromObject) {
|
|
|
6794
6691
|
}
|
|
6795
6692
|
return toObject;
|
|
6796
6693
|
}
|
|
6797
|
-
function fileFromVertex(apiClient, fromObject) {
|
|
6798
|
-
const toObject = {};
|
|
6799
|
-
return toObject;
|
|
6800
|
-
}
|
|
6801
6694
|
function listFilesResponseFromMldev(apiClient, fromObject) {
|
|
6802
6695
|
const toObject = {};
|
|
6803
6696
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
@@ -6819,10 +6712,6 @@ function listFilesResponseFromMldev(apiClient, fromObject) {
|
|
|
6819
6712
|
}
|
|
6820
6713
|
return toObject;
|
|
6821
6714
|
}
|
|
6822
|
-
function listFilesResponseFromVertex(apiClient, fromObject) {
|
|
6823
|
-
const toObject = {};
|
|
6824
|
-
return toObject;
|
|
6825
|
-
}
|
|
6826
6715
|
function createFileResponseFromMldev(apiClient, fromObject) {
|
|
6827
6716
|
const toObject = {};
|
|
6828
6717
|
const fromHttpHeaders = getValueByPath(fromObject, ['httpHeaders']);
|
|
@@ -6831,14 +6720,6 @@ function createFileResponseFromMldev(apiClient, fromObject) {
|
|
|
6831
6720
|
}
|
|
6832
6721
|
return toObject;
|
|
6833
6722
|
}
|
|
6834
|
-
function createFileResponseFromVertex(apiClient, fromObject) {
|
|
6835
|
-
const toObject = {};
|
|
6836
|
-
const fromHttpHeaders = getValueByPath(fromObject, ['httpHeaders']);
|
|
6837
|
-
if (fromHttpHeaders != null) {
|
|
6838
|
-
setValueByPath(toObject, ['httpHeaders'], fromHttpHeaders);
|
|
6839
|
-
}
|
|
6840
|
-
return toObject;
|
|
6841
|
-
}
|
|
6842
6723
|
|
|
6843
6724
|
/**
|
|
6844
6725
|
* @license
|
|
@@ -7325,7 +7206,6 @@ exports.createPartFromFunctionCall = createPartFromFunctionCall;
|
|
|
7325
7206
|
exports.createPartFromFunctionResponse = createPartFromFunctionResponse;
|
|
7326
7207
|
exports.createPartFromText = createPartFromText;
|
|
7327
7208
|
exports.createPartFromUri = createPartFromUri;
|
|
7328
|
-
exports.createPartFromVideoMetadata = createPartFromVideoMetadata;
|
|
7329
7209
|
exports.createUserContent = createUserContent;
|
|
7330
7210
|
exports.toolToMldev = toolToMldev$1;
|
|
7331
7211
|
exports.toolToVertex = toolToVertex$1;
|