@google/genai 1.4.0 → 1.5.1
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 +26 -4
- package/dist/index.cjs +44 -6
- package/dist/index.mjs +44 -6
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.cjs +50 -4
- package/dist/node/index.mjs +50 -4
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/node.d.ts +26 -4
- package/dist/web/index.mjs +43 -6
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +26 -4
- package/package.json +6 -1
package/dist/node/node.d.ts
CHANGED
|
@@ -456,7 +456,7 @@ export declare class Caches extends BaseModule {
|
|
|
456
456
|
* @example
|
|
457
457
|
* ```ts
|
|
458
458
|
* const cachedContents = await ai.caches.list({config: {'pageSize': 2}});
|
|
459
|
-
* for (const cachedContent of cachedContents) {
|
|
459
|
+
* for await (const cachedContent of cachedContents) {
|
|
460
460
|
* console.log(cachedContent);
|
|
461
461
|
* }
|
|
462
462
|
* ```
|
|
@@ -556,6 +556,10 @@ export declare interface CallableToolConfig {
|
|
|
556
556
|
* Specifies the model's behavior after invoking this tool.
|
|
557
557
|
*/
|
|
558
558
|
behavior?: Behavior;
|
|
559
|
+
/**
|
|
560
|
+
* Timeout for remote calls in milliseconds. Note this timeout applies only to
|
|
561
|
+
* tool remote calls, and not making HTTP requests to the API. */
|
|
562
|
+
timeout?: number;
|
|
559
563
|
}
|
|
560
564
|
|
|
561
565
|
/** A response candidate generated from the model. */
|
|
@@ -2426,6 +2430,8 @@ export declare interface GenerateVideosConfig {
|
|
|
2426
2430
|
enhancePrompt?: boolean;
|
|
2427
2431
|
/** Whether to generate audio along with the video. */
|
|
2428
2432
|
generateAudio?: boolean;
|
|
2433
|
+
/** Image to use as the last frame of generated videos. Only supported for image to video use cases. */
|
|
2434
|
+
lastFrame?: Image_2;
|
|
2429
2435
|
}
|
|
2430
2436
|
|
|
2431
2437
|
/** A video generation operation. */
|
|
@@ -2442,7 +2448,7 @@ export declare interface GenerateVideosOperation {
|
|
|
2442
2448
|
response?: GenerateVideosResponse;
|
|
2443
2449
|
}
|
|
2444
2450
|
|
|
2445
|
-
/** Class that represents the parameters for generating
|
|
2451
|
+
/** Class that represents the parameters for generating videos. */
|
|
2446
2452
|
export declare interface GenerateVideosParameters {
|
|
2447
2453
|
/** ID of the model to use. For a list of models, see `Google models
|
|
2448
2454
|
<https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_. */
|
|
@@ -2450,8 +2456,11 @@ export declare interface GenerateVideosParameters {
|
|
|
2450
2456
|
/** The text prompt for generating the videos. Optional for image to video use cases. */
|
|
2451
2457
|
prompt?: string;
|
|
2452
2458
|
/** The input image for generating the videos.
|
|
2453
|
-
Optional if prompt is provided. */
|
|
2459
|
+
Optional if prompt or video is provided. */
|
|
2454
2460
|
image?: Image_2;
|
|
2461
|
+
/** The input video for video extension use cases.
|
|
2462
|
+
Optional if prompt or image is provided. */
|
|
2463
|
+
video?: Video;
|
|
2455
2464
|
/** Configuration for generating videos. */
|
|
2456
2465
|
config?: GenerateVideosConfig;
|
|
2457
2466
|
}
|
|
@@ -5997,6 +6006,7 @@ declare namespace types {
|
|
|
5997
6006
|
AuthConfig,
|
|
5998
6007
|
GoogleMaps,
|
|
5999
6008
|
UrlContext,
|
|
6009
|
+
VertexAISearchDataStoreSpec,
|
|
6000
6010
|
VertexAISearch,
|
|
6001
6011
|
VertexRagStoreRagResource,
|
|
6002
6012
|
RagRetrievalConfigFilter,
|
|
@@ -6093,9 +6103,9 @@ declare namespace types {
|
|
|
6093
6103
|
ComputeTokensParameters,
|
|
6094
6104
|
TokensInfo,
|
|
6095
6105
|
ComputeTokensResponse,
|
|
6106
|
+
Video,
|
|
6096
6107
|
GenerateVideosConfig,
|
|
6097
6108
|
GenerateVideosParameters,
|
|
6098
|
-
Video,
|
|
6099
6109
|
GeneratedVideo,
|
|
6100
6110
|
GenerateVideosResponse,
|
|
6101
6111
|
GenerateVideosOperation,
|
|
@@ -6447,6 +6457,8 @@ export declare interface UsageMetadata {
|
|
|
6447
6457
|
|
|
6448
6458
|
/** Retrieve from Vertex AI Search datastore or engine for grounding. datastore and engine are mutually exclusive. See https://cloud.google.com/products/agent-builder */
|
|
6449
6459
|
export declare interface VertexAISearch {
|
|
6460
|
+
/** Specifications that define the specific DataStores to be searched, along with configurations for those data stores. This is only considered for Engines with multiple data stores. It should only be set if engine is used. */
|
|
6461
|
+
dataStoreSpecs?: VertexAISearchDataStoreSpec[];
|
|
6450
6462
|
/** Optional. Fully-qualified Vertex AI Search data store resource ID. Format: `projects/{project}/locations/{location}/collections/{collection}/dataStores/{dataStore}` */
|
|
6451
6463
|
datastore?: string;
|
|
6452
6464
|
/** Optional. Fully-qualified Vertex AI Search engine resource ID. Format: `projects/{project}/locations/{location}/collections/{collection}/engines/{engine}` */
|
|
@@ -6457,6 +6469,14 @@ export declare interface VertexAISearch {
|
|
|
6457
6469
|
maxResults?: number;
|
|
6458
6470
|
}
|
|
6459
6471
|
|
|
6472
|
+
/** Define data stores within engine to filter on in a search call and configurations for those data stores. For more information, see https://cloud.google.com/generative-ai-app-builder/docs/reference/rpc/google.cloud.discoveryengine.v1#datastorespec */
|
|
6473
|
+
export declare interface VertexAISearchDataStoreSpec {
|
|
6474
|
+
/** Full resource name of DataStore, such as Format: `projects/{project}/locations/{location}/collections/{collection}/dataStores/{dataStore}` */
|
|
6475
|
+
dataStore?: string;
|
|
6476
|
+
/** Optional. Filter specification to filter documents in the data store specified by data_store field. For more information on filtering, see [Filtering](https://cloud.google.com/generative-ai-app-builder/docs/filter-search-metadata) */
|
|
6477
|
+
filter?: string;
|
|
6478
|
+
}
|
|
6479
|
+
|
|
6460
6480
|
/** Retrieve from Vertex RAG Store for grounding. */
|
|
6461
6481
|
export declare interface VertexRagStore {
|
|
6462
6482
|
/** Optional. Deprecated. Please use rag_resources instead. */
|
|
@@ -6467,6 +6487,8 @@ export declare interface VertexRagStore {
|
|
|
6467
6487
|
ragRetrievalConfig?: RagRetrievalConfig;
|
|
6468
6488
|
/** Optional. Number of top k results to return from the selected corpora. */
|
|
6469
6489
|
similarityTopK?: number;
|
|
6490
|
+
/** Optional. Currently only supported for Gemini Multimodal Live API. In Gemini Multimodal Live API, if `store_context` bool is specified, Gemini will leverage it to automatically memorize the interactions between the client and Gemini, and retrieve context when needed to augment the response generation for users' ongoing and future interactions. */
|
|
6491
|
+
storeContext?: boolean;
|
|
6470
6492
|
/** Optional. Only return results with vector distance smaller than the threshold. */
|
|
6471
6493
|
vectorDistanceThreshold?: number;
|
|
6472
6494
|
}
|
package/dist/web/index.mjs
CHANGED
|
@@ -3636,7 +3636,7 @@ class Caches extends BaseModule {
|
|
|
3636
3636
|
* @example
|
|
3637
3637
|
* ```ts
|
|
3638
3638
|
* const cachedContents = await ai.caches.list({config: {'pageSize': 2}});
|
|
3639
|
-
* for (const cachedContent of cachedContents) {
|
|
3639
|
+
* for await (const cachedContent of cachedContents) {
|
|
3640
3640
|
* console.log(cachedContent);
|
|
3641
3641
|
* }
|
|
3642
3642
|
* ```
|
|
@@ -8122,6 +8122,9 @@ function generateVideosConfigToMldev(apiClient, fromObject, parentObject) {
|
|
|
8122
8122
|
if (getValueByPath(fromObject, ['generateAudio']) !== undefined) {
|
|
8123
8123
|
throw new Error('generateAudio parameter is not supported in Gemini API.');
|
|
8124
8124
|
}
|
|
8125
|
+
if (getValueByPath(fromObject, ['lastFrame']) !== undefined) {
|
|
8126
|
+
throw new Error('lastFrame parameter is not supported in Gemini API.');
|
|
8127
|
+
}
|
|
8125
8128
|
return toObject;
|
|
8126
8129
|
}
|
|
8127
8130
|
function generateVideosParametersToMldev(apiClient, fromObject) {
|
|
@@ -8138,6 +8141,9 @@ function generateVideosParametersToMldev(apiClient, fromObject) {
|
|
|
8138
8141
|
if (fromImage != null) {
|
|
8139
8142
|
setValueByPath(toObject, ['instances[0]', 'image'], imageToMldev(apiClient, fromImage));
|
|
8140
8143
|
}
|
|
8144
|
+
if (getValueByPath(fromObject, ['video']) !== undefined) {
|
|
8145
|
+
throw new Error('video parameter is not supported in Gemini API.');
|
|
8146
|
+
}
|
|
8141
8147
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
8142
8148
|
if (fromConfig != null) {
|
|
8143
8149
|
setValueByPath(toObject, ['config'], generateVideosConfigToMldev(apiClient, fromConfig, toObject));
|
|
@@ -9416,6 +9422,22 @@ function computeTokensParametersToVertex(apiClient, fromObject) {
|
|
|
9416
9422
|
}
|
|
9417
9423
|
return toObject;
|
|
9418
9424
|
}
|
|
9425
|
+
function videoToVertex(apiClient, fromObject) {
|
|
9426
|
+
const toObject = {};
|
|
9427
|
+
const fromUri = getValueByPath(fromObject, ['uri']);
|
|
9428
|
+
if (fromUri != null) {
|
|
9429
|
+
setValueByPath(toObject, ['gcsUri'], fromUri);
|
|
9430
|
+
}
|
|
9431
|
+
const fromVideoBytes = getValueByPath(fromObject, ['videoBytes']);
|
|
9432
|
+
if (fromVideoBytes != null) {
|
|
9433
|
+
setValueByPath(toObject, ['bytesBase64Encoded'], tBytes(apiClient, fromVideoBytes));
|
|
9434
|
+
}
|
|
9435
|
+
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
9436
|
+
if (fromMimeType != null) {
|
|
9437
|
+
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
9438
|
+
}
|
|
9439
|
+
return toObject;
|
|
9440
|
+
}
|
|
9419
9441
|
function generateVideosConfigToVertex(apiClient, fromObject, parentObject) {
|
|
9420
9442
|
const toObject = {};
|
|
9421
9443
|
const fromNumberOfVideos = getValueByPath(fromObject, [
|
|
@@ -9478,6 +9500,10 @@ function generateVideosConfigToVertex(apiClient, fromObject, parentObject) {
|
|
|
9478
9500
|
if (parentObject !== undefined && fromGenerateAudio != null) {
|
|
9479
9501
|
setValueByPath(parentObject, ['parameters', 'generateAudio'], fromGenerateAudio);
|
|
9480
9502
|
}
|
|
9503
|
+
const fromLastFrame = getValueByPath(fromObject, ['lastFrame']);
|
|
9504
|
+
if (parentObject !== undefined && fromLastFrame != null) {
|
|
9505
|
+
setValueByPath(parentObject, ['instances[0]', 'lastFrame'], imageToVertex(apiClient, fromLastFrame));
|
|
9506
|
+
}
|
|
9481
9507
|
return toObject;
|
|
9482
9508
|
}
|
|
9483
9509
|
function generateVideosParametersToVertex(apiClient, fromObject) {
|
|
@@ -9494,6 +9520,10 @@ function generateVideosParametersToVertex(apiClient, fromObject) {
|
|
|
9494
9520
|
if (fromImage != null) {
|
|
9495
9521
|
setValueByPath(toObject, ['instances[0]', 'image'], imageToVertex(apiClient, fromImage));
|
|
9496
9522
|
}
|
|
9523
|
+
const fromVideo = getValueByPath(fromObject, ['video']);
|
|
9524
|
+
if (fromVideo != null) {
|
|
9525
|
+
setValueByPath(toObject, ['instances[0]', 'video'], videoToVertex(apiClient, fromVideo));
|
|
9526
|
+
}
|
|
9497
9527
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
9498
9528
|
if (fromConfig != null) {
|
|
9499
9529
|
setValueByPath(toObject, ['config'], generateVideosConfigToVertex(apiClient, fromConfig, toObject));
|
|
@@ -10666,7 +10696,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
10666
10696
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
10667
10697
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
10668
10698
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
10669
|
-
const SDK_VERSION = '1.
|
|
10699
|
+
const SDK_VERSION = '1.5.1'; // x-release-please-version
|
|
10670
10700
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
10671
10701
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
10672
10702
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -11309,10 +11339,20 @@ class McpCallableTool {
|
|
|
11309
11339
|
for (const functionCall of functionCalls) {
|
|
11310
11340
|
if (functionCall.name in this.functionNameToMcpClient) {
|
|
11311
11341
|
const mcpClient = this.functionNameToMcpClient[functionCall.name];
|
|
11342
|
+
let requestOptions = undefined;
|
|
11343
|
+
// TODO: b/424238654 - Add support for finer grained timeout control.
|
|
11344
|
+
if (this.config.timeout) {
|
|
11345
|
+
requestOptions = {
|
|
11346
|
+
timeout: this.config.timeout,
|
|
11347
|
+
};
|
|
11348
|
+
}
|
|
11312
11349
|
const callToolResponse = await mcpClient.callTool({
|
|
11313
11350
|
name: functionCall.name,
|
|
11314
11351
|
arguments: functionCall.args,
|
|
11315
|
-
}
|
|
11352
|
+
},
|
|
11353
|
+
// Set the result schema to undefined to allow MCP to rely on the
|
|
11354
|
+
// default schema.
|
|
11355
|
+
undefined, requestOptions);
|
|
11316
11356
|
functionCallResponseParts.push({
|
|
11317
11357
|
functionResponse: {
|
|
11318
11358
|
name: functionCall.name,
|
|
@@ -15378,9 +15418,6 @@ class BrowserUploader {
|
|
|
15378
15418
|
* Copyright 2025 Google LLC
|
|
15379
15419
|
* SPDX-License-Identifier: Apache-2.0
|
|
15380
15420
|
*/
|
|
15381
|
-
// TODO((b/401271082): re-enable lint once BrowserWebSocketFactory is
|
|
15382
|
-
// implemented.
|
|
15383
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
15384
15421
|
class BrowserWebSocketFactory {
|
|
15385
15422
|
create(url, headers, callbacks) {
|
|
15386
15423
|
return new BrowserWebSocket(url, headers, callbacks);
|