@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/web/index.mjs
CHANGED
|
@@ -352,9 +352,6 @@ function processSchema(apiClient, schema) {
|
|
|
352
352
|
}
|
|
353
353
|
}
|
|
354
354
|
if ('anyOf' in schema) {
|
|
355
|
-
if (!apiClient.isVertexAI()) {
|
|
356
|
-
throw new Error('AnyOf is not supported in the response schema for the Gemini API.');
|
|
357
|
-
}
|
|
358
355
|
if (schema['anyOf'] !== undefined) {
|
|
359
356
|
for (const subSchema of schema['anyOf']) {
|
|
360
357
|
processSchema(apiClient, subSchema);
|
|
@@ -908,17 +905,6 @@ function createPartFromBase64(data, mimeType) {
|
|
|
908
905
|
},
|
|
909
906
|
};
|
|
910
907
|
}
|
|
911
|
-
/**
|
|
912
|
-
* Creates a `Part` object from the `startOffset` and `endOffset` of a `VideoMetadata` object.
|
|
913
|
-
*/
|
|
914
|
-
function createPartFromVideoMetadata(startOffset, endOffset) {
|
|
915
|
-
return {
|
|
916
|
-
videoMetadata: {
|
|
917
|
-
startOffset: startOffset,
|
|
918
|
-
endOffset: endOffset,
|
|
919
|
-
},
|
|
920
|
-
};
|
|
921
|
-
}
|
|
922
908
|
/**
|
|
923
909
|
* Creates a `Part` object from the `outcome` and `output` of a `CodeExecutionResult` object.
|
|
924
910
|
*/
|
|
@@ -1456,7 +1442,7 @@ class Caches extends BaseModule {
|
|
|
1456
1442
|
return httpResponse.json();
|
|
1457
1443
|
});
|
|
1458
1444
|
return response.then((apiResponse) => {
|
|
1459
|
-
const resp = deleteCachedContentResponseFromVertex(
|
|
1445
|
+
const resp = deleteCachedContentResponseFromVertex();
|
|
1460
1446
|
const typedResp = new DeleteCachedContentResponse();
|
|
1461
1447
|
Object.assign(typedResp, resp);
|
|
1462
1448
|
return typedResp;
|
|
@@ -1481,7 +1467,7 @@ class Caches extends BaseModule {
|
|
|
1481
1467
|
return httpResponse.json();
|
|
1482
1468
|
});
|
|
1483
1469
|
return response.then((apiResponse) => {
|
|
1484
|
-
const resp = deleteCachedContentResponseFromMldev(
|
|
1470
|
+
const resp = deleteCachedContentResponseFromMldev();
|
|
1485
1471
|
const typedResp = new DeleteCachedContentResponse();
|
|
1486
1472
|
Object.assign(typedResp, resp);
|
|
1487
1473
|
return typedResp;
|
|
@@ -1754,18 +1740,10 @@ function schemaToVertex$1(apiClient, fromObject) {
|
|
|
1754
1740
|
if (fromPattern != null) {
|
|
1755
1741
|
setValueByPath(toObject, ['pattern'], fromPattern);
|
|
1756
1742
|
}
|
|
1757
|
-
const fromMinimum = getValueByPath(fromObject, ['minimum']);
|
|
1758
|
-
if (fromMinimum != null) {
|
|
1759
|
-
setValueByPath(toObject, ['minimum'], fromMinimum);
|
|
1760
|
-
}
|
|
1761
1743
|
const fromDefault = getValueByPath(fromObject, ['default']);
|
|
1762
1744
|
if (fromDefault != null) {
|
|
1763
1745
|
setValueByPath(toObject, ['default'], fromDefault);
|
|
1764
1746
|
}
|
|
1765
|
-
const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
|
|
1766
|
-
if (fromAnyOf != null) {
|
|
1767
|
-
setValueByPath(toObject, ['anyOf'], fromAnyOf);
|
|
1768
|
-
}
|
|
1769
1747
|
const fromMaxLength = getValueByPath(fromObject, ['maxLength']);
|
|
1770
1748
|
if (fromMaxLength != null) {
|
|
1771
1749
|
setValueByPath(toObject, ['maxLength'], fromMaxLength);
|
|
@@ -1784,16 +1762,16 @@ function schemaToVertex$1(apiClient, fromObject) {
|
|
|
1784
1762
|
if (fromMinProperties != null) {
|
|
1785
1763
|
setValueByPath(toObject, ['minProperties'], fromMinProperties);
|
|
1786
1764
|
}
|
|
1787
|
-
const fromMaximum = getValueByPath(fromObject, ['maximum']);
|
|
1788
|
-
if (fromMaximum != null) {
|
|
1789
|
-
setValueByPath(toObject, ['maximum'], fromMaximum);
|
|
1790
|
-
}
|
|
1791
1765
|
const fromMaxProperties = getValueByPath(fromObject, [
|
|
1792
1766
|
'maxProperties',
|
|
1793
1767
|
]);
|
|
1794
1768
|
if (fromMaxProperties != null) {
|
|
1795
1769
|
setValueByPath(toObject, ['maxProperties'], fromMaxProperties);
|
|
1796
1770
|
}
|
|
1771
|
+
const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
|
|
1772
|
+
if (fromAnyOf != null) {
|
|
1773
|
+
setValueByPath(toObject, ['anyOf'], fromAnyOf);
|
|
1774
|
+
}
|
|
1797
1775
|
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
1798
1776
|
if (fromDescription != null) {
|
|
1799
1777
|
setValueByPath(toObject, ['description'], fromDescription);
|
|
@@ -1814,10 +1792,18 @@ function schemaToVertex$1(apiClient, fromObject) {
|
|
|
1814
1792
|
if (fromMaxItems != null) {
|
|
1815
1793
|
setValueByPath(toObject, ['maxItems'], fromMaxItems);
|
|
1816
1794
|
}
|
|
1795
|
+
const fromMaximum = getValueByPath(fromObject, ['maximum']);
|
|
1796
|
+
if (fromMaximum != null) {
|
|
1797
|
+
setValueByPath(toObject, ['maximum'], fromMaximum);
|
|
1798
|
+
}
|
|
1817
1799
|
const fromMinItems = getValueByPath(fromObject, ['minItems']);
|
|
1818
1800
|
if (fromMinItems != null) {
|
|
1819
1801
|
setValueByPath(toObject, ['minItems'], fromMinItems);
|
|
1820
1802
|
}
|
|
1803
|
+
const fromMinimum = getValueByPath(fromObject, ['minimum']);
|
|
1804
|
+
if (fromMinimum != null) {
|
|
1805
|
+
setValueByPath(toObject, ['minimum'], fromMinimum);
|
|
1806
|
+
}
|
|
1821
1807
|
const fromNullable = getValueByPath(fromObject, ['nullable']);
|
|
1822
1808
|
if (fromNullable != null) {
|
|
1823
1809
|
setValueByPath(toObject, ['nullable'], fromNullable);
|
|
@@ -1881,11 +1867,11 @@ function functionDeclarationToVertex$1(apiClient, fromObject) {
|
|
|
1881
1867
|
}
|
|
1882
1868
|
return toObject;
|
|
1883
1869
|
}
|
|
1884
|
-
function googleSearchToMldev$1(
|
|
1870
|
+
function googleSearchToMldev$1() {
|
|
1885
1871
|
const toObject = {};
|
|
1886
1872
|
return toObject;
|
|
1887
1873
|
}
|
|
1888
|
-
function googleSearchToVertex$1(
|
|
1874
|
+
function googleSearchToVertex$1() {
|
|
1889
1875
|
const toObject = {};
|
|
1890
1876
|
return toObject;
|
|
1891
1877
|
}
|
|
@@ -2384,11 +2370,11 @@ function cachedContentFromVertex(apiClient, fromObject) {
|
|
|
2384
2370
|
}
|
|
2385
2371
|
return toObject;
|
|
2386
2372
|
}
|
|
2387
|
-
function deleteCachedContentResponseFromMldev(
|
|
2373
|
+
function deleteCachedContentResponseFromMldev() {
|
|
2388
2374
|
const toObject = {};
|
|
2389
2375
|
return toObject;
|
|
2390
2376
|
}
|
|
2391
|
-
function deleteCachedContentResponseFromVertex(
|
|
2377
|
+
function deleteCachedContentResponseFromVertex() {
|
|
2392
2378
|
const toObject = {};
|
|
2393
2379
|
return toObject;
|
|
2394
2380
|
}
|
|
@@ -3275,7 +3261,7 @@ class Models extends BaseModule {
|
|
|
3275
3261
|
* ```
|
|
3276
3262
|
*/
|
|
3277
3263
|
async computeTokens(params) {
|
|
3278
|
-
var _a
|
|
3264
|
+
var _a;
|
|
3279
3265
|
let response;
|
|
3280
3266
|
let path = '';
|
|
3281
3267
|
let queryParams = {};
|
|
@@ -3305,29 +3291,7 @@ class Models extends BaseModule {
|
|
|
3305
3291
|
});
|
|
3306
3292
|
}
|
|
3307
3293
|
else {
|
|
3308
|
-
|
|
3309
|
-
path = formatMap('None', body['_url']);
|
|
3310
|
-
queryParams = body['_query'];
|
|
3311
|
-
delete body['config'];
|
|
3312
|
-
delete body['_url'];
|
|
3313
|
-
delete body['_query'];
|
|
3314
|
-
response = this.apiClient
|
|
3315
|
-
.request({
|
|
3316
|
-
path: path,
|
|
3317
|
-
queryParams: queryParams,
|
|
3318
|
-
body: JSON.stringify(body),
|
|
3319
|
-
httpMethod: 'POST',
|
|
3320
|
-
httpOptions: (_b = params.config) === null || _b === void 0 ? void 0 : _b.httpOptions,
|
|
3321
|
-
})
|
|
3322
|
-
.then((httpResponse) => {
|
|
3323
|
-
return httpResponse.json();
|
|
3324
|
-
});
|
|
3325
|
-
return response.then((apiResponse) => {
|
|
3326
|
-
const resp = computeTokensResponseFromMldev(this.apiClient, apiResponse);
|
|
3327
|
-
const typedResp = new ComputeTokensResponse();
|
|
3328
|
-
Object.assign(typedResp, resp);
|
|
3329
|
-
return typedResp;
|
|
3330
|
-
});
|
|
3294
|
+
throw new Error('This method is only supported by the Vertex AI.');
|
|
3331
3295
|
}
|
|
3332
3296
|
}
|
|
3333
3297
|
}
|
|
@@ -3472,15 +3436,9 @@ function schemaToMldev(apiClient, fromObject) {
|
|
|
3472
3436
|
if (getValueByPath(fromObject, ['pattern']) !== undefined) {
|
|
3473
3437
|
throw new Error('pattern parameter is not supported in Gemini API.');
|
|
3474
3438
|
}
|
|
3475
|
-
if (getValueByPath(fromObject, ['minimum']) !== undefined) {
|
|
3476
|
-
throw new Error('minimum parameter is not supported in Gemini API.');
|
|
3477
|
-
}
|
|
3478
3439
|
if (getValueByPath(fromObject, ['default']) !== undefined) {
|
|
3479
3440
|
throw new Error('default parameter is not supported in Gemini API.');
|
|
3480
3441
|
}
|
|
3481
|
-
if (getValueByPath(fromObject, ['anyOf']) !== undefined) {
|
|
3482
|
-
throw new Error('anyOf parameter is not supported in Gemini API.');
|
|
3483
|
-
}
|
|
3484
3442
|
if (getValueByPath(fromObject, ['maxLength']) !== undefined) {
|
|
3485
3443
|
throw new Error('maxLength parameter is not supported in Gemini API.');
|
|
3486
3444
|
}
|
|
@@ -3493,12 +3451,13 @@ function schemaToMldev(apiClient, fromObject) {
|
|
|
3493
3451
|
if (getValueByPath(fromObject, ['minProperties']) !== undefined) {
|
|
3494
3452
|
throw new Error('minProperties parameter is not supported in Gemini API.');
|
|
3495
3453
|
}
|
|
3496
|
-
if (getValueByPath(fromObject, ['maximum']) !== undefined) {
|
|
3497
|
-
throw new Error('maximum parameter is not supported in Gemini API.');
|
|
3498
|
-
}
|
|
3499
3454
|
if (getValueByPath(fromObject, ['maxProperties']) !== undefined) {
|
|
3500
3455
|
throw new Error('maxProperties parameter is not supported in Gemini API.');
|
|
3501
3456
|
}
|
|
3457
|
+
const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
|
|
3458
|
+
if (fromAnyOf != null) {
|
|
3459
|
+
setValueByPath(toObject, ['anyOf'], fromAnyOf);
|
|
3460
|
+
}
|
|
3502
3461
|
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
3503
3462
|
if (fromDescription != null) {
|
|
3504
3463
|
setValueByPath(toObject, ['description'], fromDescription);
|
|
@@ -3519,10 +3478,18 @@ function schemaToMldev(apiClient, fromObject) {
|
|
|
3519
3478
|
if (fromMaxItems != null) {
|
|
3520
3479
|
setValueByPath(toObject, ['maxItems'], fromMaxItems);
|
|
3521
3480
|
}
|
|
3481
|
+
const fromMaximum = getValueByPath(fromObject, ['maximum']);
|
|
3482
|
+
if (fromMaximum != null) {
|
|
3483
|
+
setValueByPath(toObject, ['maximum'], fromMaximum);
|
|
3484
|
+
}
|
|
3522
3485
|
const fromMinItems = getValueByPath(fromObject, ['minItems']);
|
|
3523
3486
|
if (fromMinItems != null) {
|
|
3524
3487
|
setValueByPath(toObject, ['minItems'], fromMinItems);
|
|
3525
3488
|
}
|
|
3489
|
+
const fromMinimum = getValueByPath(fromObject, ['minimum']);
|
|
3490
|
+
if (fromMinimum != null) {
|
|
3491
|
+
setValueByPath(toObject, ['minimum'], fromMinimum);
|
|
3492
|
+
}
|
|
3526
3493
|
const fromNullable = getValueByPath(fromObject, ['nullable']);
|
|
3527
3494
|
if (fromNullable != null) {
|
|
3528
3495
|
setValueByPath(toObject, ['nullable'], fromNullable);
|
|
@@ -3557,18 +3524,10 @@ function schemaToVertex(apiClient, fromObject) {
|
|
|
3557
3524
|
if (fromPattern != null) {
|
|
3558
3525
|
setValueByPath(toObject, ['pattern'], fromPattern);
|
|
3559
3526
|
}
|
|
3560
|
-
const fromMinimum = getValueByPath(fromObject, ['minimum']);
|
|
3561
|
-
if (fromMinimum != null) {
|
|
3562
|
-
setValueByPath(toObject, ['minimum'], fromMinimum);
|
|
3563
|
-
}
|
|
3564
3527
|
const fromDefault = getValueByPath(fromObject, ['default']);
|
|
3565
3528
|
if (fromDefault != null) {
|
|
3566
3529
|
setValueByPath(toObject, ['default'], fromDefault);
|
|
3567
3530
|
}
|
|
3568
|
-
const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
|
|
3569
|
-
if (fromAnyOf != null) {
|
|
3570
|
-
setValueByPath(toObject, ['anyOf'], fromAnyOf);
|
|
3571
|
-
}
|
|
3572
3531
|
const fromMaxLength = getValueByPath(fromObject, ['maxLength']);
|
|
3573
3532
|
if (fromMaxLength != null) {
|
|
3574
3533
|
setValueByPath(toObject, ['maxLength'], fromMaxLength);
|
|
@@ -3587,16 +3546,16 @@ function schemaToVertex(apiClient, fromObject) {
|
|
|
3587
3546
|
if (fromMinProperties != null) {
|
|
3588
3547
|
setValueByPath(toObject, ['minProperties'], fromMinProperties);
|
|
3589
3548
|
}
|
|
3590
|
-
const fromMaximum = getValueByPath(fromObject, ['maximum']);
|
|
3591
|
-
if (fromMaximum != null) {
|
|
3592
|
-
setValueByPath(toObject, ['maximum'], fromMaximum);
|
|
3593
|
-
}
|
|
3594
3549
|
const fromMaxProperties = getValueByPath(fromObject, [
|
|
3595
3550
|
'maxProperties',
|
|
3596
3551
|
]);
|
|
3597
3552
|
if (fromMaxProperties != null) {
|
|
3598
3553
|
setValueByPath(toObject, ['maxProperties'], fromMaxProperties);
|
|
3599
3554
|
}
|
|
3555
|
+
const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
|
|
3556
|
+
if (fromAnyOf != null) {
|
|
3557
|
+
setValueByPath(toObject, ['anyOf'], fromAnyOf);
|
|
3558
|
+
}
|
|
3600
3559
|
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
3601
3560
|
if (fromDescription != null) {
|
|
3602
3561
|
setValueByPath(toObject, ['description'], fromDescription);
|
|
@@ -3617,10 +3576,18 @@ function schemaToVertex(apiClient, fromObject) {
|
|
|
3617
3576
|
if (fromMaxItems != null) {
|
|
3618
3577
|
setValueByPath(toObject, ['maxItems'], fromMaxItems);
|
|
3619
3578
|
}
|
|
3579
|
+
const fromMaximum = getValueByPath(fromObject, ['maximum']);
|
|
3580
|
+
if (fromMaximum != null) {
|
|
3581
|
+
setValueByPath(toObject, ['maximum'], fromMaximum);
|
|
3582
|
+
}
|
|
3620
3583
|
const fromMinItems = getValueByPath(fromObject, ['minItems']);
|
|
3621
3584
|
if (fromMinItems != null) {
|
|
3622
3585
|
setValueByPath(toObject, ['minItems'], fromMinItems);
|
|
3623
3586
|
}
|
|
3587
|
+
const fromMinimum = getValueByPath(fromObject, ['minimum']);
|
|
3588
|
+
if (fromMinimum != null) {
|
|
3589
|
+
setValueByPath(toObject, ['minimum'], fromMinimum);
|
|
3590
|
+
}
|
|
3624
3591
|
const fromNullable = getValueByPath(fromObject, ['nullable']);
|
|
3625
3592
|
if (fromNullable != null) {
|
|
3626
3593
|
setValueByPath(toObject, ['nullable'], fromNullable);
|
|
@@ -3715,11 +3682,11 @@ function functionDeclarationToVertex(apiClient, fromObject) {
|
|
|
3715
3682
|
}
|
|
3716
3683
|
return toObject;
|
|
3717
3684
|
}
|
|
3718
|
-
function googleSearchToMldev(
|
|
3685
|
+
function googleSearchToMldev() {
|
|
3719
3686
|
const toObject = {};
|
|
3720
3687
|
return toObject;
|
|
3721
3688
|
}
|
|
3722
|
-
function googleSearchToVertex(
|
|
3689
|
+
function googleSearchToVertex() {
|
|
3723
3690
|
const toObject = {};
|
|
3724
3691
|
return toObject;
|
|
3725
3692
|
}
|
|
@@ -4668,21 +4635,6 @@ function countTokensParametersToVertex(apiClient, fromObject) {
|
|
|
4668
4635
|
}
|
|
4669
4636
|
return toObject;
|
|
4670
4637
|
}
|
|
4671
|
-
function computeTokensParametersToMldev(apiClient, fromObject) {
|
|
4672
|
-
const toObject = {};
|
|
4673
|
-
const fromModel = getValueByPath(fromObject, ['model']);
|
|
4674
|
-
if (fromModel != null) {
|
|
4675
|
-
setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
|
|
4676
|
-
}
|
|
4677
|
-
if (getValueByPath(fromObject, ['contents']) !== undefined) {
|
|
4678
|
-
throw new Error('contents parameter is not supported in Gemini API.');
|
|
4679
|
-
}
|
|
4680
|
-
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
4681
|
-
if (fromConfig != null) {
|
|
4682
|
-
setValueByPath(toObject, ['config'], fromConfig);
|
|
4683
|
-
}
|
|
4684
|
-
return toObject;
|
|
4685
|
-
}
|
|
4686
4638
|
function computeTokensParametersToVertex(apiClient, fromObject) {
|
|
4687
4639
|
const toObject = {};
|
|
4688
4640
|
const fromModel = getValueByPath(fromObject, ['model']);
|
|
@@ -5052,7 +5004,7 @@ function contentEmbeddingFromVertex(apiClient, fromObject) {
|
|
|
5052
5004
|
}
|
|
5053
5005
|
return toObject;
|
|
5054
5006
|
}
|
|
5055
|
-
function embedContentMetadataFromMldev(
|
|
5007
|
+
function embedContentMetadataFromMldev() {
|
|
5056
5008
|
const toObject = {};
|
|
5057
5009
|
return toObject;
|
|
5058
5010
|
}
|
|
@@ -5139,6 +5091,42 @@ function imageFromVertex(apiClient, fromObject) {
|
|
|
5139
5091
|
}
|
|
5140
5092
|
return toObject;
|
|
5141
5093
|
}
|
|
5094
|
+
function safetyAttributesFromMldev(apiClient, fromObject) {
|
|
5095
|
+
const toObject = {};
|
|
5096
|
+
const fromCategories = getValueByPath(fromObject, [
|
|
5097
|
+
'safetyAttributes',
|
|
5098
|
+
'categories',
|
|
5099
|
+
]);
|
|
5100
|
+
if (fromCategories != null) {
|
|
5101
|
+
setValueByPath(toObject, ['categories'], fromCategories);
|
|
5102
|
+
}
|
|
5103
|
+
const fromScores = getValueByPath(fromObject, [
|
|
5104
|
+
'safetyAttributes',
|
|
5105
|
+
'scores',
|
|
5106
|
+
]);
|
|
5107
|
+
if (fromScores != null) {
|
|
5108
|
+
setValueByPath(toObject, ['scores'], fromScores);
|
|
5109
|
+
}
|
|
5110
|
+
return toObject;
|
|
5111
|
+
}
|
|
5112
|
+
function safetyAttributesFromVertex(apiClient, fromObject) {
|
|
5113
|
+
const toObject = {};
|
|
5114
|
+
const fromCategories = getValueByPath(fromObject, [
|
|
5115
|
+
'safetyAttributes',
|
|
5116
|
+
'categories',
|
|
5117
|
+
]);
|
|
5118
|
+
if (fromCategories != null) {
|
|
5119
|
+
setValueByPath(toObject, ['categories'], fromCategories);
|
|
5120
|
+
}
|
|
5121
|
+
const fromScores = getValueByPath(fromObject, [
|
|
5122
|
+
'safetyAttributes',
|
|
5123
|
+
'scores',
|
|
5124
|
+
]);
|
|
5125
|
+
if (fromScores != null) {
|
|
5126
|
+
setValueByPath(toObject, ['scores'], fromScores);
|
|
5127
|
+
}
|
|
5128
|
+
return toObject;
|
|
5129
|
+
}
|
|
5142
5130
|
function generatedImageFromMldev(apiClient, fromObject) {
|
|
5143
5131
|
const toObject = {};
|
|
5144
5132
|
const fromImage = getValueByPath(fromObject, ['_self']);
|
|
@@ -5151,6 +5139,10 @@ function generatedImageFromMldev(apiClient, fromObject) {
|
|
|
5151
5139
|
if (fromRaiFilteredReason != null) {
|
|
5152
5140
|
setValueByPath(toObject, ['raiFilteredReason'], fromRaiFilteredReason);
|
|
5153
5141
|
}
|
|
5142
|
+
const fromSafetyAttributes = getValueByPath(fromObject, ['_self']);
|
|
5143
|
+
if (fromSafetyAttributes != null) {
|
|
5144
|
+
setValueByPath(toObject, ['safetyAttributes'], safetyAttributesFromMldev(apiClient, fromSafetyAttributes));
|
|
5145
|
+
}
|
|
5154
5146
|
return toObject;
|
|
5155
5147
|
}
|
|
5156
5148
|
function generatedImageFromVertex(apiClient, fromObject) {
|
|
@@ -5165,6 +5157,10 @@ function generatedImageFromVertex(apiClient, fromObject) {
|
|
|
5165
5157
|
if (fromRaiFilteredReason != null) {
|
|
5166
5158
|
setValueByPath(toObject, ['raiFilteredReason'], fromRaiFilteredReason);
|
|
5167
5159
|
}
|
|
5160
|
+
const fromSafetyAttributes = getValueByPath(fromObject, ['_self']);
|
|
5161
|
+
if (fromSafetyAttributes != null) {
|
|
5162
|
+
setValueByPath(toObject, ['safetyAttributes'], safetyAttributesFromVertex(apiClient, fromSafetyAttributes));
|
|
5163
|
+
}
|
|
5168
5164
|
const fromEnhancedPrompt = getValueByPath(fromObject, ['prompt']);
|
|
5169
5165
|
if (fromEnhancedPrompt != null) {
|
|
5170
5166
|
setValueByPath(toObject, ['enhancedPrompt'], fromEnhancedPrompt);
|
|
@@ -5227,14 +5223,6 @@ function countTokensResponseFromVertex(apiClient, fromObject) {
|
|
|
5227
5223
|
}
|
|
5228
5224
|
return toObject;
|
|
5229
5225
|
}
|
|
5230
|
-
function computeTokensResponseFromMldev(apiClient, fromObject) {
|
|
5231
|
-
const toObject = {};
|
|
5232
|
-
const fromTokensInfo = getValueByPath(fromObject, ['tokensInfo']);
|
|
5233
|
-
if (fromTokensInfo != null) {
|
|
5234
|
-
setValueByPath(toObject, ['tokensInfo'], fromTokensInfo);
|
|
5235
|
-
}
|
|
5236
|
-
return toObject;
|
|
5237
|
-
}
|
|
5238
5226
|
function computeTokensResponseFromVertex(apiClient, fromObject) {
|
|
5239
5227
|
const toObject = {};
|
|
5240
5228
|
const fromTokensInfo = getValueByPath(fromObject, ['tokensInfo']);
|
|
@@ -5868,7 +5856,7 @@ function mapToHeaders(map) {
|
|
|
5868
5856
|
const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
5869
5857
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
5870
5858
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
5871
|
-
const SDK_VERSION = '0.
|
|
5859
|
+
const SDK_VERSION = '0.4.0'; // x-release-please-version
|
|
5872
5860
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
5873
5861
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
5874
5862
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -6358,34 +6346,12 @@ class Files extends BaseModule {
|
|
|
6358
6346
|
});
|
|
6359
6347
|
}
|
|
6360
6348
|
async listInternal(params) {
|
|
6361
|
-
var _a
|
|
6349
|
+
var _a;
|
|
6362
6350
|
let response;
|
|
6363
6351
|
let path = '';
|
|
6364
6352
|
let queryParams = {};
|
|
6365
6353
|
if (this.apiClient.isVertexAI()) {
|
|
6366
|
-
|
|
6367
|
-
path = formatMap('None', body['_url']);
|
|
6368
|
-
queryParams = body['_query'];
|
|
6369
|
-
delete body['config'];
|
|
6370
|
-
delete body['_url'];
|
|
6371
|
-
delete body['_query'];
|
|
6372
|
-
response = this.apiClient
|
|
6373
|
-
.request({
|
|
6374
|
-
path: path,
|
|
6375
|
-
queryParams: queryParams,
|
|
6376
|
-
body: JSON.stringify(body),
|
|
6377
|
-
httpMethod: 'GET',
|
|
6378
|
-
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
6379
|
-
})
|
|
6380
|
-
.then((httpResponse) => {
|
|
6381
|
-
return httpResponse.json();
|
|
6382
|
-
});
|
|
6383
|
-
return response.then((apiResponse) => {
|
|
6384
|
-
const resp = listFilesResponseFromVertex(this.apiClient);
|
|
6385
|
-
const typedResp = new ListFilesResponse();
|
|
6386
|
-
Object.assign(typedResp, resp);
|
|
6387
|
-
return typedResp;
|
|
6388
|
-
});
|
|
6354
|
+
throw new Error('This method is only supported by the Gemini Developer API.');
|
|
6389
6355
|
}
|
|
6390
6356
|
else {
|
|
6391
6357
|
const body = listFilesParametersToMldev(this.apiClient, params);
|
|
@@ -6400,7 +6366,7 @@ class Files extends BaseModule {
|
|
|
6400
6366
|
queryParams: queryParams,
|
|
6401
6367
|
body: JSON.stringify(body),
|
|
6402
6368
|
httpMethod: 'GET',
|
|
6403
|
-
httpOptions: (
|
|
6369
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
6404
6370
|
})
|
|
6405
6371
|
.then((httpResponse) => {
|
|
6406
6372
|
return httpResponse.json();
|
|
@@ -6414,34 +6380,12 @@ class Files extends BaseModule {
|
|
|
6414
6380
|
}
|
|
6415
6381
|
}
|
|
6416
6382
|
async createInternal(params) {
|
|
6417
|
-
var _a
|
|
6383
|
+
var _a;
|
|
6418
6384
|
let response;
|
|
6419
6385
|
let path = '';
|
|
6420
6386
|
let queryParams = {};
|
|
6421
6387
|
if (this.apiClient.isVertexAI()) {
|
|
6422
|
-
|
|
6423
|
-
path = formatMap('', body['_url']);
|
|
6424
|
-
queryParams = body['_query'];
|
|
6425
|
-
delete body['config'];
|
|
6426
|
-
delete body['_url'];
|
|
6427
|
-
delete body['_query'];
|
|
6428
|
-
response = this.apiClient
|
|
6429
|
-
.request({
|
|
6430
|
-
path: path,
|
|
6431
|
-
queryParams: queryParams,
|
|
6432
|
-
body: JSON.stringify(body),
|
|
6433
|
-
httpMethod: 'POST',
|
|
6434
|
-
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
6435
|
-
})
|
|
6436
|
-
.then((httpResponse) => {
|
|
6437
|
-
return httpResponse.json();
|
|
6438
|
-
});
|
|
6439
|
-
return response.then((apiResponse) => {
|
|
6440
|
-
const resp = createFileResponseFromVertex(this.apiClient, apiResponse);
|
|
6441
|
-
const typedResp = new CreateFileResponse();
|
|
6442
|
-
Object.assign(typedResp, resp);
|
|
6443
|
-
return typedResp;
|
|
6444
|
-
});
|
|
6388
|
+
throw new Error('This method is only supported by the Gemini Developer API.');
|
|
6445
6389
|
}
|
|
6446
6390
|
else {
|
|
6447
6391
|
const body = createFileParametersToMldev(this.apiClient, params);
|
|
@@ -6456,7 +6400,7 @@ class Files extends BaseModule {
|
|
|
6456
6400
|
queryParams: queryParams,
|
|
6457
6401
|
body: JSON.stringify(body),
|
|
6458
6402
|
httpMethod: 'POST',
|
|
6459
|
-
httpOptions: (
|
|
6403
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
6460
6404
|
})
|
|
6461
6405
|
.then((httpResponse) => {
|
|
6462
6406
|
return httpResponse.json();
|
|
@@ -6485,32 +6429,12 @@ class Files extends BaseModule {
|
|
|
6485
6429
|
* ```
|
|
6486
6430
|
*/
|
|
6487
6431
|
async get(params) {
|
|
6488
|
-
var _a
|
|
6432
|
+
var _a;
|
|
6489
6433
|
let response;
|
|
6490
6434
|
let path = '';
|
|
6491
6435
|
let queryParams = {};
|
|
6492
6436
|
if (this.apiClient.isVertexAI()) {
|
|
6493
|
-
|
|
6494
|
-
path = formatMap('None', body['_url']);
|
|
6495
|
-
queryParams = body['_query'];
|
|
6496
|
-
delete body['config'];
|
|
6497
|
-
delete body['_url'];
|
|
6498
|
-
delete body['_query'];
|
|
6499
|
-
response = this.apiClient
|
|
6500
|
-
.request({
|
|
6501
|
-
path: path,
|
|
6502
|
-
queryParams: queryParams,
|
|
6503
|
-
body: JSON.stringify(body),
|
|
6504
|
-
httpMethod: 'GET',
|
|
6505
|
-
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
6506
|
-
})
|
|
6507
|
-
.then((httpResponse) => {
|
|
6508
|
-
return httpResponse.json();
|
|
6509
|
-
});
|
|
6510
|
-
return response.then((apiResponse) => {
|
|
6511
|
-
const resp = fileFromVertex(this.apiClient);
|
|
6512
|
-
return resp;
|
|
6513
|
-
});
|
|
6437
|
+
throw new Error('This method is only supported by the Gemini Developer API.');
|
|
6514
6438
|
}
|
|
6515
6439
|
else {
|
|
6516
6440
|
const body = getFileParametersToMldev(this.apiClient, params);
|
|
@@ -6525,7 +6449,7 @@ class Files extends BaseModule {
|
|
|
6525
6449
|
queryParams: queryParams,
|
|
6526
6450
|
body: JSON.stringify(body),
|
|
6527
6451
|
httpMethod: 'GET',
|
|
6528
|
-
httpOptions: (
|
|
6452
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
6529
6453
|
})
|
|
6530
6454
|
.then((httpResponse) => {
|
|
6531
6455
|
return httpResponse.json();
|
|
@@ -6557,13 +6481,6 @@ function listFilesParametersToMldev(apiClient, fromObject) {
|
|
|
6557
6481
|
}
|
|
6558
6482
|
return toObject;
|
|
6559
6483
|
}
|
|
6560
|
-
function listFilesParametersToVertex(apiClient, fromObject) {
|
|
6561
|
-
const toObject = {};
|
|
6562
|
-
if (getValueByPath(fromObject, ['config']) !== undefined) {
|
|
6563
|
-
throw new Error('config parameter is not supported in Vertex AI.');
|
|
6564
|
-
}
|
|
6565
|
-
return toObject;
|
|
6566
|
-
}
|
|
6567
6484
|
function fileStatusToMldev(apiClient, fromObject) {
|
|
6568
6485
|
const toObject = {};
|
|
6569
6486
|
const fromDetails = getValueByPath(fromObject, ['details']);
|
|
@@ -6656,16 +6573,6 @@ function createFileParametersToMldev(apiClient, fromObject) {
|
|
|
6656
6573
|
}
|
|
6657
6574
|
return toObject;
|
|
6658
6575
|
}
|
|
6659
|
-
function createFileParametersToVertex(apiClient, fromObject) {
|
|
6660
|
-
const toObject = {};
|
|
6661
|
-
if (getValueByPath(fromObject, ['file']) !== undefined) {
|
|
6662
|
-
throw new Error('file parameter is not supported in Vertex AI.');
|
|
6663
|
-
}
|
|
6664
|
-
if (getValueByPath(fromObject, ['config']) !== undefined) {
|
|
6665
|
-
throw new Error('config parameter is not supported in Vertex AI.');
|
|
6666
|
-
}
|
|
6667
|
-
return toObject;
|
|
6668
|
-
}
|
|
6669
6576
|
function getFileParametersToMldev(apiClient, fromObject) {
|
|
6670
6577
|
const toObject = {};
|
|
6671
6578
|
const fromName = getValueByPath(fromObject, ['name']);
|
|
@@ -6678,16 +6585,6 @@ function getFileParametersToMldev(apiClient, fromObject) {
|
|
|
6678
6585
|
}
|
|
6679
6586
|
return toObject;
|
|
6680
6587
|
}
|
|
6681
|
-
function getFileParametersToVertex(apiClient, fromObject) {
|
|
6682
|
-
const toObject = {};
|
|
6683
|
-
if (getValueByPath(fromObject, ['name']) !== undefined) {
|
|
6684
|
-
throw new Error('name parameter is not supported in Vertex AI.');
|
|
6685
|
-
}
|
|
6686
|
-
if (getValueByPath(fromObject, ['config']) !== undefined) {
|
|
6687
|
-
throw new Error('config parameter is not supported in Vertex AI.');
|
|
6688
|
-
}
|
|
6689
|
-
return toObject;
|
|
6690
|
-
}
|
|
6691
6588
|
function fileStatusFromMldev(apiClient, fromObject) {
|
|
6692
6589
|
const toObject = {};
|
|
6693
6590
|
const fromDetails = getValueByPath(fromObject, ['details']);
|
|
@@ -6768,10 +6665,6 @@ function fileFromMldev(apiClient, fromObject) {
|
|
|
6768
6665
|
}
|
|
6769
6666
|
return toObject;
|
|
6770
6667
|
}
|
|
6771
|
-
function fileFromVertex(apiClient, fromObject) {
|
|
6772
|
-
const toObject = {};
|
|
6773
|
-
return toObject;
|
|
6774
|
-
}
|
|
6775
6668
|
function listFilesResponseFromMldev(apiClient, fromObject) {
|
|
6776
6669
|
const toObject = {};
|
|
6777
6670
|
const fromNextPageToken = getValueByPath(fromObject, [
|
|
@@ -6793,10 +6686,6 @@ function listFilesResponseFromMldev(apiClient, fromObject) {
|
|
|
6793
6686
|
}
|
|
6794
6687
|
return toObject;
|
|
6795
6688
|
}
|
|
6796
|
-
function listFilesResponseFromVertex(apiClient, fromObject) {
|
|
6797
|
-
const toObject = {};
|
|
6798
|
-
return toObject;
|
|
6799
|
-
}
|
|
6800
6689
|
function createFileResponseFromMldev(apiClient, fromObject) {
|
|
6801
6690
|
const toObject = {};
|
|
6802
6691
|
const fromHttpHeaders = getValueByPath(fromObject, ['httpHeaders']);
|
|
@@ -6805,14 +6694,6 @@ function createFileResponseFromMldev(apiClient, fromObject) {
|
|
|
6805
6694
|
}
|
|
6806
6695
|
return toObject;
|
|
6807
6696
|
}
|
|
6808
|
-
function createFileResponseFromVertex(apiClient, fromObject) {
|
|
6809
|
-
const toObject = {};
|
|
6810
|
-
const fromHttpHeaders = getValueByPath(fromObject, ['httpHeaders']);
|
|
6811
|
-
if (fromHttpHeaders != null) {
|
|
6812
|
-
setValueByPath(toObject, ['httpHeaders'], fromHttpHeaders);
|
|
6813
|
-
}
|
|
6814
|
-
return toObject;
|
|
6815
|
-
}
|
|
6816
6697
|
|
|
6817
6698
|
/**
|
|
6818
6699
|
* @license
|
|
@@ -7009,6 +6890,9 @@ class GoogleGenAI {
|
|
|
7009
6890
|
throw new Error('An API Key must be set when running in a browser');
|
|
7010
6891
|
}
|
|
7011
6892
|
this.vertexai = (_a = options.vertexai) !== null && _a !== void 0 ? _a : false;
|
|
6893
|
+
if (this.vertexai) {
|
|
6894
|
+
throw new Error("VertexAI browser support is not yet implemented, it's coming soon!");
|
|
6895
|
+
}
|
|
7012
6896
|
this.apiKey = options.apiKey;
|
|
7013
6897
|
this.apiVersion = options.apiVersion;
|
|
7014
6898
|
const auth = new WebAuth(this.apiKey);
|
|
@@ -7029,5 +6913,5 @@ class GoogleGenAI {
|
|
|
7029
6913
|
}
|
|
7030
6914
|
}
|
|
7031
6915
|
|
|
7032
|
-
export { BlockedReason, Caches, Chat, Chats, ComputeTokensResponse, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DynamicRetrievalConfigMode, EmbedContentResponse, FileSource, FileState, FinishReason, FunctionCallingConfigMode, FunctionResponse, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpResponse, ImagePromptLanguage, Language, ListCachedContentsResponse, ListFilesResponse, Live, LiveClientToolResponse, MaskReferenceMode, MediaResolution, Modality, Mode, Models, Outcome, PersonGeneration, ReplayResponse, SafetyFilterLevel, Session, SessionSendToolResponseParameters, State, SubjectReferenceType, Type, contentToMldev$1 as contentToMldev, contentToVertex$1 as contentToVertex, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri,
|
|
6916
|
+
export { BlockedReason, Caches, Chat, Chats, ComputeTokensResponse, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DynamicRetrievalConfigMode, EmbedContentResponse, FileSource, FileState, FinishReason, FunctionCallingConfigMode, FunctionResponse, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpResponse, ImagePromptLanguage, Language, ListCachedContentsResponse, ListFilesResponse, Live, LiveClientToolResponse, MaskReferenceMode, MediaResolution, Modality, Mode, Models, Outcome, PersonGeneration, ReplayResponse, SafetyFilterLevel, Session, SessionSendToolResponseParameters, State, SubjectReferenceType, Type, contentToMldev$1 as contentToMldev, contentToVertex$1 as contentToVertex, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, toolToMldev$1 as toolToMldev, toolToVertex$1 as toolToVertex };
|
|
7033
6917
|
//# sourceMappingURL=index.mjs.map
|