@google/genai 1.51.0 → 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/dist/genai.d.ts +31 -0
- package/dist/index.cjs +51 -6
- package/dist/index.mjs +51 -6
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.cjs +51 -6
- package/dist/node/index.mjs +51 -6
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/node.d.ts +31 -0
- package/dist/tokenizer/node.mjs.map +1 -1
- package/dist/vertex_internal/index.cjs +115 -116
- package/dist/vertex_internal/index.cjs.map +1 -1
- package/dist/vertex_internal/index.d.ts +22 -0
- package/dist/vertex_internal/index.js +115 -116
- package/dist/vertex_internal/index.js.map +1 -1
- package/dist/web/index.mjs +51 -6
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +31 -0
- package/package.json +1 -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
|
|
@@ -2002,6 +1948,120 @@ class UploadToFileSearchStoreOperation {
|
|
|
2002
1948
|
}
|
|
2003
1949
|
}
|
|
2004
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
|
+
|
|
2005
2065
|
/**
|
|
2006
2066
|
* @license
|
|
2007
2067
|
* Copyright 2025 Google LLC
|
|
@@ -2011,7 +2071,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
2011
2071
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
2012
2072
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
2013
2073
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
2014
|
-
const SDK_VERSION = '1.
|
|
2074
|
+
const SDK_VERSION = '1.52.0'; // x-release-please-version
|
|
2015
2075
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
2016
2076
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
2017
2077
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -2760,67 +2820,6 @@ function buildGoogleAuthOptions(googleAuthOptions) {
|
|
|
2760
2820
|
}
|
|
2761
2821
|
}
|
|
2762
2822
|
|
|
2763
|
-
/**
|
|
2764
|
-
* @license
|
|
2765
|
-
* Copyright 2025 Google LLC
|
|
2766
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
2767
|
-
*/
|
|
2768
|
-
function _isFile(origin) {
|
|
2769
|
-
return (origin !== null &&
|
|
2770
|
-
origin !== undefined &&
|
|
2771
|
-
typeof origin === 'object' &&
|
|
2772
|
-
'name' in origin);
|
|
2773
|
-
}
|
|
2774
|
-
function isGeneratedVideo(origin) {
|
|
2775
|
-
return (origin !== null &&
|
|
2776
|
-
origin !== undefined &&
|
|
2777
|
-
typeof origin === 'object' &&
|
|
2778
|
-
'video' in origin);
|
|
2779
|
-
}
|
|
2780
|
-
function isVideo(origin) {
|
|
2781
|
-
return (origin !== null &&
|
|
2782
|
-
origin !== undefined &&
|
|
2783
|
-
typeof origin === 'object' &&
|
|
2784
|
-
'uri' in origin);
|
|
2785
|
-
}
|
|
2786
|
-
function tFileName(fromName) {
|
|
2787
|
-
var _a;
|
|
2788
|
-
let name;
|
|
2789
|
-
if (_isFile(fromName)) {
|
|
2790
|
-
name = fromName.name;
|
|
2791
|
-
}
|
|
2792
|
-
if (isVideo(fromName)) {
|
|
2793
|
-
name = fromName.uri;
|
|
2794
|
-
if (name === undefined) {
|
|
2795
|
-
return undefined;
|
|
2796
|
-
}
|
|
2797
|
-
}
|
|
2798
|
-
if (isGeneratedVideo(fromName)) {
|
|
2799
|
-
name = (_a = fromName.video) === null || _a === void 0 ? void 0 : _a.uri;
|
|
2800
|
-
if (name === undefined) {
|
|
2801
|
-
return undefined;
|
|
2802
|
-
}
|
|
2803
|
-
}
|
|
2804
|
-
if (typeof fromName === 'string') {
|
|
2805
|
-
name = fromName;
|
|
2806
|
-
}
|
|
2807
|
-
if (name === undefined) {
|
|
2808
|
-
throw new Error('Could not extract file name from the provided input.');
|
|
2809
|
-
}
|
|
2810
|
-
if (name.startsWith('https://')) {
|
|
2811
|
-
const suffix = name.split('files/')[1];
|
|
2812
|
-
const match = suffix.match(/[a-z0-9]+/);
|
|
2813
|
-
if (match === null) {
|
|
2814
|
-
throw new Error(`Could not extract file name from URI ${name}`);
|
|
2815
|
-
}
|
|
2816
|
-
name = match[0];
|
|
2817
|
-
}
|
|
2818
|
-
else if (name.startsWith('files/')) {
|
|
2819
|
-
name = name.split('files/')[1];
|
|
2820
|
-
}
|
|
2821
|
-
return name;
|
|
2822
|
-
}
|
|
2823
|
-
|
|
2824
2823
|
/**
|
|
2825
2824
|
* @license
|
|
2826
2825
|
* Copyright 2025 Google LLC
|