@google/genai 1.3.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/README.md +42 -1
- package/dist/genai.d.ts +26 -4
- package/dist/index.cjs +108 -16
- package/dist/index.mjs +108 -16
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.cjs +124 -18
- package/dist/node/index.mjs +124 -18
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/node.d.ts +26 -4
- package/dist/web/index.mjs +108 -16
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +26 -4
- package/package.json +6 -1
package/README.md
CHANGED
|
@@ -21,7 +21,21 @@ The Google Gen AI SDK is designed to work with Gemini 2.0 features.
|
|
|
21
21
|
|
|
22
22
|
## Prerequisites
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
1. Node.js version 20 or later
|
|
25
|
+
|
|
26
|
+
### The following are required for Vertex AI users (excluding Vertex AI Studio)
|
|
27
|
+
1. [Select](https://console.cloud.google.com/project) or [create](https://cloud.google.com/resource-manager/docs/creating-managing-projects#creating_a_project) a Google Cloud project.
|
|
28
|
+
1. [Enable billing for your project](https://cloud.google.com/billing/docs/how-to/modify-project).
|
|
29
|
+
1. [Enable the Vertex AI API](https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com).
|
|
30
|
+
1. [Configure authentication](https://cloud.google.com/docs/authentication) for your project.
|
|
31
|
+
* [Install the gcloud CLI](https://cloud.google.com/sdk/docs/install).
|
|
32
|
+
* [Initialize the gcloud CLI](https://cloud.google.com/sdk/docs/initializing).
|
|
33
|
+
* Create local authentication credentials for your user account:
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
gcloud auth application-default login
|
|
37
|
+
```
|
|
38
|
+
A list of accepted authentication options are listed in [GoogleAuthOptions](https://github.com/googleapis/google-auth-library-nodejs/blob/3ae120d0a45c95e36c59c9ac8286483938781f30/src/auth/googleauth.ts#L87) interface of google-auth-library-node.js GitHub repo.
|
|
25
39
|
|
|
26
40
|
## Installation
|
|
27
41
|
|
|
@@ -98,6 +112,33 @@ const ai = new GoogleGenAI({
|
|
|
98
112
|
});
|
|
99
113
|
```
|
|
100
114
|
|
|
115
|
+
### (Optional) (NodeJS only) Using environment variables:
|
|
116
|
+
|
|
117
|
+
For NodeJS environments, you can create a client by configuring the necessary
|
|
118
|
+
environment variables. Configuration setup instructions depends on whether
|
|
119
|
+
you're using the Gemini Developer API or the Gemini API in Vertex AI.
|
|
120
|
+
|
|
121
|
+
**Gemini Developer API:** Set `GOOGLE_API_KEY` as shown below:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
export GOOGLE_API_KEY='your-api-key'
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**Gemini API on Vertex AI:** Set `GOOGLE_GENAI_USE_VERTEXAI`,
|
|
128
|
+
`GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION`, as shown below:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
export GOOGLE_GENAI_USE_VERTEXAI=true
|
|
132
|
+
export GOOGLE_CLOUD_PROJECT='your-project-id'
|
|
133
|
+
export GOOGLE_CLOUD_LOCATION='us-central1'
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
import {GoogleGenAI} from '@google/genai';
|
|
138
|
+
|
|
139
|
+
const ai = new GoogleGenAI();
|
|
140
|
+
```
|
|
141
|
+
|
|
101
142
|
## API Selection
|
|
102
143
|
|
|
103
144
|
By default, the SDK uses the beta API endpoints provided by Google to support
|
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
|
|
@@ -1925,16 +1926,16 @@ function flattenTypeArrayToAnyOf(typeList, resultingSchema) {
|
|
|
1925
1926
|
}
|
|
1926
1927
|
const listWithoutNull = typeList.filter((type) => type !== 'null');
|
|
1927
1928
|
if (listWithoutNull.length === 1) {
|
|
1928
|
-
resultingSchema['type'] = Object.
|
|
1929
|
-
?
|
|
1929
|
+
resultingSchema['type'] = Object.values(exports.Type).includes(listWithoutNull[0].toUpperCase())
|
|
1930
|
+
? listWithoutNull[0].toUpperCase()
|
|
1930
1931
|
: exports.Type.TYPE_UNSPECIFIED;
|
|
1931
1932
|
}
|
|
1932
1933
|
else {
|
|
1933
1934
|
resultingSchema['anyOf'] = [];
|
|
1934
1935
|
for (const i of listWithoutNull) {
|
|
1935
1936
|
resultingSchema['anyOf'].push({
|
|
1936
|
-
'type': Object.
|
|
1937
|
-
?
|
|
1937
|
+
'type': Object.values(exports.Type).includes(i.toUpperCase())
|
|
1938
|
+
? i.toUpperCase()
|
|
1938
1939
|
: exports.Type.TYPE_UNSPECIFIED,
|
|
1939
1940
|
});
|
|
1940
1941
|
}
|
|
@@ -2018,7 +2019,7 @@ function processJsonSchema(_jsonSchema) {
|
|
|
2018
2019
|
// beginning of this function.
|
|
2019
2020
|
continue;
|
|
2020
2021
|
}
|
|
2021
|
-
genAISchema['type'] = Object.
|
|
2022
|
+
genAISchema['type'] = Object.values(exports.Type).includes(fieldValue.toUpperCase())
|
|
2022
2023
|
? fieldValue.toUpperCase()
|
|
2023
2024
|
: exports.Type.TYPE_UNSPECIFIED;
|
|
2024
2025
|
}
|
|
@@ -2377,7 +2378,7 @@ function filterToJsonSchema(schema) {
|
|
|
2377
2378
|
}
|
|
2378
2379
|
else if (fieldName === 'type') {
|
|
2379
2380
|
const typeValue = fieldValue.toUpperCase();
|
|
2380
|
-
filteredSchema[fieldName] = Object.
|
|
2381
|
+
filteredSchema[fieldName] = Object.values(exports.Type).includes(typeValue)
|
|
2381
2382
|
? typeValue
|
|
2382
2383
|
: exports.Type.TYPE_UNSPECIFIED;
|
|
2383
2384
|
}
|
|
@@ -3054,6 +3055,10 @@ function googleMapsToVertex$2(apiClient, fromObject) {
|
|
|
3054
3055
|
}
|
|
3055
3056
|
return toObject;
|
|
3056
3057
|
}
|
|
3058
|
+
function urlContextToVertex$2() {
|
|
3059
|
+
const toObject = {};
|
|
3060
|
+
return toObject;
|
|
3061
|
+
}
|
|
3057
3062
|
function toolToVertex$2(apiClient, fromObject) {
|
|
3058
3063
|
const toObject = {};
|
|
3059
3064
|
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
@@ -3092,8 +3097,9 @@ function toolToVertex$2(apiClient, fromObject) {
|
|
|
3092
3097
|
if (fromGoogleMaps != null) {
|
|
3093
3098
|
setValueByPath(toObject, ['googleMaps'], googleMapsToVertex$2(apiClient, fromGoogleMaps));
|
|
3094
3099
|
}
|
|
3095
|
-
|
|
3096
|
-
|
|
3100
|
+
const fromUrlContext = getValueByPath(fromObject, ['urlContext']);
|
|
3101
|
+
if (fromUrlContext != null) {
|
|
3102
|
+
setValueByPath(toObject, ['urlContext'], urlContextToVertex$2());
|
|
3097
3103
|
}
|
|
3098
3104
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
3099
3105
|
'codeExecution',
|
|
@@ -3603,7 +3609,7 @@ class Caches extends BaseModule {
|
|
|
3603
3609
|
* @example
|
|
3604
3610
|
* ```ts
|
|
3605
3611
|
* const cachedContents = await ai.caches.list({config: {'pageSize': 2}});
|
|
3606
|
-
* for (const cachedContent of cachedContents) {
|
|
3612
|
+
* for await (const cachedContent of cachedContents) {
|
|
3607
3613
|
* console.log(cachedContent);
|
|
3608
3614
|
* }
|
|
3609
3615
|
* ```
|
|
@@ -4348,7 +4354,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
4348
4354
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
4349
4355
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
4350
4356
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
4351
|
-
const SDK_VERSION = '1.
|
|
4357
|
+
const SDK_VERSION = '1.5.0'; // x-release-please-version
|
|
4352
4358
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
4353
4359
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
4354
4360
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -6042,6 +6048,10 @@ function urlContextToMldev$2() {
|
|
|
6042
6048
|
const toObject = {};
|
|
6043
6049
|
return toObject;
|
|
6044
6050
|
}
|
|
6051
|
+
function urlContextToVertex$1() {
|
|
6052
|
+
const toObject = {};
|
|
6053
|
+
return toObject;
|
|
6054
|
+
}
|
|
6045
6055
|
function toolToMldev$2(apiClient, fromObject) {
|
|
6046
6056
|
const toObject = {};
|
|
6047
6057
|
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
@@ -6125,8 +6135,9 @@ function toolToVertex$1(apiClient, fromObject) {
|
|
|
6125
6135
|
if (fromGoogleMaps != null) {
|
|
6126
6136
|
setValueByPath(toObject, ['googleMaps'], googleMapsToVertex$1(apiClient, fromGoogleMaps));
|
|
6127
6137
|
}
|
|
6128
|
-
|
|
6129
|
-
|
|
6138
|
+
const fromUrlContext = getValueByPath(fromObject, ['urlContext']);
|
|
6139
|
+
if (fromUrlContext != null) {
|
|
6140
|
+
setValueByPath(toObject, ['urlContext'], urlContextToVertex$1());
|
|
6130
6141
|
}
|
|
6131
6142
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
6132
6143
|
'codeExecution',
|
|
@@ -8722,12 +8733,18 @@ function generateVideosConfigToMldev(apiClient, fromObject, parentObject) {
|
|
|
8722
8733
|
if (parentObject !== undefined && fromNegativePrompt != null) {
|
|
8723
8734
|
setValueByPath(parentObject, ['parameters', 'negativePrompt'], fromNegativePrompt);
|
|
8724
8735
|
}
|
|
8725
|
-
|
|
8726
|
-
|
|
8736
|
+
const fromEnhancePrompt = getValueByPath(fromObject, [
|
|
8737
|
+
'enhancePrompt',
|
|
8738
|
+
]);
|
|
8739
|
+
if (parentObject !== undefined && fromEnhancePrompt != null) {
|
|
8740
|
+
setValueByPath(parentObject, ['parameters', 'enhancePrompt'], fromEnhancePrompt);
|
|
8727
8741
|
}
|
|
8728
8742
|
if (getValueByPath(fromObject, ['generateAudio']) !== undefined) {
|
|
8729
8743
|
throw new Error('generateAudio parameter is not supported in Gemini API.');
|
|
8730
8744
|
}
|
|
8745
|
+
if (getValueByPath(fromObject, ['lastFrame']) !== undefined) {
|
|
8746
|
+
throw new Error('lastFrame parameter is not supported in Gemini API.');
|
|
8747
|
+
}
|
|
8731
8748
|
return toObject;
|
|
8732
8749
|
}
|
|
8733
8750
|
function generateVideosParametersToMldev(apiClient, fromObject) {
|
|
@@ -8744,6 +8761,9 @@ function generateVideosParametersToMldev(apiClient, fromObject) {
|
|
|
8744
8761
|
if (fromImage != null) {
|
|
8745
8762
|
setValueByPath(toObject, ['instances[0]', 'image'], imageToMldev(apiClient, fromImage));
|
|
8746
8763
|
}
|
|
8764
|
+
if (getValueByPath(fromObject, ['video']) !== undefined) {
|
|
8765
|
+
throw new Error('video parameter is not supported in Gemini API.');
|
|
8766
|
+
}
|
|
8747
8767
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
8748
8768
|
if (fromConfig != null) {
|
|
8749
8769
|
setValueByPath(toObject, ['config'], generateVideosConfigToMldev(apiClient, fromConfig, toObject));
|
|
@@ -9115,6 +9135,10 @@ function googleMapsToVertex(apiClient, fromObject) {
|
|
|
9115
9135
|
}
|
|
9116
9136
|
return toObject;
|
|
9117
9137
|
}
|
|
9138
|
+
function urlContextToVertex() {
|
|
9139
|
+
const toObject = {};
|
|
9140
|
+
return toObject;
|
|
9141
|
+
}
|
|
9118
9142
|
function toolToVertex(apiClient, fromObject) {
|
|
9119
9143
|
const toObject = {};
|
|
9120
9144
|
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
@@ -9153,8 +9177,9 @@ function toolToVertex(apiClient, fromObject) {
|
|
|
9153
9177
|
if (fromGoogleMaps != null) {
|
|
9154
9178
|
setValueByPath(toObject, ['googleMaps'], googleMapsToVertex(apiClient, fromGoogleMaps));
|
|
9155
9179
|
}
|
|
9156
|
-
|
|
9157
|
-
|
|
9180
|
+
const fromUrlContext = getValueByPath(fromObject, ['urlContext']);
|
|
9181
|
+
if (fromUrlContext != null) {
|
|
9182
|
+
setValueByPath(toObject, ['urlContext'], urlContextToVertex());
|
|
9158
9183
|
}
|
|
9159
9184
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
9160
9185
|
'codeExecution',
|
|
@@ -10017,6 +10042,22 @@ function computeTokensParametersToVertex(apiClient, fromObject) {
|
|
|
10017
10042
|
}
|
|
10018
10043
|
return toObject;
|
|
10019
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
|
+
}
|
|
10020
10061
|
function generateVideosConfigToVertex(apiClient, fromObject, parentObject) {
|
|
10021
10062
|
const toObject = {};
|
|
10022
10063
|
const fromNumberOfVideos = getValueByPath(fromObject, [
|
|
@@ -10079,6 +10120,10 @@ function generateVideosConfigToVertex(apiClient, fromObject, parentObject) {
|
|
|
10079
10120
|
if (parentObject !== undefined && fromGenerateAudio != null) {
|
|
10080
10121
|
setValueByPath(parentObject, ['parameters', 'generateAudio'], fromGenerateAudio);
|
|
10081
10122
|
}
|
|
10123
|
+
const fromLastFrame = getValueByPath(fromObject, ['lastFrame']);
|
|
10124
|
+
if (parentObject !== undefined && fromLastFrame != null) {
|
|
10125
|
+
setValueByPath(parentObject, ['instances[0]', 'lastFrame'], imageToVertex(apiClient, fromLastFrame));
|
|
10126
|
+
}
|
|
10082
10127
|
return toObject;
|
|
10083
10128
|
}
|
|
10084
10129
|
function generateVideosParametersToVertex(apiClient, fromObject) {
|
|
@@ -10095,6 +10140,10 @@ function generateVideosParametersToVertex(apiClient, fromObject) {
|
|
|
10095
10140
|
if (fromImage != null) {
|
|
10096
10141
|
setValueByPath(toObject, ['instances[0]', 'image'], imageToVertex(apiClient, fromImage));
|
|
10097
10142
|
}
|
|
10143
|
+
const fromVideo = getValueByPath(fromObject, ['video']);
|
|
10144
|
+
if (fromVideo != null) {
|
|
10145
|
+
setValueByPath(toObject, ['instances[0]', 'video'], videoToVertex(apiClient, fromVideo));
|
|
10146
|
+
}
|
|
10098
10147
|
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
10099
10148
|
if (fromConfig != null) {
|
|
10100
10149
|
setValueByPath(toObject, ['config'], generateVideosConfigToVertex(apiClient, fromConfig, toObject));
|
|
@@ -10745,6 +10794,34 @@ function citationMetadataFromVertex(apiClient, fromObject) {
|
|
|
10745
10794
|
}
|
|
10746
10795
|
return toObject;
|
|
10747
10796
|
}
|
|
10797
|
+
function urlMetadataFromVertex(apiClient, fromObject) {
|
|
10798
|
+
const toObject = {};
|
|
10799
|
+
const fromRetrievedUrl = getValueByPath(fromObject, ['retrievedUrl']);
|
|
10800
|
+
if (fromRetrievedUrl != null) {
|
|
10801
|
+
setValueByPath(toObject, ['retrievedUrl'], fromRetrievedUrl);
|
|
10802
|
+
}
|
|
10803
|
+
const fromUrlRetrievalStatus = getValueByPath(fromObject, [
|
|
10804
|
+
'urlRetrievalStatus',
|
|
10805
|
+
]);
|
|
10806
|
+
if (fromUrlRetrievalStatus != null) {
|
|
10807
|
+
setValueByPath(toObject, ['urlRetrievalStatus'], fromUrlRetrievalStatus);
|
|
10808
|
+
}
|
|
10809
|
+
return toObject;
|
|
10810
|
+
}
|
|
10811
|
+
function urlContextMetadataFromVertex(apiClient, fromObject) {
|
|
10812
|
+
const toObject = {};
|
|
10813
|
+
const fromUrlMetadata = getValueByPath(fromObject, ['urlMetadata']);
|
|
10814
|
+
if (fromUrlMetadata != null) {
|
|
10815
|
+
let transformedList = fromUrlMetadata;
|
|
10816
|
+
if (Array.isArray(transformedList)) {
|
|
10817
|
+
transformedList = transformedList.map((item) => {
|
|
10818
|
+
return urlMetadataFromVertex(apiClient, item);
|
|
10819
|
+
});
|
|
10820
|
+
}
|
|
10821
|
+
setValueByPath(toObject, ['urlMetadata'], transformedList);
|
|
10822
|
+
}
|
|
10823
|
+
return toObject;
|
|
10824
|
+
}
|
|
10748
10825
|
function candidateFromVertex(apiClient, fromObject) {
|
|
10749
10826
|
const toObject = {};
|
|
10750
10827
|
const fromContent = getValueByPath(fromObject, ['content']);
|
|
@@ -10767,6 +10844,12 @@ function candidateFromVertex(apiClient, fromObject) {
|
|
|
10767
10844
|
if (fromFinishReason != null) {
|
|
10768
10845
|
setValueByPath(toObject, ['finishReason'], fromFinishReason);
|
|
10769
10846
|
}
|
|
10847
|
+
const fromUrlContextMetadata = getValueByPath(fromObject, [
|
|
10848
|
+
'urlContextMetadata',
|
|
10849
|
+
]);
|
|
10850
|
+
if (fromUrlContextMetadata != null) {
|
|
10851
|
+
setValueByPath(toObject, ['urlContextMetadata'], urlContextMetadataFromVertex(apiClient, fromUrlContextMetadata));
|
|
10852
|
+
}
|
|
10770
10853
|
const fromAvgLogprobs = getValueByPath(fromObject, ['avgLogprobs']);
|
|
10771
10854
|
if (fromAvgLogprobs != null) {
|
|
10772
10855
|
setValueByPath(toObject, ['avgLogprobs'], fromAvgLogprobs);
|
|
@@ -11354,9 +11437,18 @@ class McpCallableTool {
|
|
|
11354
11437
|
for (const functionCall of functionCalls) {
|
|
11355
11438
|
if (functionCall.name in this.functionNameToMcpClient) {
|
|
11356
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
|
+
}
|
|
11357
11447
|
const callToolResponse = await mcpClient.callTool({
|
|
11358
11448
|
name: functionCall.name,
|
|
11359
11449
|
arguments: functionCall.args,
|
|
11450
|
+
CallToolResultSchema: types_js.CallToolResultSchema,
|
|
11451
|
+
requestOptions,
|
|
11360
11452
|
});
|
|
11361
11453
|
functionCallResponseParts.push({
|
|
11362
11454
|
functionResponse: {
|