@google/genai 2.2.0 → 2.3.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 +4 -1
- package/dist/genai.d.ts +42 -29
- package/dist/index.cjs +73 -6
- package/dist/index.mjs +73 -6
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.cjs +73 -6
- package/dist/node/index.mjs +73 -6
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/node.d.ts +42 -29
- package/dist/tokenizer/node.mjs.map +1 -1
- package/dist/vertex_internal/index.cjs +1 -1
- package/dist/vertex_internal/index.cjs.map +1 -1
- package/dist/vertex_internal/index.d.ts +14 -0
- package/dist/vertex_internal/index.js +1 -1
- package/dist/vertex_internal/index.js.map +1 -1
- package/dist/web/index.mjs +73 -6
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +42 -29
- package/package.json +1 -1
package/dist/web/index.mjs
CHANGED
|
@@ -8232,6 +8232,12 @@ function liveConnectConfigToMldev$1(fromObject, parentObject) {
|
|
|
8232
8232
|
}
|
|
8233
8233
|
setValueByPath(parentObject, ['setup', 'safetySettings'], transformedList);
|
|
8234
8234
|
}
|
|
8235
|
+
const fromStreamTranslationConfig = getValueByPath(fromObject, [
|
|
8236
|
+
'streamTranslationConfig',
|
|
8237
|
+
]);
|
|
8238
|
+
if (parentObject !== undefined && fromStreamTranslationConfig != null) {
|
|
8239
|
+
setValueByPath(parentObject, ['setup', 'generationConfig', 'streamTranslationConfig'], fromStreamTranslationConfig);
|
|
8240
|
+
}
|
|
8235
8241
|
return toObject;
|
|
8236
8242
|
}
|
|
8237
8243
|
function liveConnectConfigToVertex(fromObject, parentObject) {
|
|
@@ -8364,6 +8370,9 @@ function liveConnectConfigToVertex(fromObject, parentObject) {
|
|
|
8364
8370
|
}
|
|
8365
8371
|
setValueByPath(parentObject, ['setup', 'safetySettings'], transformedList);
|
|
8366
8372
|
}
|
|
8373
|
+
if (getValueByPath(fromObject, ['streamTranslationConfig']) !== undefined) {
|
|
8374
|
+
throw new Error('streamTranslationConfig parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.');
|
|
8375
|
+
}
|
|
8367
8376
|
return toObject;
|
|
8368
8377
|
}
|
|
8369
8378
|
function liveConnectParametersToMldev(apiClient, fromObject) {
|
|
@@ -12784,7 +12793,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
12784
12793
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
12785
12794
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
12786
12795
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
12787
|
-
const SDK_VERSION = '2.
|
|
12796
|
+
const SDK_VERSION = '2.3.0'; // x-release-please-version
|
|
12788
12797
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
12789
12798
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
12790
12799
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -16434,6 +16443,12 @@ function liveConnectConfigToMldev(fromObject, parentObject) {
|
|
|
16434
16443
|
}
|
|
16435
16444
|
setValueByPath(parentObject, ['setup', 'safetySettings'], transformedList);
|
|
16436
16445
|
}
|
|
16446
|
+
const fromStreamTranslationConfig = getValueByPath(fromObject, [
|
|
16447
|
+
'streamTranslationConfig',
|
|
16448
|
+
]);
|
|
16449
|
+
if (parentObject !== undefined && fromStreamTranslationConfig != null) {
|
|
16450
|
+
setValueByPath(parentObject, ['setup', 'generationConfig', 'streamTranslationConfig'], fromStreamTranslationConfig);
|
|
16451
|
+
}
|
|
16437
16452
|
return toObject;
|
|
16438
16453
|
}
|
|
16439
16454
|
function liveConnectConstraintsToMldev(apiClient, fromObject) {
|
|
@@ -18694,10 +18709,14 @@ class BaseInteractions extends APIResource {
|
|
|
18694
18709
|
});
|
|
18695
18710
|
const isStreaming = (_a = params.stream) !== null && _a !== void 0 ? _a : false;
|
|
18696
18711
|
const promise = this._client.post(path `/${api_version}/interactions`, Object.assign(Object.assign(Object.assign({ body }, options), { stream: isStreaming }), (needsLegacyLyriaShim && isStreaming ? { __streamClass: LegacyLyriaStream } : {})));
|
|
18697
|
-
if (
|
|
18698
|
-
return promise
|
|
18712
|
+
if (isStreaming) {
|
|
18713
|
+
return promise;
|
|
18699
18714
|
}
|
|
18700
|
-
|
|
18715
|
+
let nonStreaming = promise;
|
|
18716
|
+
if (needsLegacyLyriaShim) {
|
|
18717
|
+
nonStreaming = nonStreaming._thenUnwrap((data) => coerceLegacyInteractionResponse(data));
|
|
18718
|
+
}
|
|
18719
|
+
return nonStreaming._thenUnwrap(addOutputProperties);
|
|
18701
18720
|
}
|
|
18702
18721
|
/**
|
|
18703
18722
|
* Deletes the interaction by id.
|
|
@@ -18726,17 +18745,64 @@ class BaseInteractions extends APIResource {
|
|
|
18726
18745
|
*/
|
|
18727
18746
|
cancel(id, params = {}, options) {
|
|
18728
18747
|
const { api_version = this._client.apiVersion } = params !== null && params !== void 0 ? params : {};
|
|
18729
|
-
return this._client.post(path `/${api_version}/interactions/${id}/cancel`, options);
|
|
18748
|
+
return this._client.post(path `/${api_version}/interactions/${id}/cancel`, options)._thenUnwrap(addOutputProperties);
|
|
18730
18749
|
}
|
|
18731
18750
|
get(id, params = {}, options) {
|
|
18732
18751
|
var _a;
|
|
18733
18752
|
const _b = params !== null && params !== void 0 ? params : {}, { api_version = this._client.apiVersion } = _b, query = __rest(_b, ["api_version"]);
|
|
18734
|
-
|
|
18753
|
+
const response = this._client.get(path `/${api_version}/interactions/${id}`, Object.assign(Object.assign({ query }, options), { stream: (_a = params === null || params === void 0 ? void 0 : params.stream) !== null && _a !== void 0 ? _a : false }));
|
|
18754
|
+
if (params === null || params === void 0 ? void 0 : params.stream) {
|
|
18755
|
+
return response;
|
|
18756
|
+
}
|
|
18757
|
+
return response._thenUnwrap(addOutputProperties);
|
|
18735
18758
|
}
|
|
18736
18759
|
}
|
|
18737
18760
|
BaseInteractions._key = Object.freeze(['interactions']);
|
|
18738
18761
|
class Interactions extends BaseInteractions {
|
|
18739
18762
|
}
|
|
18763
|
+
function addOutputProperties(interaction) {
|
|
18764
|
+
var _a, _b;
|
|
18765
|
+
const steps = (_a = interaction.steps) !== null && _a !== void 0 ? _a : [];
|
|
18766
|
+
let firstTrailing = steps.length;
|
|
18767
|
+
while (firstTrailing > 0 && steps[firstTrailing - 1].type === 'model_output') {
|
|
18768
|
+
firstTrailing--;
|
|
18769
|
+
}
|
|
18770
|
+
const modelSteps = steps.slice(firstTrailing);
|
|
18771
|
+
const output = modelSteps.flatMap((step) => { var _a; return (_a = step.content) !== null && _a !== void 0 ? _a : []; });
|
|
18772
|
+
const textParts = [];
|
|
18773
|
+
for (let i = output.length - 1; i >= 0; i--) {
|
|
18774
|
+
const content = output[i];
|
|
18775
|
+
if (content.type !== 'text')
|
|
18776
|
+
break;
|
|
18777
|
+
textParts.push((_b = content.text) !== null && _b !== void 0 ? _b : '');
|
|
18778
|
+
}
|
|
18779
|
+
const output_text = textParts.reverse().join('');
|
|
18780
|
+
let output_image;
|
|
18781
|
+
let output_audio;
|
|
18782
|
+
let output_video;
|
|
18783
|
+
for (let i = steps.length - 1; i >= 0; i--) {
|
|
18784
|
+
const step = steps[i];
|
|
18785
|
+
const anyStep = step;
|
|
18786
|
+
if (anyStep.type === 'user_input') {
|
|
18787
|
+
break;
|
|
18788
|
+
}
|
|
18789
|
+
if (anyStep.type === 'model_output' && anyStep.content) {
|
|
18790
|
+
for (let j = anyStep.content.length - 1; j >= 0; j--) {
|
|
18791
|
+
const content = anyStep.content[j];
|
|
18792
|
+
if (content.type === 'image' && !output_image) {
|
|
18793
|
+
output_image = content;
|
|
18794
|
+
}
|
|
18795
|
+
if (content.type === 'audio' && !output_audio) {
|
|
18796
|
+
output_audio = content;
|
|
18797
|
+
}
|
|
18798
|
+
if (content.type === 'video' && !output_video) {
|
|
18799
|
+
output_video = content;
|
|
18800
|
+
}
|
|
18801
|
+
}
|
|
18802
|
+
}
|
|
18803
|
+
}
|
|
18804
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, interaction), (output_text && { output_text })), (output_image && { output_image })), (output_audio && { output_audio })), (output_video && { output_video }));
|
|
18805
|
+
}
|
|
18740
18806
|
|
|
18741
18807
|
/**
|
|
18742
18808
|
* @license
|
|
@@ -20918,6 +20984,7 @@ class GoogleGenAI {
|
|
|
20918
20984
|
if (this._interactions !== undefined) {
|
|
20919
20985
|
return this._interactions;
|
|
20920
20986
|
}
|
|
20987
|
+
console.warn('GoogleGenAI.interactions: Interactions usage is experimental and may change in future versions.');
|
|
20921
20988
|
this._interactions = this.getNextGenClient().interactions;
|
|
20922
20989
|
return this._interactions;
|
|
20923
20990
|
}
|