@google/genai 1.40.0 → 1.42.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 +89 -21
- package/dist/index.cjs +263 -37
- package/dist/index.mjs +264 -38
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.cjs +262 -37
- package/dist/node/index.mjs +263 -38
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/node.d.ts +89 -21
- package/dist/tokenizer/node.cjs +12 -0
- package/dist/tokenizer/node.d.ts +9 -0
- package/dist/tokenizer/node.mjs +12 -0
- package/dist/tokenizer/node.mjs.map +1 -1
- package/dist/web/index.mjs +264 -38
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +89 -21
- package/package.json +3 -2
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import pRetry, { AbortError } from 'p-retry';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* @license
|
|
3
5
|
* Copyright 2025 Google LLC
|
|
@@ -1326,6 +1328,18 @@ var Environment;
|
|
|
1326
1328
|
*/
|
|
1327
1329
|
Environment["ENVIRONMENT_BROWSER"] = "ENVIRONMENT_BROWSER";
|
|
1328
1330
|
})(Environment || (Environment = {}));
|
|
1331
|
+
/** Enum representing the Vertex embedding API to use. */
|
|
1332
|
+
var EmbeddingApiType;
|
|
1333
|
+
(function (EmbeddingApiType) {
|
|
1334
|
+
/**
|
|
1335
|
+
* predict API endpoint (default)
|
|
1336
|
+
*/
|
|
1337
|
+
EmbeddingApiType["PREDICT"] = "PREDICT";
|
|
1338
|
+
/**
|
|
1339
|
+
* embedContent API Endpoint
|
|
1340
|
+
*/
|
|
1341
|
+
EmbeddingApiType["EMBED_CONTENT"] = "EMBED_CONTENT";
|
|
1342
|
+
})(EmbeddingApiType || (EmbeddingApiType = {}));
|
|
1329
1343
|
/** Enum that controls the safety filter level for objectionable content. */
|
|
1330
1344
|
var SafetyFilterLevel;
|
|
1331
1345
|
(function (SafetyFilterLevel) {
|
|
@@ -3357,6 +3371,10 @@ function tJobState(state) {
|
|
|
3357
3371
|
return stateString;
|
|
3358
3372
|
}
|
|
3359
3373
|
}
|
|
3374
|
+
function tIsVertexEmbedContentModel(model) {
|
|
3375
|
+
return ((model.includes('gemini') && model !== 'gemini-embedding-001') ||
|
|
3376
|
+
model.includes('maas'));
|
|
3377
|
+
}
|
|
3360
3378
|
|
|
3361
3379
|
/**
|
|
3362
3380
|
* @license
|
|
@@ -6929,10 +6947,22 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
6929
6947
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
6930
6948
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
6931
6949
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
6932
|
-
const SDK_VERSION = '1.
|
|
6950
|
+
const SDK_VERSION = '1.42.0'; // x-release-please-version
|
|
6933
6951
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
6934
6952
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
6935
6953
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
6954
|
+
// Default retry options.
|
|
6955
|
+
// The config is based on https://cloud.google.com/storage/docs/retry-strategy.
|
|
6956
|
+
const DEFAULT_RETRY_ATTEMPTS = 5; // Including the initial call
|
|
6957
|
+
// LINT.IfChange
|
|
6958
|
+
const DEFAULT_RETRY_HTTP_STATUS_CODES = [
|
|
6959
|
+
408, // Request timeout
|
|
6960
|
+
429, // Too many requests
|
|
6961
|
+
500, // Internal server error
|
|
6962
|
+
502, // Bad gateway
|
|
6963
|
+
503, // Service unavailable
|
|
6964
|
+
504, // Gateway timeout
|
|
6965
|
+
];
|
|
6936
6966
|
/**
|
|
6937
6967
|
* The ApiClient class is used to send requests to the Gemini API or Vertex AI
|
|
6938
6968
|
* endpoints.
|
|
@@ -7317,8 +7347,25 @@ class ApiClient {
|
|
|
7317
7347
|
});
|
|
7318
7348
|
}
|
|
7319
7349
|
async apiCall(url, requestInit) {
|
|
7320
|
-
|
|
7321
|
-
|
|
7350
|
+
var _a;
|
|
7351
|
+
if (!this.clientOptions.httpOptions ||
|
|
7352
|
+
!this.clientOptions.httpOptions.retryOptions) {
|
|
7353
|
+
return fetch(url, requestInit);
|
|
7354
|
+
}
|
|
7355
|
+
const retryOptions = this.clientOptions.httpOptions.retryOptions;
|
|
7356
|
+
const runFetch = async () => {
|
|
7357
|
+
const response = await fetch(url, requestInit);
|
|
7358
|
+
if (response.ok) {
|
|
7359
|
+
return response;
|
|
7360
|
+
}
|
|
7361
|
+
if (DEFAULT_RETRY_HTTP_STATUS_CODES.includes(response.status)) {
|
|
7362
|
+
throw new Error(`Retryable HTTP Error: ${response.statusText}`);
|
|
7363
|
+
}
|
|
7364
|
+
throw new AbortError(`Non-retryable exception ${response.statusText} sending request`);
|
|
7365
|
+
};
|
|
7366
|
+
return pRetry(runFetch, {
|
|
7367
|
+
// Retry attempts is one less than the number of total attempts.
|
|
7368
|
+
retries: ((_a = retryOptions.attempts) !== null && _a !== void 0 ? _a : DEFAULT_RETRY_ATTEMPTS) - 1,
|
|
7322
7369
|
});
|
|
7323
7370
|
}
|
|
7324
7371
|
getDefaultHeaders() {
|
|
@@ -10479,7 +10526,7 @@ class BaseGeminiNextGenAPIClient {
|
|
|
10479
10526
|
}
|
|
10480
10527
|
async fetchWithTimeout(url, init, ms, controller) {
|
|
10481
10528
|
const _b = init || {}, { signal, method } = _b, options = __rest(_b, ["signal", "method"]);
|
|
10482
|
-
const abort =
|
|
10529
|
+
const abort = this._makeAbort(controller);
|
|
10483
10530
|
if (signal)
|
|
10484
10531
|
signal.addEventListener('abort', abort, { once: true });
|
|
10485
10532
|
const timeout = setTimeout(abort, ms);
|
|
@@ -10595,6 +10642,11 @@ class BaseGeminiNextGenAPIClient {
|
|
|
10595
10642
|
this.validateHeaders(headers);
|
|
10596
10643
|
return headers.values;
|
|
10597
10644
|
}
|
|
10645
|
+
_makeAbort(controller) {
|
|
10646
|
+
// note: we can't just inline this method inside `fetchWithTimeout()` because then the closure
|
|
10647
|
+
// would capture all request options, and cause a memory leak.
|
|
10648
|
+
return () => controller.abort();
|
|
10649
|
+
}
|
|
10598
10650
|
buildBody({ options: { body, headers: rawHeaders } }) {
|
|
10599
10651
|
if (!body) {
|
|
10600
10652
|
return { bodyHeaders: undefined, body: undefined };
|
|
@@ -10623,6 +10675,13 @@ class BaseGeminiNextGenAPIClient {
|
|
|
10623
10675
|
(Symbol.iterator in body && 'next' in body && typeof body.next === 'function'))) {
|
|
10624
10676
|
return { bodyHeaders: undefined, body: ReadableStreamFrom(body) };
|
|
10625
10677
|
}
|
|
10678
|
+
else if (typeof body === 'object' &&
|
|
10679
|
+
headers.values.get('content-type') === 'application/x-www-form-urlencoded') {
|
|
10680
|
+
return {
|
|
10681
|
+
bodyHeaders: { 'content-type': 'application/x-www-form-urlencoded' },
|
|
10682
|
+
body: this.stringifyQuery(body),
|
|
10683
|
+
};
|
|
10684
|
+
}
|
|
10626
10685
|
else {
|
|
10627
10686
|
return this.encoder({ body, headers });
|
|
10628
10687
|
}
|
|
@@ -12126,33 +12185,103 @@ function embedContentConfigToMldev(fromObject, parentObject, _rootObject) {
|
|
|
12126
12185
|
}
|
|
12127
12186
|
return toObject;
|
|
12128
12187
|
}
|
|
12129
|
-
function embedContentConfigToVertex(fromObject, parentObject,
|
|
12188
|
+
function embedContentConfigToVertex(fromObject, parentObject, rootObject) {
|
|
12130
12189
|
const toObject = {};
|
|
12131
|
-
|
|
12132
|
-
|
|
12133
|
-
|
|
12190
|
+
let discriminatorTaskType = getValueByPath(rootObject, [
|
|
12191
|
+
'embeddingApiType',
|
|
12192
|
+
]);
|
|
12193
|
+
if (discriminatorTaskType === undefined) {
|
|
12194
|
+
discriminatorTaskType = 'PREDICT';
|
|
12134
12195
|
}
|
|
12135
|
-
|
|
12136
|
-
|
|
12137
|
-
|
|
12196
|
+
if (discriminatorTaskType === 'PREDICT') {
|
|
12197
|
+
const fromTaskType = getValueByPath(fromObject, ['taskType']);
|
|
12198
|
+
if (parentObject !== undefined && fromTaskType != null) {
|
|
12199
|
+
setValueByPath(parentObject, ['instances[]', 'task_type'], fromTaskType);
|
|
12200
|
+
}
|
|
12138
12201
|
}
|
|
12139
|
-
|
|
12140
|
-
'
|
|
12202
|
+
else if (discriminatorTaskType === 'EMBED_CONTENT') {
|
|
12203
|
+
const fromTaskType = getValueByPath(fromObject, ['taskType']);
|
|
12204
|
+
if (parentObject !== undefined && fromTaskType != null) {
|
|
12205
|
+
setValueByPath(parentObject, ['taskType'], fromTaskType);
|
|
12206
|
+
}
|
|
12207
|
+
}
|
|
12208
|
+
let discriminatorTitle = getValueByPath(rootObject, [
|
|
12209
|
+
'embeddingApiType',
|
|
12141
12210
|
]);
|
|
12142
|
-
if (
|
|
12143
|
-
|
|
12211
|
+
if (discriminatorTitle === undefined) {
|
|
12212
|
+
discriminatorTitle = 'PREDICT';
|
|
12144
12213
|
}
|
|
12145
|
-
|
|
12146
|
-
|
|
12147
|
-
|
|
12214
|
+
if (discriminatorTitle === 'PREDICT') {
|
|
12215
|
+
const fromTitle = getValueByPath(fromObject, ['title']);
|
|
12216
|
+
if (parentObject !== undefined && fromTitle != null) {
|
|
12217
|
+
setValueByPath(parentObject, ['instances[]', 'title'], fromTitle);
|
|
12218
|
+
}
|
|
12148
12219
|
}
|
|
12149
|
-
|
|
12150
|
-
|
|
12151
|
-
|
|
12220
|
+
else if (discriminatorTitle === 'EMBED_CONTENT') {
|
|
12221
|
+
const fromTitle = getValueByPath(fromObject, ['title']);
|
|
12222
|
+
if (parentObject !== undefined && fromTitle != null) {
|
|
12223
|
+
setValueByPath(parentObject, ['title'], fromTitle);
|
|
12224
|
+
}
|
|
12225
|
+
}
|
|
12226
|
+
let discriminatorOutputDimensionality = getValueByPath(rootObject, [
|
|
12227
|
+
'embeddingApiType',
|
|
12228
|
+
]);
|
|
12229
|
+
if (discriminatorOutputDimensionality === undefined) {
|
|
12230
|
+
discriminatorOutputDimensionality = 'PREDICT';
|
|
12231
|
+
}
|
|
12232
|
+
if (discriminatorOutputDimensionality === 'PREDICT') {
|
|
12233
|
+
const fromOutputDimensionality = getValueByPath(fromObject, [
|
|
12234
|
+
'outputDimensionality',
|
|
12235
|
+
]);
|
|
12236
|
+
if (parentObject !== undefined && fromOutputDimensionality != null) {
|
|
12237
|
+
setValueByPath(parentObject, ['parameters', 'outputDimensionality'], fromOutputDimensionality);
|
|
12238
|
+
}
|
|
12239
|
+
}
|
|
12240
|
+
else if (discriminatorOutputDimensionality === 'EMBED_CONTENT') {
|
|
12241
|
+
const fromOutputDimensionality = getValueByPath(fromObject, [
|
|
12242
|
+
'outputDimensionality',
|
|
12243
|
+
]);
|
|
12244
|
+
if (parentObject !== undefined && fromOutputDimensionality != null) {
|
|
12245
|
+
setValueByPath(parentObject, ['outputDimensionality'], fromOutputDimensionality);
|
|
12246
|
+
}
|
|
12247
|
+
}
|
|
12248
|
+
let discriminatorMimeType = getValueByPath(rootObject, [
|
|
12249
|
+
'embeddingApiType',
|
|
12250
|
+
]);
|
|
12251
|
+
if (discriminatorMimeType === undefined) {
|
|
12252
|
+
discriminatorMimeType = 'PREDICT';
|
|
12253
|
+
}
|
|
12254
|
+
if (discriminatorMimeType === 'PREDICT') {
|
|
12255
|
+
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
12256
|
+
if (parentObject !== undefined && fromMimeType != null) {
|
|
12257
|
+
setValueByPath(parentObject, ['instances[]', 'mimeType'], fromMimeType);
|
|
12258
|
+
}
|
|
12259
|
+
}
|
|
12260
|
+
let discriminatorAutoTruncate = getValueByPath(rootObject, [
|
|
12261
|
+
'embeddingApiType',
|
|
12262
|
+
]);
|
|
12263
|
+
if (discriminatorAutoTruncate === undefined) {
|
|
12264
|
+
discriminatorAutoTruncate = 'PREDICT';
|
|
12265
|
+
}
|
|
12266
|
+
if (discriminatorAutoTruncate === 'PREDICT') {
|
|
12267
|
+
const fromAutoTruncate = getValueByPath(fromObject, [
|
|
12268
|
+
'autoTruncate',
|
|
12269
|
+
]);
|
|
12270
|
+
if (parentObject !== undefined && fromAutoTruncate != null) {
|
|
12271
|
+
setValueByPath(parentObject, ['parameters', 'autoTruncate'], fromAutoTruncate);
|
|
12272
|
+
}
|
|
12273
|
+
}
|
|
12274
|
+
else if (discriminatorAutoTruncate === 'EMBED_CONTENT') {
|
|
12275
|
+
const fromAutoTruncate = getValueByPath(fromObject, [
|
|
12276
|
+
'autoTruncate',
|
|
12277
|
+
]);
|
|
12278
|
+
if (parentObject !== undefined && fromAutoTruncate != null) {
|
|
12279
|
+
setValueByPath(parentObject, ['autoTruncate'], fromAutoTruncate);
|
|
12280
|
+
}
|
|
12152
12281
|
}
|
|
12153
12282
|
return toObject;
|
|
12154
12283
|
}
|
|
12155
|
-
function
|
|
12284
|
+
function embedContentParametersPrivateToMldev(apiClient, fromObject, rootObject) {
|
|
12156
12285
|
const toObject = {};
|
|
12157
12286
|
const fromModel = getValueByPath(fromObject, ['model']);
|
|
12158
12287
|
if (fromModel != null) {
|
|
@@ -12168,6 +12297,10 @@ function embedContentParametersToMldev(apiClient, fromObject, rootObject) {
|
|
|
12168
12297
|
}
|
|
12169
12298
|
setValueByPath(toObject, ['requests[]', 'content'], transformedList);
|
|
12170
12299
|
}
|
|
12300
|
+
const fromContent = getValueByPath(fromObject, ['content']);
|
|
12301
|
+
if (fromContent != null) {
|
|
12302
|
+
contentToMldev$1(tContent(fromContent));
|
|
12303
|
+
}
|
|
12171
12304
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
12172
12305
|
if (fromConfig != null) {
|
|
12173
12306
|
embedContentConfigToMldev(fromConfig, toObject);
|
|
@@ -12178,25 +12311,45 @@ function embedContentParametersToMldev(apiClient, fromObject, rootObject) {
|
|
|
12178
12311
|
}
|
|
12179
12312
|
return toObject;
|
|
12180
12313
|
}
|
|
12181
|
-
function
|
|
12314
|
+
function embedContentParametersPrivateToVertex(apiClient, fromObject, rootObject) {
|
|
12182
12315
|
const toObject = {};
|
|
12183
12316
|
const fromModel = getValueByPath(fromObject, ['model']);
|
|
12184
12317
|
if (fromModel != null) {
|
|
12185
12318
|
setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
|
|
12186
12319
|
}
|
|
12187
|
-
|
|
12188
|
-
|
|
12189
|
-
|
|
12190
|
-
|
|
12191
|
-
|
|
12192
|
-
|
|
12193
|
-
|
|
12320
|
+
let discriminatorContents = getValueByPath(rootObject, [
|
|
12321
|
+
'embeddingApiType',
|
|
12322
|
+
]);
|
|
12323
|
+
if (discriminatorContents === undefined) {
|
|
12324
|
+
discriminatorContents = 'PREDICT';
|
|
12325
|
+
}
|
|
12326
|
+
if (discriminatorContents === 'PREDICT') {
|
|
12327
|
+
const fromContents = getValueByPath(fromObject, ['contents']);
|
|
12328
|
+
if (fromContents != null) {
|
|
12329
|
+
let transformedList = tContentsForEmbed(apiClient, fromContents);
|
|
12330
|
+
if (Array.isArray(transformedList)) {
|
|
12331
|
+
transformedList = transformedList.map((item) => {
|
|
12332
|
+
return item;
|
|
12333
|
+
});
|
|
12334
|
+
}
|
|
12335
|
+
setValueByPath(toObject, ['instances[]', 'content'], transformedList);
|
|
12336
|
+
}
|
|
12337
|
+
}
|
|
12338
|
+
let discriminatorContent = getValueByPath(rootObject, [
|
|
12339
|
+
'embeddingApiType',
|
|
12340
|
+
]);
|
|
12341
|
+
if (discriminatorContent === undefined) {
|
|
12342
|
+
discriminatorContent = 'PREDICT';
|
|
12343
|
+
}
|
|
12344
|
+
if (discriminatorContent === 'EMBED_CONTENT') {
|
|
12345
|
+
const fromContent = getValueByPath(fromObject, ['content']);
|
|
12346
|
+
if (fromContent != null) {
|
|
12347
|
+
setValueByPath(toObject, ['content'], tContent(fromContent));
|
|
12194
12348
|
}
|
|
12195
|
-
setValueByPath(toObject, ['instances[]', 'content'], transformedList);
|
|
12196
12349
|
}
|
|
12197
12350
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
12198
12351
|
if (fromConfig != null) {
|
|
12199
|
-
embedContentConfigToVertex(fromConfig, toObject);
|
|
12352
|
+
embedContentConfigToVertex(fromConfig, toObject, rootObject);
|
|
12200
12353
|
}
|
|
12201
12354
|
return toObject;
|
|
12202
12355
|
}
|
|
@@ -12249,6 +12402,24 @@ function embedContentResponseFromVertex(fromObject, rootObject) {
|
|
|
12249
12402
|
if (fromMetadata != null) {
|
|
12250
12403
|
setValueByPath(toObject, ['metadata'], fromMetadata);
|
|
12251
12404
|
}
|
|
12405
|
+
if (rootObject &&
|
|
12406
|
+
getValueByPath(rootObject, ['embeddingApiType']) === 'EMBED_CONTENT') {
|
|
12407
|
+
const embedding = getValueByPath(fromObject, ['embedding']);
|
|
12408
|
+
const usageMetadata = getValueByPath(fromObject, ['usageMetadata']);
|
|
12409
|
+
const truncated = getValueByPath(fromObject, ['truncated']);
|
|
12410
|
+
if (embedding) {
|
|
12411
|
+
const stats = {};
|
|
12412
|
+
if (usageMetadata &&
|
|
12413
|
+
usageMetadata['promptTokenCount']) {
|
|
12414
|
+
stats.tokenCount = usageMetadata['promptTokenCount'];
|
|
12415
|
+
}
|
|
12416
|
+
if (truncated) {
|
|
12417
|
+
stats.truncated = truncated;
|
|
12418
|
+
}
|
|
12419
|
+
embedding.statistics = stats;
|
|
12420
|
+
setValueByPath(toObject, ['embeddings'], [embedding]);
|
|
12421
|
+
}
|
|
12422
|
+
}
|
|
12252
12423
|
return toObject;
|
|
12253
12424
|
}
|
|
12254
12425
|
function endpointFromVertex(fromObject, _rootObject) {
|
|
@@ -15797,6 +15968,47 @@ class Models extends BaseModule {
|
|
|
15797
15968
|
constructor(apiClient) {
|
|
15798
15969
|
super();
|
|
15799
15970
|
this.apiClient = apiClient;
|
|
15971
|
+
/**
|
|
15972
|
+
* Calculates embeddings for the given contents.
|
|
15973
|
+
*
|
|
15974
|
+
* @param params - The parameters for embedding contents.
|
|
15975
|
+
* @return The response from the API.
|
|
15976
|
+
*
|
|
15977
|
+
* @example
|
|
15978
|
+
* ```ts
|
|
15979
|
+
* const response = await ai.models.embedContent({
|
|
15980
|
+
* model: 'text-embedding-004',
|
|
15981
|
+
* contents: [
|
|
15982
|
+
* 'What is your name?',
|
|
15983
|
+
* 'What is your favorite color?',
|
|
15984
|
+
* ],
|
|
15985
|
+
* config: {
|
|
15986
|
+
* outputDimensionality: 64,
|
|
15987
|
+
* },
|
|
15988
|
+
* });
|
|
15989
|
+
* console.log(response);
|
|
15990
|
+
* ```
|
|
15991
|
+
*/
|
|
15992
|
+
this.embedContent = async (params) => {
|
|
15993
|
+
if (!this.apiClient.isVertexAI()) {
|
|
15994
|
+
return await this.embedContentInternal(params);
|
|
15995
|
+
}
|
|
15996
|
+
const isVertexEmbedContentModel = (params.model.includes('gemini') &&
|
|
15997
|
+
params.model !== 'gemini-embedding-001') ||
|
|
15998
|
+
params.model.includes('maas');
|
|
15999
|
+
if (isVertexEmbedContentModel) {
|
|
16000
|
+
const contents = tContents(params.contents);
|
|
16001
|
+
if (contents.length > 1) {
|
|
16002
|
+
throw new Error('The embedContent API for this model only supports one content at a time.');
|
|
16003
|
+
}
|
|
16004
|
+
const paramsPrivate = Object.assign(Object.assign({}, params), { content: contents[0], embeddingApiType: EmbeddingApiType.EMBED_CONTENT });
|
|
16005
|
+
return await this.embedContentInternal(paramsPrivate);
|
|
16006
|
+
}
|
|
16007
|
+
else {
|
|
16008
|
+
const paramsPrivate = Object.assign(Object.assign({}, params), { embeddingApiType: EmbeddingApiType.PREDICT });
|
|
16009
|
+
return await this.embedContentInternal(paramsPrivate);
|
|
16010
|
+
}
|
|
16011
|
+
};
|
|
15800
16012
|
/**
|
|
15801
16013
|
* Makes an API request to generate content with a given model.
|
|
15802
16014
|
*
|
|
@@ -16484,14 +16696,17 @@ class Models extends BaseModule {
|
|
|
16484
16696
|
* console.log(response);
|
|
16485
16697
|
* ```
|
|
16486
16698
|
*/
|
|
16487
|
-
async
|
|
16699
|
+
async embedContentInternal(params) {
|
|
16488
16700
|
var _a, _b, _c, _d;
|
|
16489
16701
|
let response;
|
|
16490
16702
|
let path = '';
|
|
16491
16703
|
let queryParams = {};
|
|
16492
16704
|
if (this.apiClient.isVertexAI()) {
|
|
16493
|
-
const body =
|
|
16494
|
-
|
|
16705
|
+
const body = embedContentParametersPrivateToVertex(this.apiClient, params, params);
|
|
16706
|
+
const endpointUrl = tIsVertexEmbedContentModel(params.model)
|
|
16707
|
+
? '{model}:embedContent'
|
|
16708
|
+
: '{model}:predict';
|
|
16709
|
+
path = formatMap(endpointUrl, body['_url']);
|
|
16495
16710
|
queryParams = body['_query'];
|
|
16496
16711
|
delete body['_url'];
|
|
16497
16712
|
delete body['_query'];
|
|
@@ -16514,14 +16729,14 @@ class Models extends BaseModule {
|
|
|
16514
16729
|
});
|
|
16515
16730
|
});
|
|
16516
16731
|
return response.then((apiResponse) => {
|
|
16517
|
-
const resp = embedContentResponseFromVertex(apiResponse);
|
|
16732
|
+
const resp = embedContentResponseFromVertex(apiResponse, params);
|
|
16518
16733
|
const typedResp = new EmbedContentResponse();
|
|
16519
16734
|
Object.assign(typedResp, resp);
|
|
16520
16735
|
return typedResp;
|
|
16521
16736
|
});
|
|
16522
16737
|
}
|
|
16523
16738
|
else {
|
|
16524
|
-
const body =
|
|
16739
|
+
const body = embedContentParametersPrivateToMldev(this.apiClient, params);
|
|
16525
16740
|
path = formatMap('{model}:batchEmbedContents', body['_url']);
|
|
16526
16741
|
queryParams = body['_query'];
|
|
16527
16742
|
delete body['_url'];
|
|
@@ -18249,6 +18464,9 @@ function createTuningJobConfigToMldev(fromObject, parentObject, _rootObject) {
|
|
|
18249
18464
|
if (getValueByPath(fromObject, ['outputUri']) !== undefined) {
|
|
18250
18465
|
throw new Error('outputUri parameter is not supported in Gemini API.');
|
|
18251
18466
|
}
|
|
18467
|
+
if (getValueByPath(fromObject, ['encryptionSpec']) !== undefined) {
|
|
18468
|
+
throw new Error('encryptionSpec parameter is not supported in Gemini API.');
|
|
18469
|
+
}
|
|
18252
18470
|
return toObject;
|
|
18253
18471
|
}
|
|
18254
18472
|
function createTuningJobConfigToVertex(fromObject, parentObject, rootObject) {
|
|
@@ -18484,6 +18702,12 @@ function createTuningJobConfigToVertex(fromObject, parentObject, rootObject) {
|
|
|
18484
18702
|
if (parentObject !== undefined && fromOutputUri != null) {
|
|
18485
18703
|
setValueByPath(parentObject, ['outputUri'], fromOutputUri);
|
|
18486
18704
|
}
|
|
18705
|
+
const fromEncryptionSpec = getValueByPath(fromObject, [
|
|
18706
|
+
'encryptionSpec',
|
|
18707
|
+
]);
|
|
18708
|
+
if (parentObject !== undefined && fromEncryptionSpec != null) {
|
|
18709
|
+
setValueByPath(parentObject, ['encryptionSpec'], fromEncryptionSpec);
|
|
18710
|
+
}
|
|
18487
18711
|
return toObject;
|
|
18488
18712
|
}
|
|
18489
18713
|
function createTuningJobParametersPrivateToMldev(fromObject, rootObject) {
|
|
@@ -19411,6 +19635,7 @@ const LANGUAGE_LABEL_PREFIX = 'gl-node/';
|
|
|
19411
19635
|
*/
|
|
19412
19636
|
class GoogleGenAI {
|
|
19413
19637
|
get interactions() {
|
|
19638
|
+
var _a;
|
|
19414
19639
|
if (this._interactions !== undefined) {
|
|
19415
19640
|
return this._interactions;
|
|
19416
19641
|
}
|
|
@@ -19430,6 +19655,7 @@ class GoogleGenAI {
|
|
|
19430
19655
|
clientAdapter: this.apiClient,
|
|
19431
19656
|
defaultHeaders: this.apiClient.getDefaultHeaders(),
|
|
19432
19657
|
timeout: httpOpts === null || httpOpts === void 0 ? void 0 : httpOpts.timeout,
|
|
19658
|
+
maxRetries: (_a = httpOpts === null || httpOpts === void 0 ? void 0 : httpOpts.retryOptions) === null || _a === void 0 ? void 0 : _a.attempts,
|
|
19433
19659
|
});
|
|
19434
19660
|
this._interactions = nextGenClient.interactions;
|
|
19435
19661
|
return this._interactions;
|
|
@@ -19467,5 +19693,5 @@ class GoogleGenAI {
|
|
|
19467
19693
|
}
|
|
19468
19694
|
}
|
|
19469
19695
|
|
|
19470
|
-
export { ActivityHandling, AdapterSize, ApiError, ApiSpec, AuthType, Batches, Behavior, BlockedReason, Caches, CancelTuningJobResponse, Chat, Chats, ComputeTokensResponse, ContentReferenceImage, ControlReferenceImage, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DeleteModelResponse, DocumentState, DynamicRetrievalConfigMode, EditImageResponse, EditMode, EmbedContentResponse, EndSensitivity, Environment, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, FunctionResponseBlob, FunctionResponseFileData, FunctionResponsePart, FunctionResponseScheduling, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosOperation, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpElementLocation, HttpResponse, ImagePromptLanguage, ImportFileOperation, ImportFileResponse, InlinedEmbedContentResponse, InlinedResponse, JobState, Language, ListBatchJobsResponse, ListCachedContentsResponse, ListDocumentsResponse, ListFileSearchStoresResponse, ListFilesResponse, ListModelsResponse, ListTuningJobsResponse, Live, LiveClientToolResponse, LiveMusicPlaybackControl, LiveMusicServerMessage, LiveSendToolResponseParameters, LiveServerMessage, MaskReferenceImage, MaskReferenceMode, MediaModality, MediaResolution, Modality, Models, MusicGenerationMode, Operations, Outcome, PagedItem, Pager, PartMediaResolutionLevel, PersonGeneration, PhishBlockThreshold, RawReferenceImage, RecontextImageResponse, RegisterFilesResponse, ReplayResponse, ResourceScope, SafetyFilterLevel, Scale, SegmentImageResponse, SegmentMode, Session, SingleEmbedContentResponse, StartSensitivity, StyleReferenceImage, SubjectReferenceImage, SubjectReferenceType, ThinkingLevel, Tokens, TrafficType, TuningMethod, TuningMode, TuningTask, TurnCompleteReason, TurnCoverage, Type, UploadToFileSearchStoreOperation, UploadToFileSearchStoreResponse, UploadToFileSearchStoreResumableResponse, UpscaleImageResponse, UrlRetrievalStatus, VadSignalType, VideoCompressionQuality, VideoGenerationMaskMode, VideoGenerationReferenceType, VoiceActivityType, createFunctionResponsePartFromBase64, createFunctionResponsePartFromUri, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, mcpToTool, setDefaultBaseUrls };
|
|
19696
|
+
export { ActivityHandling, AdapterSize, ApiError, ApiSpec, AuthType, Batches, Behavior, BlockedReason, Caches, CancelTuningJobResponse, Chat, Chats, ComputeTokensResponse, ContentReferenceImage, ControlReferenceImage, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DeleteModelResponse, DocumentState, DynamicRetrievalConfigMode, EditImageResponse, EditMode, EmbedContentResponse, EmbeddingApiType, EndSensitivity, Environment, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, FunctionResponseBlob, FunctionResponseFileData, FunctionResponsePart, FunctionResponseScheduling, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosOperation, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpElementLocation, HttpResponse, ImagePromptLanguage, ImportFileOperation, ImportFileResponse, InlinedEmbedContentResponse, InlinedResponse, JobState, Language, ListBatchJobsResponse, ListCachedContentsResponse, ListDocumentsResponse, ListFileSearchStoresResponse, ListFilesResponse, ListModelsResponse, ListTuningJobsResponse, Live, LiveClientToolResponse, LiveMusicPlaybackControl, LiveMusicServerMessage, LiveSendToolResponseParameters, LiveServerMessage, MaskReferenceImage, MaskReferenceMode, MediaModality, MediaResolution, Modality, Models, MusicGenerationMode, Operations, Outcome, PagedItem, Pager, PartMediaResolutionLevel, PersonGeneration, PhishBlockThreshold, RawReferenceImage, RecontextImageResponse, RegisterFilesResponse, ReplayResponse, ResourceScope, SafetyFilterLevel, Scale, SegmentImageResponse, SegmentMode, Session, SingleEmbedContentResponse, StartSensitivity, StyleReferenceImage, SubjectReferenceImage, SubjectReferenceType, ThinkingLevel, Tokens, TrafficType, TuningMethod, TuningMode, TuningTask, TurnCompleteReason, TurnCoverage, Type, UploadToFileSearchStoreOperation, UploadToFileSearchStoreResponse, UploadToFileSearchStoreResumableResponse, UpscaleImageResponse, UrlRetrievalStatus, VadSignalType, VideoCompressionQuality, VideoGenerationMaskMode, VideoGenerationReferenceType, VoiceActivityType, createFunctionResponsePartFromBase64, createFunctionResponsePartFromUri, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, mcpToTool, setDefaultBaseUrls };
|
|
19471
19697
|
//# sourceMappingURL=index.mjs.map
|