@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
|
@@ -1319,6 +1319,10 @@ declare interface CreateFileSearchStoreConfig {
|
|
|
1319
1319
|
/** The human-readable display name for the file search store.
|
|
1320
1320
|
*/
|
|
1321
1321
|
displayName?: string;
|
|
1322
|
+
/** The embedding model to use for the FileSearchStore.
|
|
1323
|
+
Format: `models/{model}`. If not specified, the default embedding model will be used.
|
|
1324
|
+
*/
|
|
1325
|
+
embeddingModel?: string;
|
|
1322
1326
|
}
|
|
1323
1327
|
|
|
1324
1328
|
/** Config for file_search_stores.create parameters. */
|
|
@@ -1842,6 +1846,19 @@ declare interface DownloadFileParameters {
|
|
|
1842
1846
|
config?: DownloadFileConfig;
|
|
1843
1847
|
}
|
|
1844
1848
|
|
|
1849
|
+
/** Used to override the default configuration. */
|
|
1850
|
+
declare interface DownloadMediaConfig {
|
|
1851
|
+
/** Used to override HTTP request options. */
|
|
1852
|
+
httpOptions?: HttpOptions;
|
|
1853
|
+
/** Abort signal which can be used to cancel the request.
|
|
1854
|
+
|
|
1855
|
+
NOTE: AbortSignal is a client-only operation. Using it to cancel an
|
|
1856
|
+
operation will not cancel the request in the service. You will still
|
|
1857
|
+
be charged usage for any applicable operations.
|
|
1858
|
+
*/
|
|
1859
|
+
abortSignal?: AbortSignal;
|
|
1860
|
+
}
|
|
1861
|
+
|
|
1845
1862
|
/** Describes the options to customize dynamic retrieval. */
|
|
1846
1863
|
declare interface DynamicRetrievalConfig {
|
|
1847
1864
|
/** Optional. The threshold to be used in dynamic retrieval. If not set, a system default value is used. */
|
|
@@ -2314,6 +2331,8 @@ declare interface FileSearchStore {
|
|
|
2314
2331
|
/** The size of raw bytes ingested into the FileSearchStore. This is the
|
|
2315
2332
|
total size of all the documents in the FileSearchStore. */
|
|
2316
2333
|
sizeBytes?: string;
|
|
2334
|
+
/** The embedding model used by the FileSearchStore. */
|
|
2335
|
+
embeddingModel?: string;
|
|
2317
2336
|
}
|
|
2318
2337
|
|
|
2319
2338
|
/** Source of the File. */
|
|
@@ -3660,6 +3679,8 @@ declare interface GroundingChunkRetrievedContext {
|
|
|
3660
3679
|
fileSearchStore?: string;
|
|
3661
3680
|
/** Optional. Page number of the retrieved context. This field is not supported in Vertex AI. */
|
|
3662
3681
|
pageNumber?: number;
|
|
3682
|
+
/** Optional. Media ID. This field is not supported in Vertex AI. */
|
|
3683
|
+
mediaId?: string;
|
|
3663
3684
|
}
|
|
3664
3685
|
|
|
3665
3686
|
/** A list of string values. This data type is not supported in Vertex AI. */
|
|
@@ -7804,6 +7825,7 @@ declare namespace types {
|
|
|
7804
7825
|
EmbedContentParameters,
|
|
7805
7826
|
UploadToFileSearchStoreResponse,
|
|
7806
7827
|
UploadToFileSearchStoreOperation,
|
|
7828
|
+
DownloadMediaConfig,
|
|
7807
7829
|
BlobImageUnion,
|
|
7808
7830
|
PartUnion,
|
|
7809
7831
|
PartListUnion,
|
|
@@ -274,60 +274,6 @@ function _moveValueRecursive(data, sourceKeys, destKeys, keyIdx, excludeKeys) {
|
|
|
274
274
|
}
|
|
275
275
|
}
|
|
276
276
|
|
|
277
|
-
/**
|
|
278
|
-
* @license
|
|
279
|
-
* Copyright 2025 Google LLC
|
|
280
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
281
|
-
*/
|
|
282
|
-
// Code generated by the Google Gen AI SDK generator DO NOT EDIT.
|
|
283
|
-
function uploadToFileSearchStoreConfigToMldev(fromObject, parentObject) {
|
|
284
|
-
const toObject = {};
|
|
285
|
-
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
286
|
-
if (parentObject !== undefined && fromMimeType != null) {
|
|
287
|
-
setValueByPath(parentObject, ['mimeType'], fromMimeType);
|
|
288
|
-
}
|
|
289
|
-
const fromDisplayName = getValueByPath(fromObject, ['displayName']);
|
|
290
|
-
if (parentObject !== undefined && fromDisplayName != null) {
|
|
291
|
-
setValueByPath(parentObject, ['displayName'], fromDisplayName);
|
|
292
|
-
}
|
|
293
|
-
const fromCustomMetadata = getValueByPath(fromObject, [
|
|
294
|
-
'customMetadata',
|
|
295
|
-
]);
|
|
296
|
-
if (parentObject !== undefined && fromCustomMetadata != null) {
|
|
297
|
-
let transformedList = fromCustomMetadata;
|
|
298
|
-
if (Array.isArray(transformedList)) {
|
|
299
|
-
transformedList = transformedList.map((item) => {
|
|
300
|
-
return item;
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
|
-
setValueByPath(parentObject, ['customMetadata'], transformedList);
|
|
304
|
-
}
|
|
305
|
-
const fromChunkingConfig = getValueByPath(fromObject, [
|
|
306
|
-
'chunkingConfig',
|
|
307
|
-
]);
|
|
308
|
-
if (parentObject !== undefined && fromChunkingConfig != null) {
|
|
309
|
-
setValueByPath(parentObject, ['chunkingConfig'], fromChunkingConfig);
|
|
310
|
-
}
|
|
311
|
-
return toObject;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
/**
|
|
315
|
-
* @license
|
|
316
|
-
* Copyright 2025 Google LLC
|
|
317
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
318
|
-
*/
|
|
319
|
-
/**
|
|
320
|
-
* API errors raised by the GenAI API.
|
|
321
|
-
*/
|
|
322
|
-
class ApiError extends Error {
|
|
323
|
-
constructor(options) {
|
|
324
|
-
super(options.message);
|
|
325
|
-
this.name = 'ApiError';
|
|
326
|
-
this.status = options.status;
|
|
327
|
-
Object.setPrototypeOf(this, ApiError.prototype);
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
|
|
331
277
|
/**
|
|
332
278
|
* @license
|
|
333
279
|
* Copyright 2025 Google LLC
|
|
@@ -1981,6 +1927,120 @@ class UploadToFileSearchStoreOperation {
|
|
|
1981
1927
|
}
|
|
1982
1928
|
}
|
|
1983
1929
|
|
|
1930
|
+
/**
|
|
1931
|
+
* @license
|
|
1932
|
+
* Copyright 2025 Google LLC
|
|
1933
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
1934
|
+
*/
|
|
1935
|
+
function _isFile(origin) {
|
|
1936
|
+
return (origin !== null &&
|
|
1937
|
+
origin !== undefined &&
|
|
1938
|
+
typeof origin === 'object' &&
|
|
1939
|
+
'name' in origin);
|
|
1940
|
+
}
|
|
1941
|
+
function isGeneratedVideo(origin) {
|
|
1942
|
+
return (origin !== null &&
|
|
1943
|
+
origin !== undefined &&
|
|
1944
|
+
typeof origin === 'object' &&
|
|
1945
|
+
'video' in origin);
|
|
1946
|
+
}
|
|
1947
|
+
function isVideo(origin) {
|
|
1948
|
+
return (origin !== null &&
|
|
1949
|
+
origin !== undefined &&
|
|
1950
|
+
typeof origin === 'object' &&
|
|
1951
|
+
'uri' in origin);
|
|
1952
|
+
}
|
|
1953
|
+
function tFileName(fromName) {
|
|
1954
|
+
var _a;
|
|
1955
|
+
let name;
|
|
1956
|
+
if (_isFile(fromName)) {
|
|
1957
|
+
name = fromName.name;
|
|
1958
|
+
}
|
|
1959
|
+
if (isVideo(fromName)) {
|
|
1960
|
+
name = fromName.uri;
|
|
1961
|
+
if (name === undefined) {
|
|
1962
|
+
return undefined;
|
|
1963
|
+
}
|
|
1964
|
+
}
|
|
1965
|
+
if (isGeneratedVideo(fromName)) {
|
|
1966
|
+
name = (_a = fromName.video) === null || _a === void 0 ? void 0 : _a.uri;
|
|
1967
|
+
if (name === undefined) {
|
|
1968
|
+
return undefined;
|
|
1969
|
+
}
|
|
1970
|
+
}
|
|
1971
|
+
if (typeof fromName === 'string') {
|
|
1972
|
+
name = fromName;
|
|
1973
|
+
}
|
|
1974
|
+
if (name === undefined) {
|
|
1975
|
+
throw new Error('Could not extract file name from the provided input.');
|
|
1976
|
+
}
|
|
1977
|
+
if (name.startsWith('https://')) {
|
|
1978
|
+
const suffix = name.split('files/')[1];
|
|
1979
|
+
const match = suffix.match(/[a-z0-9]+/);
|
|
1980
|
+
if (match === null) {
|
|
1981
|
+
throw new Error(`Could not extract file name from URI ${name}`);
|
|
1982
|
+
}
|
|
1983
|
+
name = match[0];
|
|
1984
|
+
}
|
|
1985
|
+
else if (name.startsWith('files/')) {
|
|
1986
|
+
name = name.split('files/')[1];
|
|
1987
|
+
}
|
|
1988
|
+
return name;
|
|
1989
|
+
}
|
|
1990
|
+
|
|
1991
|
+
/**
|
|
1992
|
+
* @license
|
|
1993
|
+
* Copyright 2025 Google LLC
|
|
1994
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
1995
|
+
*/
|
|
1996
|
+
function uploadToFileSearchStoreConfigToMldev(fromObject, parentObject) {
|
|
1997
|
+
const toObject = {};
|
|
1998
|
+
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
1999
|
+
if (parentObject !== undefined && fromMimeType != null) {
|
|
2000
|
+
setValueByPath(parentObject, ['mimeType'], fromMimeType);
|
|
2001
|
+
}
|
|
2002
|
+
const fromDisplayName = getValueByPath(fromObject, ['displayName']);
|
|
2003
|
+
if (parentObject !== undefined && fromDisplayName != null) {
|
|
2004
|
+
setValueByPath(parentObject, ['displayName'], fromDisplayName);
|
|
2005
|
+
}
|
|
2006
|
+
const fromCustomMetadata = getValueByPath(fromObject, [
|
|
2007
|
+
'customMetadata',
|
|
2008
|
+
]);
|
|
2009
|
+
if (parentObject !== undefined && fromCustomMetadata != null) {
|
|
2010
|
+
let transformedList = fromCustomMetadata;
|
|
2011
|
+
if (Array.isArray(transformedList)) {
|
|
2012
|
+
transformedList = transformedList.map((item) => {
|
|
2013
|
+
return item;
|
|
2014
|
+
});
|
|
2015
|
+
}
|
|
2016
|
+
setValueByPath(parentObject, ['customMetadata'], transformedList);
|
|
2017
|
+
}
|
|
2018
|
+
const fromChunkingConfig = getValueByPath(fromObject, [
|
|
2019
|
+
'chunkingConfig',
|
|
2020
|
+
]);
|
|
2021
|
+
if (parentObject !== undefined && fromChunkingConfig != null) {
|
|
2022
|
+
setValueByPath(parentObject, ['chunkingConfig'], fromChunkingConfig);
|
|
2023
|
+
}
|
|
2024
|
+
return toObject;
|
|
2025
|
+
}
|
|
2026
|
+
|
|
2027
|
+
/**
|
|
2028
|
+
* @license
|
|
2029
|
+
* Copyright 2025 Google LLC
|
|
2030
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
2031
|
+
*/
|
|
2032
|
+
/**
|
|
2033
|
+
* API errors raised by the GenAI API.
|
|
2034
|
+
*/
|
|
2035
|
+
class ApiError extends Error {
|
|
2036
|
+
constructor(options) {
|
|
2037
|
+
super(options.message);
|
|
2038
|
+
this.name = 'ApiError';
|
|
2039
|
+
this.status = options.status;
|
|
2040
|
+
Object.setPrototypeOf(this, ApiError.prototype);
|
|
2041
|
+
}
|
|
2042
|
+
}
|
|
2043
|
+
|
|
1984
2044
|
/**
|
|
1985
2045
|
* @license
|
|
1986
2046
|
* Copyright 2025 Google LLC
|
|
@@ -1990,7 +2050,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
1990
2050
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
1991
2051
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
1992
2052
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
1993
|
-
const SDK_VERSION = '1.
|
|
2053
|
+
const SDK_VERSION = '1.52.0'; // x-release-please-version
|
|
1994
2054
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
1995
2055
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
1996
2056
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -2739,67 +2799,6 @@ function buildGoogleAuthOptions(googleAuthOptions) {
|
|
|
2739
2799
|
}
|
|
2740
2800
|
}
|
|
2741
2801
|
|
|
2742
|
-
/**
|
|
2743
|
-
* @license
|
|
2744
|
-
* Copyright 2025 Google LLC
|
|
2745
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
2746
|
-
*/
|
|
2747
|
-
function _isFile(origin) {
|
|
2748
|
-
return (origin !== null &&
|
|
2749
|
-
origin !== undefined &&
|
|
2750
|
-
typeof origin === 'object' &&
|
|
2751
|
-
'name' in origin);
|
|
2752
|
-
}
|
|
2753
|
-
function isGeneratedVideo(origin) {
|
|
2754
|
-
return (origin !== null &&
|
|
2755
|
-
origin !== undefined &&
|
|
2756
|
-
typeof origin === 'object' &&
|
|
2757
|
-
'video' in origin);
|
|
2758
|
-
}
|
|
2759
|
-
function isVideo(origin) {
|
|
2760
|
-
return (origin !== null &&
|
|
2761
|
-
origin !== undefined &&
|
|
2762
|
-
typeof origin === 'object' &&
|
|
2763
|
-
'uri' in origin);
|
|
2764
|
-
}
|
|
2765
|
-
function tFileName(fromName) {
|
|
2766
|
-
var _a;
|
|
2767
|
-
let name;
|
|
2768
|
-
if (_isFile(fromName)) {
|
|
2769
|
-
name = fromName.name;
|
|
2770
|
-
}
|
|
2771
|
-
if (isVideo(fromName)) {
|
|
2772
|
-
name = fromName.uri;
|
|
2773
|
-
if (name === undefined) {
|
|
2774
|
-
return undefined;
|
|
2775
|
-
}
|
|
2776
|
-
}
|
|
2777
|
-
if (isGeneratedVideo(fromName)) {
|
|
2778
|
-
name = (_a = fromName.video) === null || _a === void 0 ? void 0 : _a.uri;
|
|
2779
|
-
if (name === undefined) {
|
|
2780
|
-
return undefined;
|
|
2781
|
-
}
|
|
2782
|
-
}
|
|
2783
|
-
if (typeof fromName === 'string') {
|
|
2784
|
-
name = fromName;
|
|
2785
|
-
}
|
|
2786
|
-
if (name === undefined) {
|
|
2787
|
-
throw new Error('Could not extract file name from the provided input.');
|
|
2788
|
-
}
|
|
2789
|
-
if (name.startsWith('https://')) {
|
|
2790
|
-
const suffix = name.split('files/')[1];
|
|
2791
|
-
const match = suffix.match(/[a-z0-9]+/);
|
|
2792
|
-
if (match === null) {
|
|
2793
|
-
throw new Error(`Could not extract file name from URI ${name}`);
|
|
2794
|
-
}
|
|
2795
|
-
name = match[0];
|
|
2796
|
-
}
|
|
2797
|
-
else if (name.startsWith('files/')) {
|
|
2798
|
-
name = name.split('files/')[1];
|
|
2799
|
-
}
|
|
2800
|
-
return name;
|
|
2801
|
-
}
|
|
2802
|
-
|
|
2803
2802
|
/**
|
|
2804
2803
|
* @license
|
|
2805
2804
|
* Copyright 2025 Google LLC
|