@google/genai 1.3.0 → 1.4.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/index.cjs +67 -15
- package/dist/index.mjs +67 -15
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.cjs +76 -16
- package/dist/node/index.mjs +76 -16
- package/dist/node/index.mjs.map +1 -1
- package/dist/web/index.mjs +67 -15
- package/dist/web/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/web/index.mjs
CHANGED
|
@@ -1953,16 +1953,16 @@ function flattenTypeArrayToAnyOf(typeList, resultingSchema) {
|
|
|
1953
1953
|
}
|
|
1954
1954
|
const listWithoutNull = typeList.filter((type) => type !== 'null');
|
|
1955
1955
|
if (listWithoutNull.length === 1) {
|
|
1956
|
-
resultingSchema['type'] = Object.
|
|
1957
|
-
?
|
|
1956
|
+
resultingSchema['type'] = Object.values(Type).includes(listWithoutNull[0].toUpperCase())
|
|
1957
|
+
? listWithoutNull[0].toUpperCase()
|
|
1958
1958
|
: Type.TYPE_UNSPECIFIED;
|
|
1959
1959
|
}
|
|
1960
1960
|
else {
|
|
1961
1961
|
resultingSchema['anyOf'] = [];
|
|
1962
1962
|
for (const i of listWithoutNull) {
|
|
1963
1963
|
resultingSchema['anyOf'].push({
|
|
1964
|
-
'type': Object.
|
|
1965
|
-
?
|
|
1964
|
+
'type': Object.values(Type).includes(i.toUpperCase())
|
|
1965
|
+
? i.toUpperCase()
|
|
1966
1966
|
: Type.TYPE_UNSPECIFIED,
|
|
1967
1967
|
});
|
|
1968
1968
|
}
|
|
@@ -2046,7 +2046,7 @@ function processJsonSchema(_jsonSchema) {
|
|
|
2046
2046
|
// beginning of this function.
|
|
2047
2047
|
continue;
|
|
2048
2048
|
}
|
|
2049
|
-
genAISchema['type'] = Object.
|
|
2049
|
+
genAISchema['type'] = Object.values(Type).includes(fieldValue.toUpperCase())
|
|
2050
2050
|
? fieldValue.toUpperCase()
|
|
2051
2051
|
: Type.TYPE_UNSPECIFIED;
|
|
2052
2052
|
}
|
|
@@ -2405,7 +2405,7 @@ function filterToJsonSchema(schema) {
|
|
|
2405
2405
|
}
|
|
2406
2406
|
else if (fieldName === 'type') {
|
|
2407
2407
|
const typeValue = fieldValue.toUpperCase();
|
|
2408
|
-
filteredSchema[fieldName] = Object.
|
|
2408
|
+
filteredSchema[fieldName] = Object.values(Type).includes(typeValue)
|
|
2409
2409
|
? typeValue
|
|
2410
2410
|
: Type.TYPE_UNSPECIFIED;
|
|
2411
2411
|
}
|
|
@@ -3082,6 +3082,10 @@ function googleMapsToVertex$2(apiClient, fromObject) {
|
|
|
3082
3082
|
}
|
|
3083
3083
|
return toObject;
|
|
3084
3084
|
}
|
|
3085
|
+
function urlContextToVertex$2() {
|
|
3086
|
+
const toObject = {};
|
|
3087
|
+
return toObject;
|
|
3088
|
+
}
|
|
3085
3089
|
function toolToVertex$2(apiClient, fromObject) {
|
|
3086
3090
|
const toObject = {};
|
|
3087
3091
|
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
@@ -3120,8 +3124,9 @@ function toolToVertex$2(apiClient, fromObject) {
|
|
|
3120
3124
|
if (fromGoogleMaps != null) {
|
|
3121
3125
|
setValueByPath(toObject, ['googleMaps'], googleMapsToVertex$2(apiClient, fromGoogleMaps));
|
|
3122
3126
|
}
|
|
3123
|
-
|
|
3124
|
-
|
|
3127
|
+
const fromUrlContext = getValueByPath(fromObject, ['urlContext']);
|
|
3128
|
+
if (fromUrlContext != null) {
|
|
3129
|
+
setValueByPath(toObject, ['urlContext'], urlContextToVertex$2());
|
|
3125
3130
|
}
|
|
3126
3131
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
3127
3132
|
'codeExecution',
|
|
@@ -5423,6 +5428,10 @@ function urlContextToMldev$2() {
|
|
|
5423
5428
|
const toObject = {};
|
|
5424
5429
|
return toObject;
|
|
5425
5430
|
}
|
|
5431
|
+
function urlContextToVertex$1() {
|
|
5432
|
+
const toObject = {};
|
|
5433
|
+
return toObject;
|
|
5434
|
+
}
|
|
5426
5435
|
function toolToMldev$2(apiClient, fromObject) {
|
|
5427
5436
|
const toObject = {};
|
|
5428
5437
|
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
@@ -5506,8 +5515,9 @@ function toolToVertex$1(apiClient, fromObject) {
|
|
|
5506
5515
|
if (fromGoogleMaps != null) {
|
|
5507
5516
|
setValueByPath(toObject, ['googleMaps'], googleMapsToVertex$1(apiClient, fromGoogleMaps));
|
|
5508
5517
|
}
|
|
5509
|
-
|
|
5510
|
-
|
|
5518
|
+
const fromUrlContext = getValueByPath(fromObject, ['urlContext']);
|
|
5519
|
+
if (fromUrlContext != null) {
|
|
5520
|
+
setValueByPath(toObject, ['urlContext'], urlContextToVertex$1());
|
|
5511
5521
|
}
|
|
5512
5522
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
5513
5523
|
'codeExecution',
|
|
@@ -8103,8 +8113,11 @@ function generateVideosConfigToMldev(apiClient, fromObject, parentObject) {
|
|
|
8103
8113
|
if (parentObject !== undefined && fromNegativePrompt != null) {
|
|
8104
8114
|
setValueByPath(parentObject, ['parameters', 'negativePrompt'], fromNegativePrompt);
|
|
8105
8115
|
}
|
|
8106
|
-
|
|
8107
|
-
|
|
8116
|
+
const fromEnhancePrompt = getValueByPath(fromObject, [
|
|
8117
|
+
'enhancePrompt',
|
|
8118
|
+
]);
|
|
8119
|
+
if (parentObject !== undefined && fromEnhancePrompt != null) {
|
|
8120
|
+
setValueByPath(parentObject, ['parameters', 'enhancePrompt'], fromEnhancePrompt);
|
|
8108
8121
|
}
|
|
8109
8122
|
if (getValueByPath(fromObject, ['generateAudio']) !== undefined) {
|
|
8110
8123
|
throw new Error('generateAudio parameter is not supported in Gemini API.');
|
|
@@ -8496,6 +8509,10 @@ function googleMapsToVertex(apiClient, fromObject) {
|
|
|
8496
8509
|
}
|
|
8497
8510
|
return toObject;
|
|
8498
8511
|
}
|
|
8512
|
+
function urlContextToVertex() {
|
|
8513
|
+
const toObject = {};
|
|
8514
|
+
return toObject;
|
|
8515
|
+
}
|
|
8499
8516
|
function toolToVertex(apiClient, fromObject) {
|
|
8500
8517
|
const toObject = {};
|
|
8501
8518
|
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
@@ -8534,8 +8551,9 @@ function toolToVertex(apiClient, fromObject) {
|
|
|
8534
8551
|
if (fromGoogleMaps != null) {
|
|
8535
8552
|
setValueByPath(toObject, ['googleMaps'], googleMapsToVertex(apiClient, fromGoogleMaps));
|
|
8536
8553
|
}
|
|
8537
|
-
|
|
8538
|
-
|
|
8554
|
+
const fromUrlContext = getValueByPath(fromObject, ['urlContext']);
|
|
8555
|
+
if (fromUrlContext != null) {
|
|
8556
|
+
setValueByPath(toObject, ['urlContext'], urlContextToVertex());
|
|
8539
8557
|
}
|
|
8540
8558
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
8541
8559
|
'codeExecution',
|
|
@@ -10126,6 +10144,34 @@ function citationMetadataFromVertex(apiClient, fromObject) {
|
|
|
10126
10144
|
}
|
|
10127
10145
|
return toObject;
|
|
10128
10146
|
}
|
|
10147
|
+
function urlMetadataFromVertex(apiClient, fromObject) {
|
|
10148
|
+
const toObject = {};
|
|
10149
|
+
const fromRetrievedUrl = getValueByPath(fromObject, ['retrievedUrl']);
|
|
10150
|
+
if (fromRetrievedUrl != null) {
|
|
10151
|
+
setValueByPath(toObject, ['retrievedUrl'], fromRetrievedUrl);
|
|
10152
|
+
}
|
|
10153
|
+
const fromUrlRetrievalStatus = getValueByPath(fromObject, [
|
|
10154
|
+
'urlRetrievalStatus',
|
|
10155
|
+
]);
|
|
10156
|
+
if (fromUrlRetrievalStatus != null) {
|
|
10157
|
+
setValueByPath(toObject, ['urlRetrievalStatus'], fromUrlRetrievalStatus);
|
|
10158
|
+
}
|
|
10159
|
+
return toObject;
|
|
10160
|
+
}
|
|
10161
|
+
function urlContextMetadataFromVertex(apiClient, fromObject) {
|
|
10162
|
+
const toObject = {};
|
|
10163
|
+
const fromUrlMetadata = getValueByPath(fromObject, ['urlMetadata']);
|
|
10164
|
+
if (fromUrlMetadata != null) {
|
|
10165
|
+
let transformedList = fromUrlMetadata;
|
|
10166
|
+
if (Array.isArray(transformedList)) {
|
|
10167
|
+
transformedList = transformedList.map((item) => {
|
|
10168
|
+
return urlMetadataFromVertex(apiClient, item);
|
|
10169
|
+
});
|
|
10170
|
+
}
|
|
10171
|
+
setValueByPath(toObject, ['urlMetadata'], transformedList);
|
|
10172
|
+
}
|
|
10173
|
+
return toObject;
|
|
10174
|
+
}
|
|
10129
10175
|
function candidateFromVertex(apiClient, fromObject) {
|
|
10130
10176
|
const toObject = {};
|
|
10131
10177
|
const fromContent = getValueByPath(fromObject, ['content']);
|
|
@@ -10148,6 +10194,12 @@ function candidateFromVertex(apiClient, fromObject) {
|
|
|
10148
10194
|
if (fromFinishReason != null) {
|
|
10149
10195
|
setValueByPath(toObject, ['finishReason'], fromFinishReason);
|
|
10150
10196
|
}
|
|
10197
|
+
const fromUrlContextMetadata = getValueByPath(fromObject, [
|
|
10198
|
+
'urlContextMetadata',
|
|
10199
|
+
]);
|
|
10200
|
+
if (fromUrlContextMetadata != null) {
|
|
10201
|
+
setValueByPath(toObject, ['urlContextMetadata'], urlContextMetadataFromVertex(apiClient, fromUrlContextMetadata));
|
|
10202
|
+
}
|
|
10151
10203
|
const fromAvgLogprobs = getValueByPath(fromObject, ['avgLogprobs']);
|
|
10152
10204
|
if (fromAvgLogprobs != null) {
|
|
10153
10205
|
setValueByPath(toObject, ['avgLogprobs'], fromAvgLogprobs);
|
|
@@ -10614,7 +10666,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
10614
10666
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
10615
10667
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
10616
10668
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
10617
|
-
const SDK_VERSION = '1.
|
|
10669
|
+
const SDK_VERSION = '1.4.0'; // x-release-please-version
|
|
10618
10670
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
10619
10671
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
10620
10672
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|