@google/genai 1.50.1 → 1.52.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 +12 -12
- package/dist/genai.d.ts +199 -101
- package/dist/index.cjs +207 -146
- package/dist/index.mjs +208 -147
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.cjs +235 -156
- package/dist/node/index.mjs +236 -157
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/node.d.ts +199 -101
- package/dist/tokenizer/node.cjs +15 -1
- package/dist/tokenizer/node.d.ts +1 -1
- package/dist/tokenizer/node.mjs +15 -1
- package/dist/tokenizer/node.mjs.map +1 -1
- package/dist/vertex_internal/index.cjs +130 -117
- package/dist/vertex_internal/index.cjs.map +1 -1
- package/dist/vertex_internal/index.d.ts +97 -24
- package/dist/vertex_internal/index.js +130 -117
- package/dist/vertex_internal/index.js.map +1 -1
- package/dist/web/index.mjs +201 -145
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +199 -101
- package/package.json +6 -1
|
@@ -295,60 +295,6 @@ function _moveValueRecursive(data, sourceKeys, destKeys, keyIdx, excludeKeys) {
|
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
297
|
|
|
298
|
-
/**
|
|
299
|
-
* @license
|
|
300
|
-
* Copyright 2025 Google LLC
|
|
301
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
302
|
-
*/
|
|
303
|
-
// Code generated by the Google Gen AI SDK generator DO NOT EDIT.
|
|
304
|
-
function uploadToFileSearchStoreConfigToMldev(fromObject, parentObject) {
|
|
305
|
-
const toObject = {};
|
|
306
|
-
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
307
|
-
if (parentObject !== undefined && fromMimeType != null) {
|
|
308
|
-
setValueByPath(parentObject, ['mimeType'], fromMimeType);
|
|
309
|
-
}
|
|
310
|
-
const fromDisplayName = getValueByPath(fromObject, ['displayName']);
|
|
311
|
-
if (parentObject !== undefined && fromDisplayName != null) {
|
|
312
|
-
setValueByPath(parentObject, ['displayName'], fromDisplayName);
|
|
313
|
-
}
|
|
314
|
-
const fromCustomMetadata = getValueByPath(fromObject, [
|
|
315
|
-
'customMetadata',
|
|
316
|
-
]);
|
|
317
|
-
if (parentObject !== undefined && fromCustomMetadata != null) {
|
|
318
|
-
let transformedList = fromCustomMetadata;
|
|
319
|
-
if (Array.isArray(transformedList)) {
|
|
320
|
-
transformedList = transformedList.map((item) => {
|
|
321
|
-
return item;
|
|
322
|
-
});
|
|
323
|
-
}
|
|
324
|
-
setValueByPath(parentObject, ['customMetadata'], transformedList);
|
|
325
|
-
}
|
|
326
|
-
const fromChunkingConfig = getValueByPath(fromObject, [
|
|
327
|
-
'chunkingConfig',
|
|
328
|
-
]);
|
|
329
|
-
if (parentObject !== undefined && fromChunkingConfig != null) {
|
|
330
|
-
setValueByPath(parentObject, ['chunkingConfig'], fromChunkingConfig);
|
|
331
|
-
}
|
|
332
|
-
return toObject;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
/**
|
|
336
|
-
* @license
|
|
337
|
-
* Copyright 2025 Google LLC
|
|
338
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
339
|
-
*/
|
|
340
|
-
/**
|
|
341
|
-
* API errors raised by the GenAI API.
|
|
342
|
-
*/
|
|
343
|
-
class ApiError extends Error {
|
|
344
|
-
constructor(options) {
|
|
345
|
-
super(options.message);
|
|
346
|
-
this.name = 'ApiError';
|
|
347
|
-
this.status = options.status;
|
|
348
|
-
Object.setPrototypeOf(this, ApiError.prototype);
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
|
|
352
298
|
/**
|
|
353
299
|
* @license
|
|
354
300
|
* Copyright 2025 Google LLC
|
|
@@ -1419,7 +1365,7 @@ var FeatureSelectionPreference;
|
|
|
1419
1365
|
FeatureSelectionPreference["BALANCED"] = "BALANCED";
|
|
1420
1366
|
FeatureSelectionPreference["PRIORITIZE_COST"] = "PRIORITIZE_COST";
|
|
1421
1367
|
})(FeatureSelectionPreference || (FeatureSelectionPreference = {}));
|
|
1422
|
-
/** Enum representing the
|
|
1368
|
+
/** Enum representing the Gemini Enterprise Agent Platform embedding API to use. */
|
|
1423
1369
|
var EmbeddingApiType;
|
|
1424
1370
|
(function (EmbeddingApiType) {
|
|
1425
1371
|
/**
|
|
@@ -1577,6 +1523,20 @@ var VideoCompressionQuality;
|
|
|
1577
1523
|
*/
|
|
1578
1524
|
VideoCompressionQuality["LOSSLESS"] = "LOSSLESS";
|
|
1579
1525
|
})(VideoCompressionQuality || (VideoCompressionQuality = {}));
|
|
1526
|
+
/** Resize mode for the image input for video generation. */
|
|
1527
|
+
var ImageResizeMode;
|
|
1528
|
+
(function (ImageResizeMode) {
|
|
1529
|
+
/**
|
|
1530
|
+
* Crop the image to fit the correct aspect ratio (so we lose parts
|
|
1531
|
+
of the image in the process).
|
|
1532
|
+
*/
|
|
1533
|
+
ImageResizeMode["CROP"] = "CROP";
|
|
1534
|
+
/**
|
|
1535
|
+
* Pad the image to fit the correct aspect ratio (so we don't lose
|
|
1536
|
+
any parts of the image in the process).
|
|
1537
|
+
*/
|
|
1538
|
+
ImageResizeMode["PAD"] = "PAD";
|
|
1539
|
+
})(ImageResizeMode || (ImageResizeMode = {}));
|
|
1580
1540
|
/** Enum representing the tuning method. */
|
|
1581
1541
|
var TuningMethod;
|
|
1582
1542
|
(function (TuningMethod) {
|
|
@@ -1988,6 +1948,120 @@ class UploadToFileSearchStoreOperation {
|
|
|
1988
1948
|
}
|
|
1989
1949
|
}
|
|
1990
1950
|
|
|
1951
|
+
/**
|
|
1952
|
+
* @license
|
|
1953
|
+
* Copyright 2025 Google LLC
|
|
1954
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
1955
|
+
*/
|
|
1956
|
+
function _isFile(origin) {
|
|
1957
|
+
return (origin !== null &&
|
|
1958
|
+
origin !== undefined &&
|
|
1959
|
+
typeof origin === 'object' &&
|
|
1960
|
+
'name' in origin);
|
|
1961
|
+
}
|
|
1962
|
+
function isGeneratedVideo(origin) {
|
|
1963
|
+
return (origin !== null &&
|
|
1964
|
+
origin !== undefined &&
|
|
1965
|
+
typeof origin === 'object' &&
|
|
1966
|
+
'video' in origin);
|
|
1967
|
+
}
|
|
1968
|
+
function isVideo(origin) {
|
|
1969
|
+
return (origin !== null &&
|
|
1970
|
+
origin !== undefined &&
|
|
1971
|
+
typeof origin === 'object' &&
|
|
1972
|
+
'uri' in origin);
|
|
1973
|
+
}
|
|
1974
|
+
function tFileName(fromName) {
|
|
1975
|
+
var _a;
|
|
1976
|
+
let name;
|
|
1977
|
+
if (_isFile(fromName)) {
|
|
1978
|
+
name = fromName.name;
|
|
1979
|
+
}
|
|
1980
|
+
if (isVideo(fromName)) {
|
|
1981
|
+
name = fromName.uri;
|
|
1982
|
+
if (name === undefined) {
|
|
1983
|
+
return undefined;
|
|
1984
|
+
}
|
|
1985
|
+
}
|
|
1986
|
+
if (isGeneratedVideo(fromName)) {
|
|
1987
|
+
name = (_a = fromName.video) === null || _a === void 0 ? void 0 : _a.uri;
|
|
1988
|
+
if (name === undefined) {
|
|
1989
|
+
return undefined;
|
|
1990
|
+
}
|
|
1991
|
+
}
|
|
1992
|
+
if (typeof fromName === 'string') {
|
|
1993
|
+
name = fromName;
|
|
1994
|
+
}
|
|
1995
|
+
if (name === undefined) {
|
|
1996
|
+
throw new Error('Could not extract file name from the provided input.');
|
|
1997
|
+
}
|
|
1998
|
+
if (name.startsWith('https://')) {
|
|
1999
|
+
const suffix = name.split('files/')[1];
|
|
2000
|
+
const match = suffix.match(/[a-z0-9]+/);
|
|
2001
|
+
if (match === null) {
|
|
2002
|
+
throw new Error(`Could not extract file name from URI ${name}`);
|
|
2003
|
+
}
|
|
2004
|
+
name = match[0];
|
|
2005
|
+
}
|
|
2006
|
+
else if (name.startsWith('files/')) {
|
|
2007
|
+
name = name.split('files/')[1];
|
|
2008
|
+
}
|
|
2009
|
+
return name;
|
|
2010
|
+
}
|
|
2011
|
+
|
|
2012
|
+
/**
|
|
2013
|
+
* @license
|
|
2014
|
+
* Copyright 2025 Google LLC
|
|
2015
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
2016
|
+
*/
|
|
2017
|
+
function uploadToFileSearchStoreConfigToMldev(fromObject, parentObject) {
|
|
2018
|
+
const toObject = {};
|
|
2019
|
+
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
2020
|
+
if (parentObject !== undefined && fromMimeType != null) {
|
|
2021
|
+
setValueByPath(parentObject, ['mimeType'], fromMimeType);
|
|
2022
|
+
}
|
|
2023
|
+
const fromDisplayName = getValueByPath(fromObject, ['displayName']);
|
|
2024
|
+
if (parentObject !== undefined && fromDisplayName != null) {
|
|
2025
|
+
setValueByPath(parentObject, ['displayName'], fromDisplayName);
|
|
2026
|
+
}
|
|
2027
|
+
const fromCustomMetadata = getValueByPath(fromObject, [
|
|
2028
|
+
'customMetadata',
|
|
2029
|
+
]);
|
|
2030
|
+
if (parentObject !== undefined && fromCustomMetadata != null) {
|
|
2031
|
+
let transformedList = fromCustomMetadata;
|
|
2032
|
+
if (Array.isArray(transformedList)) {
|
|
2033
|
+
transformedList = transformedList.map((item) => {
|
|
2034
|
+
return item;
|
|
2035
|
+
});
|
|
2036
|
+
}
|
|
2037
|
+
setValueByPath(parentObject, ['customMetadata'], transformedList);
|
|
2038
|
+
}
|
|
2039
|
+
const fromChunkingConfig = getValueByPath(fromObject, [
|
|
2040
|
+
'chunkingConfig',
|
|
2041
|
+
]);
|
|
2042
|
+
if (parentObject !== undefined && fromChunkingConfig != null) {
|
|
2043
|
+
setValueByPath(parentObject, ['chunkingConfig'], fromChunkingConfig);
|
|
2044
|
+
}
|
|
2045
|
+
return toObject;
|
|
2046
|
+
}
|
|
2047
|
+
|
|
2048
|
+
/**
|
|
2049
|
+
* @license
|
|
2050
|
+
* Copyright 2025 Google LLC
|
|
2051
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
2052
|
+
*/
|
|
2053
|
+
/**
|
|
2054
|
+
* API errors raised by the GenAI API.
|
|
2055
|
+
*/
|
|
2056
|
+
class ApiError extends Error {
|
|
2057
|
+
constructor(options) {
|
|
2058
|
+
super(options.message);
|
|
2059
|
+
this.name = 'ApiError';
|
|
2060
|
+
this.status = options.status;
|
|
2061
|
+
Object.setPrototypeOf(this, ApiError.prototype);
|
|
2062
|
+
}
|
|
2063
|
+
}
|
|
2064
|
+
|
|
1991
2065
|
/**
|
|
1992
2066
|
* @license
|
|
1993
2067
|
* Copyright 2025 Google LLC
|
|
@@ -1997,7 +2071,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
1997
2071
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
1998
2072
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
1999
2073
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
2000
|
-
const SDK_VERSION = '1.
|
|
2074
|
+
const SDK_VERSION = '1.52.0'; // x-release-please-version
|
|
2001
2075
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
2002
2076
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
2003
2077
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -2746,67 +2820,6 @@ function buildGoogleAuthOptions(googleAuthOptions) {
|
|
|
2746
2820
|
}
|
|
2747
2821
|
}
|
|
2748
2822
|
|
|
2749
|
-
/**
|
|
2750
|
-
* @license
|
|
2751
|
-
* Copyright 2025 Google LLC
|
|
2752
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
2753
|
-
*/
|
|
2754
|
-
function _isFile(origin) {
|
|
2755
|
-
return (origin !== null &&
|
|
2756
|
-
origin !== undefined &&
|
|
2757
|
-
typeof origin === 'object' &&
|
|
2758
|
-
'name' in origin);
|
|
2759
|
-
}
|
|
2760
|
-
function isGeneratedVideo(origin) {
|
|
2761
|
-
return (origin !== null &&
|
|
2762
|
-
origin !== undefined &&
|
|
2763
|
-
typeof origin === 'object' &&
|
|
2764
|
-
'video' in origin);
|
|
2765
|
-
}
|
|
2766
|
-
function isVideo(origin) {
|
|
2767
|
-
return (origin !== null &&
|
|
2768
|
-
origin !== undefined &&
|
|
2769
|
-
typeof origin === 'object' &&
|
|
2770
|
-
'uri' in origin);
|
|
2771
|
-
}
|
|
2772
|
-
function tFileName(fromName) {
|
|
2773
|
-
var _a;
|
|
2774
|
-
let name;
|
|
2775
|
-
if (_isFile(fromName)) {
|
|
2776
|
-
name = fromName.name;
|
|
2777
|
-
}
|
|
2778
|
-
if (isVideo(fromName)) {
|
|
2779
|
-
name = fromName.uri;
|
|
2780
|
-
if (name === undefined) {
|
|
2781
|
-
return undefined;
|
|
2782
|
-
}
|
|
2783
|
-
}
|
|
2784
|
-
if (isGeneratedVideo(fromName)) {
|
|
2785
|
-
name = (_a = fromName.video) === null || _a === void 0 ? void 0 : _a.uri;
|
|
2786
|
-
if (name === undefined) {
|
|
2787
|
-
return undefined;
|
|
2788
|
-
}
|
|
2789
|
-
}
|
|
2790
|
-
if (typeof fromName === 'string') {
|
|
2791
|
-
name = fromName;
|
|
2792
|
-
}
|
|
2793
|
-
if (name === undefined) {
|
|
2794
|
-
throw new Error('Could not extract file name from the provided input.');
|
|
2795
|
-
}
|
|
2796
|
-
if (name.startsWith('https://')) {
|
|
2797
|
-
const suffix = name.split('files/')[1];
|
|
2798
|
-
const match = suffix.match(/[a-z0-9]+/);
|
|
2799
|
-
if (match === null) {
|
|
2800
|
-
throw new Error(`Could not extract file name from URI ${name}`);
|
|
2801
|
-
}
|
|
2802
|
-
name = match[0];
|
|
2803
|
-
}
|
|
2804
|
-
else if (name.startsWith('files/')) {
|
|
2805
|
-
name = name.split('files/')[1];
|
|
2806
|
-
}
|
|
2807
|
-
return name;
|
|
2808
|
-
}
|
|
2809
|
-
|
|
2810
2823
|
/**
|
|
2811
2824
|
* @license
|
|
2812
2825
|
* Copyright 2025 Google LLC
|