@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/node/index.cjs
CHANGED
|
@@ -1980,16 +1980,16 @@ function flattenTypeArrayToAnyOf(typeList, resultingSchema) {
|
|
|
1980
1980
|
}
|
|
1981
1981
|
const listWithoutNull = typeList.filter((type) => type !== 'null');
|
|
1982
1982
|
if (listWithoutNull.length === 1) {
|
|
1983
|
-
resultingSchema['type'] = Object.
|
|
1984
|
-
?
|
|
1983
|
+
resultingSchema['type'] = Object.values(exports.Type).includes(listWithoutNull[0].toUpperCase())
|
|
1984
|
+
? listWithoutNull[0].toUpperCase()
|
|
1985
1985
|
: exports.Type.TYPE_UNSPECIFIED;
|
|
1986
1986
|
}
|
|
1987
1987
|
else {
|
|
1988
1988
|
resultingSchema['anyOf'] = [];
|
|
1989
1989
|
for (const i of listWithoutNull) {
|
|
1990
1990
|
resultingSchema['anyOf'].push({
|
|
1991
|
-
'type': Object.
|
|
1992
|
-
?
|
|
1991
|
+
'type': Object.values(exports.Type).includes(i.toUpperCase())
|
|
1992
|
+
? i.toUpperCase()
|
|
1993
1993
|
: exports.Type.TYPE_UNSPECIFIED,
|
|
1994
1994
|
});
|
|
1995
1995
|
}
|
|
@@ -2073,7 +2073,7 @@ function processJsonSchema(_jsonSchema) {
|
|
|
2073
2073
|
// beginning of this function.
|
|
2074
2074
|
continue;
|
|
2075
2075
|
}
|
|
2076
|
-
genAISchema['type'] = Object.
|
|
2076
|
+
genAISchema['type'] = Object.values(exports.Type).includes(fieldValue.toUpperCase())
|
|
2077
2077
|
? fieldValue.toUpperCase()
|
|
2078
2078
|
: exports.Type.TYPE_UNSPECIFIED;
|
|
2079
2079
|
}
|
|
@@ -2432,7 +2432,7 @@ function filterToJsonSchema(schema) {
|
|
|
2432
2432
|
}
|
|
2433
2433
|
else if (fieldName === 'type') {
|
|
2434
2434
|
const typeValue = fieldValue.toUpperCase();
|
|
2435
|
-
filteredSchema[fieldName] = Object.
|
|
2435
|
+
filteredSchema[fieldName] = Object.values(exports.Type).includes(typeValue)
|
|
2436
2436
|
? typeValue
|
|
2437
2437
|
: exports.Type.TYPE_UNSPECIFIED;
|
|
2438
2438
|
}
|
|
@@ -3109,6 +3109,10 @@ function googleMapsToVertex$2(apiClient, fromObject) {
|
|
|
3109
3109
|
}
|
|
3110
3110
|
return toObject;
|
|
3111
3111
|
}
|
|
3112
|
+
function urlContextToVertex$2() {
|
|
3113
|
+
const toObject = {};
|
|
3114
|
+
return toObject;
|
|
3115
|
+
}
|
|
3112
3116
|
function toolToVertex$2(apiClient, fromObject) {
|
|
3113
3117
|
const toObject = {};
|
|
3114
3118
|
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
@@ -3147,8 +3151,9 @@ function toolToVertex$2(apiClient, fromObject) {
|
|
|
3147
3151
|
if (fromGoogleMaps != null) {
|
|
3148
3152
|
setValueByPath(toObject, ['googleMaps'], googleMapsToVertex$2(apiClient, fromGoogleMaps));
|
|
3149
3153
|
}
|
|
3150
|
-
|
|
3151
|
-
|
|
3154
|
+
const fromUrlContext = getValueByPath(fromObject, ['urlContext']);
|
|
3155
|
+
if (fromUrlContext != null) {
|
|
3156
|
+
setValueByPath(toObject, ['urlContext'], urlContextToVertex$2());
|
|
3152
3157
|
}
|
|
3153
3158
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
3154
3159
|
'codeExecution',
|
|
@@ -5450,6 +5455,10 @@ function urlContextToMldev$2() {
|
|
|
5450
5455
|
const toObject = {};
|
|
5451
5456
|
return toObject;
|
|
5452
5457
|
}
|
|
5458
|
+
function urlContextToVertex$1() {
|
|
5459
|
+
const toObject = {};
|
|
5460
|
+
return toObject;
|
|
5461
|
+
}
|
|
5453
5462
|
function toolToMldev$2(apiClient, fromObject) {
|
|
5454
5463
|
const toObject = {};
|
|
5455
5464
|
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
@@ -5533,8 +5542,9 @@ function toolToVertex$1(apiClient, fromObject) {
|
|
|
5533
5542
|
if (fromGoogleMaps != null) {
|
|
5534
5543
|
setValueByPath(toObject, ['googleMaps'], googleMapsToVertex$1(apiClient, fromGoogleMaps));
|
|
5535
5544
|
}
|
|
5536
|
-
|
|
5537
|
-
|
|
5545
|
+
const fromUrlContext = getValueByPath(fromObject, ['urlContext']);
|
|
5546
|
+
if (fromUrlContext != null) {
|
|
5547
|
+
setValueByPath(toObject, ['urlContext'], urlContextToVertex$1());
|
|
5538
5548
|
}
|
|
5539
5549
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
5540
5550
|
'codeExecution',
|
|
@@ -8130,8 +8140,11 @@ function generateVideosConfigToMldev(apiClient, fromObject, parentObject) {
|
|
|
8130
8140
|
if (parentObject !== undefined && fromNegativePrompt != null) {
|
|
8131
8141
|
setValueByPath(parentObject, ['parameters', 'negativePrompt'], fromNegativePrompt);
|
|
8132
8142
|
}
|
|
8133
|
-
|
|
8134
|
-
|
|
8143
|
+
const fromEnhancePrompt = getValueByPath(fromObject, [
|
|
8144
|
+
'enhancePrompt',
|
|
8145
|
+
]);
|
|
8146
|
+
if (parentObject !== undefined && fromEnhancePrompt != null) {
|
|
8147
|
+
setValueByPath(parentObject, ['parameters', 'enhancePrompt'], fromEnhancePrompt);
|
|
8135
8148
|
}
|
|
8136
8149
|
if (getValueByPath(fromObject, ['generateAudio']) !== undefined) {
|
|
8137
8150
|
throw new Error('generateAudio parameter is not supported in Gemini API.');
|
|
@@ -8523,6 +8536,10 @@ function googleMapsToVertex(apiClient, fromObject) {
|
|
|
8523
8536
|
}
|
|
8524
8537
|
return toObject;
|
|
8525
8538
|
}
|
|
8539
|
+
function urlContextToVertex() {
|
|
8540
|
+
const toObject = {};
|
|
8541
|
+
return toObject;
|
|
8542
|
+
}
|
|
8526
8543
|
function toolToVertex(apiClient, fromObject) {
|
|
8527
8544
|
const toObject = {};
|
|
8528
8545
|
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
@@ -8561,8 +8578,9 @@ function toolToVertex(apiClient, fromObject) {
|
|
|
8561
8578
|
if (fromGoogleMaps != null) {
|
|
8562
8579
|
setValueByPath(toObject, ['googleMaps'], googleMapsToVertex(apiClient, fromGoogleMaps));
|
|
8563
8580
|
}
|
|
8564
|
-
|
|
8565
|
-
|
|
8581
|
+
const fromUrlContext = getValueByPath(fromObject, ['urlContext']);
|
|
8582
|
+
if (fromUrlContext != null) {
|
|
8583
|
+
setValueByPath(toObject, ['urlContext'], urlContextToVertex());
|
|
8566
8584
|
}
|
|
8567
8585
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
8568
8586
|
'codeExecution',
|
|
@@ -10153,6 +10171,34 @@ function citationMetadataFromVertex(apiClient, fromObject) {
|
|
|
10153
10171
|
}
|
|
10154
10172
|
return toObject;
|
|
10155
10173
|
}
|
|
10174
|
+
function urlMetadataFromVertex(apiClient, fromObject) {
|
|
10175
|
+
const toObject = {};
|
|
10176
|
+
const fromRetrievedUrl = getValueByPath(fromObject, ['retrievedUrl']);
|
|
10177
|
+
if (fromRetrievedUrl != null) {
|
|
10178
|
+
setValueByPath(toObject, ['retrievedUrl'], fromRetrievedUrl);
|
|
10179
|
+
}
|
|
10180
|
+
const fromUrlRetrievalStatus = getValueByPath(fromObject, [
|
|
10181
|
+
'urlRetrievalStatus',
|
|
10182
|
+
]);
|
|
10183
|
+
if (fromUrlRetrievalStatus != null) {
|
|
10184
|
+
setValueByPath(toObject, ['urlRetrievalStatus'], fromUrlRetrievalStatus);
|
|
10185
|
+
}
|
|
10186
|
+
return toObject;
|
|
10187
|
+
}
|
|
10188
|
+
function urlContextMetadataFromVertex(apiClient, fromObject) {
|
|
10189
|
+
const toObject = {};
|
|
10190
|
+
const fromUrlMetadata = getValueByPath(fromObject, ['urlMetadata']);
|
|
10191
|
+
if (fromUrlMetadata != null) {
|
|
10192
|
+
let transformedList = fromUrlMetadata;
|
|
10193
|
+
if (Array.isArray(transformedList)) {
|
|
10194
|
+
transformedList = transformedList.map((item) => {
|
|
10195
|
+
return urlMetadataFromVertex(apiClient, item);
|
|
10196
|
+
});
|
|
10197
|
+
}
|
|
10198
|
+
setValueByPath(toObject, ['urlMetadata'], transformedList);
|
|
10199
|
+
}
|
|
10200
|
+
return toObject;
|
|
10201
|
+
}
|
|
10156
10202
|
function candidateFromVertex(apiClient, fromObject) {
|
|
10157
10203
|
const toObject = {};
|
|
10158
10204
|
const fromContent = getValueByPath(fromObject, ['content']);
|
|
@@ -10175,6 +10221,12 @@ function candidateFromVertex(apiClient, fromObject) {
|
|
|
10175
10221
|
if (fromFinishReason != null) {
|
|
10176
10222
|
setValueByPath(toObject, ['finishReason'], fromFinishReason);
|
|
10177
10223
|
}
|
|
10224
|
+
const fromUrlContextMetadata = getValueByPath(fromObject, [
|
|
10225
|
+
'urlContextMetadata',
|
|
10226
|
+
]);
|
|
10227
|
+
if (fromUrlContextMetadata != null) {
|
|
10228
|
+
setValueByPath(toObject, ['urlContextMetadata'], urlContextMetadataFromVertex(apiClient, fromUrlContextMetadata));
|
|
10229
|
+
}
|
|
10178
10230
|
const fromAvgLogprobs = getValueByPath(fromObject, ['avgLogprobs']);
|
|
10179
10231
|
if (fromAvgLogprobs != null) {
|
|
10180
10232
|
setValueByPath(toObject, ['avgLogprobs'], fromAvgLogprobs);
|
|
@@ -10641,7 +10693,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
10641
10693
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
10642
10694
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
10643
10695
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
10644
|
-
const SDK_VERSION = '1.
|
|
10696
|
+
const SDK_VERSION = '1.4.0'; // x-release-please-version
|
|
10645
10697
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
10646
10698
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
10647
10699
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -15738,7 +15790,7 @@ class GoogleGenAI {
|
|
|
15738
15790
|
}
|
|
15739
15791
|
this.vertexai =
|
|
15740
15792
|
(_b = (_a = options.vertexai) !== null && _a !== void 0 ? _a : getBooleanEnv('GOOGLE_GENAI_USE_VERTEXAI')) !== null && _b !== void 0 ? _b : false;
|
|
15741
|
-
const envApiKey =
|
|
15793
|
+
const envApiKey = getApiKeyFromEnv();
|
|
15742
15794
|
const envProject = getEnv('GOOGLE_CLOUD_PROJECT');
|
|
15743
15795
|
const envLocation = getEnv('GOOGLE_CLOUD_LOCATION');
|
|
15744
15796
|
this.apiKey = (_c = options.apiKey) !== null && _c !== void 0 ? _c : envApiKey;
|
|
@@ -15816,6 +15868,14 @@ function stringToBoolean(str) {
|
|
|
15816
15868
|
}
|
|
15817
15869
|
return str.toLowerCase() === 'true';
|
|
15818
15870
|
}
|
|
15871
|
+
function getApiKeyFromEnv() {
|
|
15872
|
+
const envGoogleApiKey = getEnv('GOOGLE_API_KEY');
|
|
15873
|
+
const envGeminiApiKey = getEnv('GEMINI_API_KEY');
|
|
15874
|
+
if (envGoogleApiKey && envGeminiApiKey) {
|
|
15875
|
+
console.warn('Both GOOGLE_API_KEY and GEMINI_API_KEY are set. Using GOOGLE_API_KEY.');
|
|
15876
|
+
}
|
|
15877
|
+
return envGoogleApiKey || envGeminiApiKey;
|
|
15878
|
+
}
|
|
15819
15879
|
|
|
15820
15880
|
exports.Caches = Caches;
|
|
15821
15881
|
exports.Chat = Chat;
|
package/dist/node/index.mjs
CHANGED
|
@@ -1958,16 +1958,16 @@ function flattenTypeArrayToAnyOf(typeList, resultingSchema) {
|
|
|
1958
1958
|
}
|
|
1959
1959
|
const listWithoutNull = typeList.filter((type) => type !== 'null');
|
|
1960
1960
|
if (listWithoutNull.length === 1) {
|
|
1961
|
-
resultingSchema['type'] = Object.
|
|
1962
|
-
?
|
|
1961
|
+
resultingSchema['type'] = Object.values(Type).includes(listWithoutNull[0].toUpperCase())
|
|
1962
|
+
? listWithoutNull[0].toUpperCase()
|
|
1963
1963
|
: Type.TYPE_UNSPECIFIED;
|
|
1964
1964
|
}
|
|
1965
1965
|
else {
|
|
1966
1966
|
resultingSchema['anyOf'] = [];
|
|
1967
1967
|
for (const i of listWithoutNull) {
|
|
1968
1968
|
resultingSchema['anyOf'].push({
|
|
1969
|
-
'type': Object.
|
|
1970
|
-
?
|
|
1969
|
+
'type': Object.values(Type).includes(i.toUpperCase())
|
|
1970
|
+
? i.toUpperCase()
|
|
1971
1971
|
: Type.TYPE_UNSPECIFIED,
|
|
1972
1972
|
});
|
|
1973
1973
|
}
|
|
@@ -2051,7 +2051,7 @@ function processJsonSchema(_jsonSchema) {
|
|
|
2051
2051
|
// beginning of this function.
|
|
2052
2052
|
continue;
|
|
2053
2053
|
}
|
|
2054
|
-
genAISchema['type'] = Object.
|
|
2054
|
+
genAISchema['type'] = Object.values(Type).includes(fieldValue.toUpperCase())
|
|
2055
2055
|
? fieldValue.toUpperCase()
|
|
2056
2056
|
: Type.TYPE_UNSPECIFIED;
|
|
2057
2057
|
}
|
|
@@ -2410,7 +2410,7 @@ function filterToJsonSchema(schema) {
|
|
|
2410
2410
|
}
|
|
2411
2411
|
else if (fieldName === 'type') {
|
|
2412
2412
|
const typeValue = fieldValue.toUpperCase();
|
|
2413
|
-
filteredSchema[fieldName] = Object.
|
|
2413
|
+
filteredSchema[fieldName] = Object.values(Type).includes(typeValue)
|
|
2414
2414
|
? typeValue
|
|
2415
2415
|
: Type.TYPE_UNSPECIFIED;
|
|
2416
2416
|
}
|
|
@@ -3087,6 +3087,10 @@ function googleMapsToVertex$2(apiClient, fromObject) {
|
|
|
3087
3087
|
}
|
|
3088
3088
|
return toObject;
|
|
3089
3089
|
}
|
|
3090
|
+
function urlContextToVertex$2() {
|
|
3091
|
+
const toObject = {};
|
|
3092
|
+
return toObject;
|
|
3093
|
+
}
|
|
3090
3094
|
function toolToVertex$2(apiClient, fromObject) {
|
|
3091
3095
|
const toObject = {};
|
|
3092
3096
|
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
@@ -3125,8 +3129,9 @@ function toolToVertex$2(apiClient, fromObject) {
|
|
|
3125
3129
|
if (fromGoogleMaps != null) {
|
|
3126
3130
|
setValueByPath(toObject, ['googleMaps'], googleMapsToVertex$2(apiClient, fromGoogleMaps));
|
|
3127
3131
|
}
|
|
3128
|
-
|
|
3129
|
-
|
|
3132
|
+
const fromUrlContext = getValueByPath(fromObject, ['urlContext']);
|
|
3133
|
+
if (fromUrlContext != null) {
|
|
3134
|
+
setValueByPath(toObject, ['urlContext'], urlContextToVertex$2());
|
|
3130
3135
|
}
|
|
3131
3136
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
3132
3137
|
'codeExecution',
|
|
@@ -5428,6 +5433,10 @@ function urlContextToMldev$2() {
|
|
|
5428
5433
|
const toObject = {};
|
|
5429
5434
|
return toObject;
|
|
5430
5435
|
}
|
|
5436
|
+
function urlContextToVertex$1() {
|
|
5437
|
+
const toObject = {};
|
|
5438
|
+
return toObject;
|
|
5439
|
+
}
|
|
5431
5440
|
function toolToMldev$2(apiClient, fromObject) {
|
|
5432
5441
|
const toObject = {};
|
|
5433
5442
|
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
@@ -5511,8 +5520,9 @@ function toolToVertex$1(apiClient, fromObject) {
|
|
|
5511
5520
|
if (fromGoogleMaps != null) {
|
|
5512
5521
|
setValueByPath(toObject, ['googleMaps'], googleMapsToVertex$1(apiClient, fromGoogleMaps));
|
|
5513
5522
|
}
|
|
5514
|
-
|
|
5515
|
-
|
|
5523
|
+
const fromUrlContext = getValueByPath(fromObject, ['urlContext']);
|
|
5524
|
+
if (fromUrlContext != null) {
|
|
5525
|
+
setValueByPath(toObject, ['urlContext'], urlContextToVertex$1());
|
|
5516
5526
|
}
|
|
5517
5527
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
5518
5528
|
'codeExecution',
|
|
@@ -8108,8 +8118,11 @@ function generateVideosConfigToMldev(apiClient, fromObject, parentObject) {
|
|
|
8108
8118
|
if (parentObject !== undefined && fromNegativePrompt != null) {
|
|
8109
8119
|
setValueByPath(parentObject, ['parameters', 'negativePrompt'], fromNegativePrompt);
|
|
8110
8120
|
}
|
|
8111
|
-
|
|
8112
|
-
|
|
8121
|
+
const fromEnhancePrompt = getValueByPath(fromObject, [
|
|
8122
|
+
'enhancePrompt',
|
|
8123
|
+
]);
|
|
8124
|
+
if (parentObject !== undefined && fromEnhancePrompt != null) {
|
|
8125
|
+
setValueByPath(parentObject, ['parameters', 'enhancePrompt'], fromEnhancePrompt);
|
|
8113
8126
|
}
|
|
8114
8127
|
if (getValueByPath(fromObject, ['generateAudio']) !== undefined) {
|
|
8115
8128
|
throw new Error('generateAudio parameter is not supported in Gemini API.');
|
|
@@ -8501,6 +8514,10 @@ function googleMapsToVertex(apiClient, fromObject) {
|
|
|
8501
8514
|
}
|
|
8502
8515
|
return toObject;
|
|
8503
8516
|
}
|
|
8517
|
+
function urlContextToVertex() {
|
|
8518
|
+
const toObject = {};
|
|
8519
|
+
return toObject;
|
|
8520
|
+
}
|
|
8504
8521
|
function toolToVertex(apiClient, fromObject) {
|
|
8505
8522
|
const toObject = {};
|
|
8506
8523
|
const fromFunctionDeclarations = getValueByPath(fromObject, [
|
|
@@ -8539,8 +8556,9 @@ function toolToVertex(apiClient, fromObject) {
|
|
|
8539
8556
|
if (fromGoogleMaps != null) {
|
|
8540
8557
|
setValueByPath(toObject, ['googleMaps'], googleMapsToVertex(apiClient, fromGoogleMaps));
|
|
8541
8558
|
}
|
|
8542
|
-
|
|
8543
|
-
|
|
8559
|
+
const fromUrlContext = getValueByPath(fromObject, ['urlContext']);
|
|
8560
|
+
if (fromUrlContext != null) {
|
|
8561
|
+
setValueByPath(toObject, ['urlContext'], urlContextToVertex());
|
|
8544
8562
|
}
|
|
8545
8563
|
const fromCodeExecution = getValueByPath(fromObject, [
|
|
8546
8564
|
'codeExecution',
|
|
@@ -10131,6 +10149,34 @@ function citationMetadataFromVertex(apiClient, fromObject) {
|
|
|
10131
10149
|
}
|
|
10132
10150
|
return toObject;
|
|
10133
10151
|
}
|
|
10152
|
+
function urlMetadataFromVertex(apiClient, fromObject) {
|
|
10153
|
+
const toObject = {};
|
|
10154
|
+
const fromRetrievedUrl = getValueByPath(fromObject, ['retrievedUrl']);
|
|
10155
|
+
if (fromRetrievedUrl != null) {
|
|
10156
|
+
setValueByPath(toObject, ['retrievedUrl'], fromRetrievedUrl);
|
|
10157
|
+
}
|
|
10158
|
+
const fromUrlRetrievalStatus = getValueByPath(fromObject, [
|
|
10159
|
+
'urlRetrievalStatus',
|
|
10160
|
+
]);
|
|
10161
|
+
if (fromUrlRetrievalStatus != null) {
|
|
10162
|
+
setValueByPath(toObject, ['urlRetrievalStatus'], fromUrlRetrievalStatus);
|
|
10163
|
+
}
|
|
10164
|
+
return toObject;
|
|
10165
|
+
}
|
|
10166
|
+
function urlContextMetadataFromVertex(apiClient, fromObject) {
|
|
10167
|
+
const toObject = {};
|
|
10168
|
+
const fromUrlMetadata = getValueByPath(fromObject, ['urlMetadata']);
|
|
10169
|
+
if (fromUrlMetadata != null) {
|
|
10170
|
+
let transformedList = fromUrlMetadata;
|
|
10171
|
+
if (Array.isArray(transformedList)) {
|
|
10172
|
+
transformedList = transformedList.map((item) => {
|
|
10173
|
+
return urlMetadataFromVertex(apiClient, item);
|
|
10174
|
+
});
|
|
10175
|
+
}
|
|
10176
|
+
setValueByPath(toObject, ['urlMetadata'], transformedList);
|
|
10177
|
+
}
|
|
10178
|
+
return toObject;
|
|
10179
|
+
}
|
|
10134
10180
|
function candidateFromVertex(apiClient, fromObject) {
|
|
10135
10181
|
const toObject = {};
|
|
10136
10182
|
const fromContent = getValueByPath(fromObject, ['content']);
|
|
@@ -10153,6 +10199,12 @@ function candidateFromVertex(apiClient, fromObject) {
|
|
|
10153
10199
|
if (fromFinishReason != null) {
|
|
10154
10200
|
setValueByPath(toObject, ['finishReason'], fromFinishReason);
|
|
10155
10201
|
}
|
|
10202
|
+
const fromUrlContextMetadata = getValueByPath(fromObject, [
|
|
10203
|
+
'urlContextMetadata',
|
|
10204
|
+
]);
|
|
10205
|
+
if (fromUrlContextMetadata != null) {
|
|
10206
|
+
setValueByPath(toObject, ['urlContextMetadata'], urlContextMetadataFromVertex(apiClient, fromUrlContextMetadata));
|
|
10207
|
+
}
|
|
10156
10208
|
const fromAvgLogprobs = getValueByPath(fromObject, ['avgLogprobs']);
|
|
10157
10209
|
if (fromAvgLogprobs != null) {
|
|
10158
10210
|
setValueByPath(toObject, ['avgLogprobs'], fromAvgLogprobs);
|
|
@@ -10619,7 +10671,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
10619
10671
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
10620
10672
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
10621
10673
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
10622
|
-
const SDK_VERSION = '1.
|
|
10674
|
+
const SDK_VERSION = '1.4.0'; // x-release-please-version
|
|
10623
10675
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
10624
10676
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
10625
10677
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -15716,7 +15768,7 @@ class GoogleGenAI {
|
|
|
15716
15768
|
}
|
|
15717
15769
|
this.vertexai =
|
|
15718
15770
|
(_b = (_a = options.vertexai) !== null && _a !== void 0 ? _a : getBooleanEnv('GOOGLE_GENAI_USE_VERTEXAI')) !== null && _b !== void 0 ? _b : false;
|
|
15719
|
-
const envApiKey =
|
|
15771
|
+
const envApiKey = getApiKeyFromEnv();
|
|
15720
15772
|
const envProject = getEnv('GOOGLE_CLOUD_PROJECT');
|
|
15721
15773
|
const envLocation = getEnv('GOOGLE_CLOUD_LOCATION');
|
|
15722
15774
|
this.apiKey = (_c = options.apiKey) !== null && _c !== void 0 ? _c : envApiKey;
|
|
@@ -15794,6 +15846,14 @@ function stringToBoolean(str) {
|
|
|
15794
15846
|
}
|
|
15795
15847
|
return str.toLowerCase() === 'true';
|
|
15796
15848
|
}
|
|
15849
|
+
function getApiKeyFromEnv() {
|
|
15850
|
+
const envGoogleApiKey = getEnv('GOOGLE_API_KEY');
|
|
15851
|
+
const envGeminiApiKey = getEnv('GEMINI_API_KEY');
|
|
15852
|
+
if (envGoogleApiKey && envGeminiApiKey) {
|
|
15853
|
+
console.warn('Both GOOGLE_API_KEY and GEMINI_API_KEY are set. Using GOOGLE_API_KEY.');
|
|
15854
|
+
}
|
|
15855
|
+
return envGoogleApiKey || envGeminiApiKey;
|
|
15856
|
+
}
|
|
15797
15857
|
|
|
15798
15858
|
export { ActivityHandling, AdapterSize, AuthType, Behavior, BlockedReason, Caches, Chat, Chats, ComputeTokensResponse, ControlReferenceImage, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DeleteModelResponse, DynamicRetrievalConfigMode, EditImageResponse, EditMode, EmbedContentResponse, EndSensitivity, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, FunctionResponseScheduling, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpResponse, ImagePromptLanguage, JobState, Language, ListCachedContentsResponse, ListFilesResponse, ListModelsResponse, ListTuningJobsResponse, Live, LiveClientToolResponse, LiveMusicPlaybackControl, LiveMusicServerMessage, LiveSendToolResponseParameters, LiveServerMessage, MaskReferenceImage, MaskReferenceMode, MediaModality, MediaResolution, Modality, Mode, Models, Operations, Outcome, PagedItem, Pager, PersonGeneration, RawReferenceImage, ReplayResponse, SafetyFilterLevel, Scale, Session, StartSensitivity, StyleReferenceImage, SubjectReferenceImage, SubjectReferenceType, Tokens, TrafficType, TurnCoverage, Type, UpscaleImageResponse, UrlRetrievalStatus, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, mcpToTool, setDefaultBaseUrls };
|
|
15799
15859
|
//# sourceMappingURL=index.mjs.map
|