@google/genai 1.4.0 → 1.5.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 +26 -4
- package/dist/index.cjs +42 -2
- package/dist/index.mjs +42 -2
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.cjs +49 -3
- package/dist/node/index.mjs +49 -3
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/node.d.ts +26 -4
- package/dist/web/index.mjs +42 -2
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +26 -4
- package/package.json +6 -1
package/dist/genai.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
|
}
|
|
@@ -5985,6 +5994,7 @@ declare namespace types {
|
|
|
5985
5994
|
AuthConfig,
|
|
5986
5995
|
GoogleMaps,
|
|
5987
5996
|
UrlContext,
|
|
5997
|
+
VertexAISearchDataStoreSpec,
|
|
5988
5998
|
VertexAISearch,
|
|
5989
5999
|
VertexRagStoreRagResource,
|
|
5990
6000
|
RagRetrievalConfigFilter,
|
|
@@ -6081,9 +6091,9 @@ declare namespace types {
|
|
|
6081
6091
|
ComputeTokensParameters,
|
|
6082
6092
|
TokensInfo,
|
|
6083
6093
|
ComputeTokensResponse,
|
|
6094
|
+
Video,
|
|
6084
6095
|
GenerateVideosConfig,
|
|
6085
6096
|
GenerateVideosParameters,
|
|
6086
|
-
Video,
|
|
6087
6097
|
GeneratedVideo,
|
|
6088
6098
|
GenerateVideosResponse,
|
|
6089
6099
|
GenerateVideosOperation,
|
|
@@ -6435,6 +6445,8 @@ export declare interface UsageMetadata {
|
|
|
6435
6445
|
|
|
6436
6446
|
/** Retrieve from Vertex AI Search datastore or engine for grounding. datastore and engine are mutually exclusive. See https://cloud.google.com/products/agent-builder */
|
|
6437
6447
|
export declare interface VertexAISearch {
|
|
6448
|
+
/** 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. */
|
|
6449
|
+
dataStoreSpecs?: VertexAISearchDataStoreSpec[];
|
|
6438
6450
|
/** Optional. Fully-qualified Vertex AI Search data store resource ID. Format: `projects/{project}/locations/{location}/collections/{collection}/dataStores/{dataStore}` */
|
|
6439
6451
|
datastore?: string;
|
|
6440
6452
|
/** Optional. Fully-qualified Vertex AI Search engine resource ID. Format: `projects/{project}/locations/{location}/collections/{collection}/engines/{engine}` */
|
|
@@ -6445,6 +6457,14 @@ export declare interface VertexAISearch {
|
|
|
6445
6457
|
maxResults?: number;
|
|
6446
6458
|
}
|
|
6447
6459
|
|
|
6460
|
+
/** 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 */
|
|
6461
|
+
export declare interface VertexAISearchDataStoreSpec {
|
|
6462
|
+
/** Full resource name of DataStore, such as Format: `projects/{project}/locations/{location}/collections/{collection}/dataStores/{dataStore}` */
|
|
6463
|
+
dataStore?: string;
|
|
6464
|
+
/** 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) */
|
|
6465
|
+
filter?: string;
|
|
6466
|
+
}
|
|
6467
|
+
|
|
6448
6468
|
/** Retrieve from Vertex RAG Store for grounding. */
|
|
6449
6469
|
export declare interface VertexRagStore {
|
|
6450
6470
|
/** Optional. Deprecated. Please use rag_resources instead. */
|
|
@@ -6455,6 +6475,8 @@ export declare interface VertexRagStore {
|
|
|
6455
6475
|
ragRetrievalConfig?: RagRetrievalConfig;
|
|
6456
6476
|
/** Optional. Number of top k results to return from the selected corpora. */
|
|
6457
6477
|
similarityTopK?: number;
|
|
6478
|
+
/** 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. */
|
|
6479
|
+
storeContext?: boolean;
|
|
6458
6480
|
/** Optional. Only return results with vector distance smaller than the threshold. */
|
|
6459
6481
|
vectorDistanceThreshold?: number;
|
|
6460
6482
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var zod = require('zod');
|
|
4
|
+
var types_js = require('@modelcontextprotocol/sdk/types.js');
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* @license
|
|
@@ -3608,7 +3609,7 @@ class Caches extends BaseModule {
|
|
|
3608
3609
|
* @example
|
|
3609
3610
|
* ```ts
|
|
3610
3611
|
* const cachedContents = await ai.caches.list({config: {'pageSize': 2}});
|
|
3611
|
-
* for (const cachedContent of cachedContents) {
|
|
3612
|
+
* for await (const cachedContent of cachedContents) {
|
|
3612
3613
|
* console.log(cachedContent);
|
|
3613
3614
|
* }
|
|
3614
3615
|
* ```
|
|
@@ -4353,7 +4354,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
4353
4354
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
4354
4355
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
4355
4356
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
4356
|
-
const SDK_VERSION = '1.
|
|
4357
|
+
const SDK_VERSION = '1.5.0'; // x-release-please-version
|
|
4357
4358
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
4358
4359
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
4359
4360
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -8741,6 +8742,9 @@ function generateVideosConfigToMldev(apiClient, fromObject, parentObject) {
|
|
|
8741
8742
|
if (getValueByPath(fromObject, ['generateAudio']) !== undefined) {
|
|
8742
8743
|
throw new Error('generateAudio parameter is not supported in Gemini API.');
|
|
8743
8744
|
}
|
|
8745
|
+
if (getValueByPath(fromObject, ['lastFrame']) !== undefined) {
|
|
8746
|
+
throw new Error('lastFrame parameter is not supported in Gemini API.');
|
|
8747
|
+
}
|
|
8744
8748
|
return toObject;
|
|
8745
8749
|
}
|
|
8746
8750
|
function generateVideosParametersToMldev(apiClient, fromObject) {
|
|
@@ -8757,6 +8761,9 @@ function generateVideosParametersToMldev(apiClient, fromObject) {
|
|
|
8757
8761
|
if (fromImage != null) {
|
|
8758
8762
|
setValueByPath(toObject, ['instances[0]', 'image'], imageToMldev(apiClient, fromImage));
|
|
8759
8763
|
}
|
|
8764
|
+
if (getValueByPath(fromObject, ['video']) !== undefined) {
|
|
8765
|
+
throw new Error('video parameter is not supported in Gemini API.');
|
|
8766
|
+
}
|
|
8760
8767
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
8761
8768
|
if (fromConfig != null) {
|
|
8762
8769
|
setValueByPath(toObject, ['config'], generateVideosConfigToMldev(apiClient, fromConfig, toObject));
|
|
@@ -10035,6 +10042,22 @@ function computeTokensParametersToVertex(apiClient, fromObject) {
|
|
|
10035
10042
|
}
|
|
10036
10043
|
return toObject;
|
|
10037
10044
|
}
|
|
10045
|
+
function videoToVertex(apiClient, fromObject) {
|
|
10046
|
+
const toObject = {};
|
|
10047
|
+
const fromUri = getValueByPath(fromObject, ['uri']);
|
|
10048
|
+
if (fromUri != null) {
|
|
10049
|
+
setValueByPath(toObject, ['gcsUri'], fromUri);
|
|
10050
|
+
}
|
|
10051
|
+
const fromVideoBytes = getValueByPath(fromObject, ['videoBytes']);
|
|
10052
|
+
if (fromVideoBytes != null) {
|
|
10053
|
+
setValueByPath(toObject, ['bytesBase64Encoded'], tBytes(apiClient, fromVideoBytes));
|
|
10054
|
+
}
|
|
10055
|
+
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
10056
|
+
if (fromMimeType != null) {
|
|
10057
|
+
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
10058
|
+
}
|
|
10059
|
+
return toObject;
|
|
10060
|
+
}
|
|
10038
10061
|
function generateVideosConfigToVertex(apiClient, fromObject, parentObject) {
|
|
10039
10062
|
const toObject = {};
|
|
10040
10063
|
const fromNumberOfVideos = getValueByPath(fromObject, [
|
|
@@ -10097,6 +10120,10 @@ function generateVideosConfigToVertex(apiClient, fromObject, parentObject) {
|
|
|
10097
10120
|
if (parentObject !== undefined && fromGenerateAudio != null) {
|
|
10098
10121
|
setValueByPath(parentObject, ['parameters', 'generateAudio'], fromGenerateAudio);
|
|
10099
10122
|
}
|
|
10123
|
+
const fromLastFrame = getValueByPath(fromObject, ['lastFrame']);
|
|
10124
|
+
if (parentObject !== undefined && fromLastFrame != null) {
|
|
10125
|
+
setValueByPath(parentObject, ['instances[0]', 'lastFrame'], imageToVertex(apiClient, fromLastFrame));
|
|
10126
|
+
}
|
|
10100
10127
|
return toObject;
|
|
10101
10128
|
}
|
|
10102
10129
|
function generateVideosParametersToVertex(apiClient, fromObject) {
|
|
@@ -10113,6 +10140,10 @@ function generateVideosParametersToVertex(apiClient, fromObject) {
|
|
|
10113
10140
|
if (fromImage != null) {
|
|
10114
10141
|
setValueByPath(toObject, ['instances[0]', 'image'], imageToVertex(apiClient, fromImage));
|
|
10115
10142
|
}
|
|
10143
|
+
const fromVideo = getValueByPath(fromObject, ['video']);
|
|
10144
|
+
if (fromVideo != null) {
|
|
10145
|
+
setValueByPath(toObject, ['instances[0]', 'video'], videoToVertex(apiClient, fromVideo));
|
|
10146
|
+
}
|
|
10116
10147
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
10117
10148
|
if (fromConfig != null) {
|
|
10118
10149
|
setValueByPath(toObject, ['config'], generateVideosConfigToVertex(apiClient, fromConfig, toObject));
|
|
@@ -11406,9 +11437,18 @@ class McpCallableTool {
|
|
|
11406
11437
|
for (const functionCall of functionCalls) {
|
|
11407
11438
|
if (functionCall.name in this.functionNameToMcpClient) {
|
|
11408
11439
|
const mcpClient = this.functionNameToMcpClient[functionCall.name];
|
|
11440
|
+
let requestOptions = undefined;
|
|
11441
|
+
// TODO: b/424238654 - Add support for finer grained timeout control.
|
|
11442
|
+
if (this.config.timeout) {
|
|
11443
|
+
requestOptions = {
|
|
11444
|
+
timeout: this.config.timeout,
|
|
11445
|
+
};
|
|
11446
|
+
}
|
|
11409
11447
|
const callToolResponse = await mcpClient.callTool({
|
|
11410
11448
|
name: functionCall.name,
|
|
11411
11449
|
arguments: functionCall.args,
|
|
11450
|
+
CallToolResultSchema: types_js.CallToolResultSchema,
|
|
11451
|
+
requestOptions,
|
|
11412
11452
|
});
|
|
11413
11453
|
functionCallResponseParts.push({
|
|
11414
11454
|
functionResponse: {
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { CallToolResultSchema } from '@modelcontextprotocol/sdk/types.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* @license
|
|
@@ -3606,7 +3607,7 @@ class Caches extends BaseModule {
|
|
|
3606
3607
|
* @example
|
|
3607
3608
|
* ```ts
|
|
3608
3609
|
* const cachedContents = await ai.caches.list({config: {'pageSize': 2}});
|
|
3609
|
-
* for (const cachedContent of cachedContents) {
|
|
3610
|
+
* for await (const cachedContent of cachedContents) {
|
|
3610
3611
|
* console.log(cachedContent);
|
|
3611
3612
|
* }
|
|
3612
3613
|
* ```
|
|
@@ -4351,7 +4352,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
4351
4352
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
4352
4353
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
4353
4354
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
4354
|
-
const SDK_VERSION = '1.
|
|
4355
|
+
const SDK_VERSION = '1.5.0'; // x-release-please-version
|
|
4355
4356
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
4356
4357
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
4357
4358
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -8739,6 +8740,9 @@ function generateVideosConfigToMldev(apiClient, fromObject, parentObject) {
|
|
|
8739
8740
|
if (getValueByPath(fromObject, ['generateAudio']) !== undefined) {
|
|
8740
8741
|
throw new Error('generateAudio parameter is not supported in Gemini API.');
|
|
8741
8742
|
}
|
|
8743
|
+
if (getValueByPath(fromObject, ['lastFrame']) !== undefined) {
|
|
8744
|
+
throw new Error('lastFrame parameter is not supported in Gemini API.');
|
|
8745
|
+
}
|
|
8742
8746
|
return toObject;
|
|
8743
8747
|
}
|
|
8744
8748
|
function generateVideosParametersToMldev(apiClient, fromObject) {
|
|
@@ -8755,6 +8759,9 @@ function generateVideosParametersToMldev(apiClient, fromObject) {
|
|
|
8755
8759
|
if (fromImage != null) {
|
|
8756
8760
|
setValueByPath(toObject, ['instances[0]', 'image'], imageToMldev(apiClient, fromImage));
|
|
8757
8761
|
}
|
|
8762
|
+
if (getValueByPath(fromObject, ['video']) !== undefined) {
|
|
8763
|
+
throw new Error('video parameter is not supported in Gemini API.');
|
|
8764
|
+
}
|
|
8758
8765
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
8759
8766
|
if (fromConfig != null) {
|
|
8760
8767
|
setValueByPath(toObject, ['config'], generateVideosConfigToMldev(apiClient, fromConfig, toObject));
|
|
@@ -10033,6 +10040,22 @@ function computeTokensParametersToVertex(apiClient, fromObject) {
|
|
|
10033
10040
|
}
|
|
10034
10041
|
return toObject;
|
|
10035
10042
|
}
|
|
10043
|
+
function videoToVertex(apiClient, fromObject) {
|
|
10044
|
+
const toObject = {};
|
|
10045
|
+
const fromUri = getValueByPath(fromObject, ['uri']);
|
|
10046
|
+
if (fromUri != null) {
|
|
10047
|
+
setValueByPath(toObject, ['gcsUri'], fromUri);
|
|
10048
|
+
}
|
|
10049
|
+
const fromVideoBytes = getValueByPath(fromObject, ['videoBytes']);
|
|
10050
|
+
if (fromVideoBytes != null) {
|
|
10051
|
+
setValueByPath(toObject, ['bytesBase64Encoded'], tBytes(apiClient, fromVideoBytes));
|
|
10052
|
+
}
|
|
10053
|
+
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
10054
|
+
if (fromMimeType != null) {
|
|
10055
|
+
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
10056
|
+
}
|
|
10057
|
+
return toObject;
|
|
10058
|
+
}
|
|
10036
10059
|
function generateVideosConfigToVertex(apiClient, fromObject, parentObject) {
|
|
10037
10060
|
const toObject = {};
|
|
10038
10061
|
const fromNumberOfVideos = getValueByPath(fromObject, [
|
|
@@ -10095,6 +10118,10 @@ function generateVideosConfigToVertex(apiClient, fromObject, parentObject) {
|
|
|
10095
10118
|
if (parentObject !== undefined && fromGenerateAudio != null) {
|
|
10096
10119
|
setValueByPath(parentObject, ['parameters', 'generateAudio'], fromGenerateAudio);
|
|
10097
10120
|
}
|
|
10121
|
+
const fromLastFrame = getValueByPath(fromObject, ['lastFrame']);
|
|
10122
|
+
if (parentObject !== undefined && fromLastFrame != null) {
|
|
10123
|
+
setValueByPath(parentObject, ['instances[0]', 'lastFrame'], imageToVertex(apiClient, fromLastFrame));
|
|
10124
|
+
}
|
|
10098
10125
|
return toObject;
|
|
10099
10126
|
}
|
|
10100
10127
|
function generateVideosParametersToVertex(apiClient, fromObject) {
|
|
@@ -10111,6 +10138,10 @@ function generateVideosParametersToVertex(apiClient, fromObject) {
|
|
|
10111
10138
|
if (fromImage != null) {
|
|
10112
10139
|
setValueByPath(toObject, ['instances[0]', 'image'], imageToVertex(apiClient, fromImage));
|
|
10113
10140
|
}
|
|
10141
|
+
const fromVideo = getValueByPath(fromObject, ['video']);
|
|
10142
|
+
if (fromVideo != null) {
|
|
10143
|
+
setValueByPath(toObject, ['instances[0]', 'video'], videoToVertex(apiClient, fromVideo));
|
|
10144
|
+
}
|
|
10114
10145
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
10115
10146
|
if (fromConfig != null) {
|
|
10116
10147
|
setValueByPath(toObject, ['config'], generateVideosConfigToVertex(apiClient, fromConfig, toObject));
|
|
@@ -11404,9 +11435,18 @@ class McpCallableTool {
|
|
|
11404
11435
|
for (const functionCall of functionCalls) {
|
|
11405
11436
|
if (functionCall.name in this.functionNameToMcpClient) {
|
|
11406
11437
|
const mcpClient = this.functionNameToMcpClient[functionCall.name];
|
|
11438
|
+
let requestOptions = undefined;
|
|
11439
|
+
// TODO: b/424238654 - Add support for finer grained timeout control.
|
|
11440
|
+
if (this.config.timeout) {
|
|
11441
|
+
requestOptions = {
|
|
11442
|
+
timeout: this.config.timeout,
|
|
11443
|
+
};
|
|
11444
|
+
}
|
|
11407
11445
|
const callToolResponse = await mcpClient.callTool({
|
|
11408
11446
|
name: functionCall.name,
|
|
11409
11447
|
arguments: functionCall.args,
|
|
11448
|
+
CallToolResultSchema,
|
|
11449
|
+
requestOptions,
|
|
11410
11450
|
});
|
|
11411
11451
|
functionCallResponseParts.push({
|
|
11412
11452
|
functionResponse: {
|