@ai-sdk/google 4.0.0-canary.73 → 4.0.0-canary.75
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/CHANGELOG.md +12 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +113 -87
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +1 -1
- package/dist/internal/index.js +40 -19
- package/dist/internal/index.js.map +1 -1
- package/docs/15-google.mdx +1 -0
- package/package.json +1 -1
- package/src/convert-to-google-messages.ts +46 -2
- package/src/google-embedding-model-options.ts +1 -0
- package/src/google-json-accumulator.ts +10 -10
- package/src/google-language-model-options.ts +2 -0
- package/src/google-language-model.ts +4 -1
- package/src/interactions/build-google-interactions-stream-transform.ts +7 -7
- package/src/interactions/extract-google-interactions-sources.ts +20 -13
- package/src/interactions/google-interactions-language-model.ts +50 -46
- package/src/interactions/stream-google-interactions.ts +8 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @ai-sdk/google
|
|
2
2
|
|
|
3
|
+
## 4.0.0-canary.75
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 00a0f36: feat(google, google-vertex): added `gemini-embedding-2`, `deep-research-max-preview-04-2026` and `deep-research-preview-04-2026`
|
|
8
|
+
|
|
9
|
+
## 4.0.0-canary.74
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- a8d70b6: fix(google): auto-inject `skip_thought_signature_validator` for Gemini 3 tool-call replays without a signature
|
|
14
|
+
|
|
3
15
|
## 4.0.0-canary.73
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ declare const googleErrorDataSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
11
11
|
}>;
|
|
12
12
|
type GoogleErrorData = InferSchema<typeof googleErrorDataSchema>;
|
|
13
13
|
|
|
14
|
-
type GoogleModelId = 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-2.0-flash-lite' | 'gemini-2.0-flash-lite-001' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-image' | 'gemini-2.5-flash-lite' | 'gemini-2.5-flash-preview-tts' | 'gemini-2.5-pro-preview-tts' | 'gemini-2.5-flash-native-audio-latest' | 'gemini-2.5-flash-native-audio-preview-09-2025' | 'gemini-2.5-flash-native-audio-preview-12-2025' | 'gemini-2.5-computer-use-preview-10-2025' | 'gemini-3-pro-preview' | 'gemini-3-pro-image-preview' | 'gemini-3-flash-preview' | 'gemini-3.1-pro-preview' | 'gemini-3.1-pro-preview-customtools' | 'gemini-3.1-flash-image-preview' | 'gemini-3.1-flash-lite-preview' | 'gemini-3.1-flash-tts-preview' | 'gemini-3.5-flash' | 'gemini-pro-latest' | 'gemini-flash-latest' | 'gemini-flash-lite-latest' | 'deep-research-pro-preview-12-2025' | 'nano-banana-pro-preview' | 'aqa' | 'gemini-robotics-er-1.5-preview' | 'gemma-3-1b-it' | 'gemma-3-4b-it' | 'gemma-3n-e4b-it' | 'gemma-3n-e2b-it' | 'gemma-3-12b-it' | 'gemma-3-27b-it' | (string & {});
|
|
14
|
+
type GoogleModelId = 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-2.0-flash-lite' | 'gemini-2.0-flash-lite-001' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-image' | 'gemini-2.5-flash-lite' | 'gemini-2.5-flash-preview-tts' | 'gemini-2.5-pro-preview-tts' | 'gemini-2.5-flash-native-audio-latest' | 'gemini-2.5-flash-native-audio-preview-09-2025' | 'gemini-2.5-flash-native-audio-preview-12-2025' | 'gemini-2.5-computer-use-preview-10-2025' | 'gemini-3-pro-preview' | 'gemini-3-pro-image-preview' | 'gemini-3-flash-preview' | 'gemini-3.1-pro-preview' | 'gemini-3.1-pro-preview-customtools' | 'gemini-3.1-flash-image-preview' | 'gemini-3.1-flash-lite-preview' | 'gemini-3.1-flash-tts-preview' | 'gemini-3.5-flash' | 'gemini-pro-latest' | 'gemini-flash-latest' | 'gemini-flash-lite-latest' | 'deep-research-pro-preview-12-2025' | 'deep-research-max-preview-04-2026' | 'deep-research-preview-04-2026' | 'nano-banana-pro-preview' | 'aqa' | 'gemini-robotics-er-1.5-preview' | 'gemma-3-1b-it' | 'gemma-3-4b-it' | 'gemma-3n-e4b-it' | 'gemma-3n-e2b-it' | 'gemma-3-12b-it' | 'gemma-3-27b-it' | (string & {});
|
|
15
15
|
declare const googleLanguageModelOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
16
16
|
responseModalities?: ("TEXT" | "IMAGE")[] | undefined;
|
|
17
17
|
thinkingConfig?: {
|
|
@@ -231,7 +231,7 @@ declare const googleImageModelOptionsSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
231
231
|
}>;
|
|
232
232
|
type GoogleImageModelOptions = InferSchema<typeof googleImageModelOptionsSchema>;
|
|
233
233
|
|
|
234
|
-
type GoogleEmbeddingModelId = 'gemini-embedding-001' | 'gemini-embedding-2-preview' | (string & {});
|
|
234
|
+
type GoogleEmbeddingModelId = 'gemini-embedding-001' | 'gemini-embedding-2' | 'gemini-embedding-2-preview' | (string & {});
|
|
235
235
|
declare const googleEmbeddingModelOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
236
236
|
outputDimensionality?: number | undefined;
|
|
237
237
|
taskType?: "SEMANTIC_SIMILARITY" | "CLASSIFICATION" | "CLUSTERING" | "RETRIEVAL_DOCUMENT" | "RETRIEVAL_QUERY" | "QUESTION_ANSWERING" | "FACT_VERIFICATION" | "CODE_RETRIEVAL_QUERY" | undefined;
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "@ai-sdk/provider-utils";
|
|
8
8
|
|
|
9
9
|
// src/version.ts
|
|
10
|
-
var VERSION = true ? "4.0.0-canary.
|
|
10
|
+
var VERSION = true ? "4.0.0-canary.75" : "0.0.0-test";
|
|
11
11
|
|
|
12
12
|
// src/google-embedding-model.ts
|
|
13
13
|
import {
|
|
@@ -436,6 +436,7 @@ import {
|
|
|
436
436
|
resolveFullMediaType,
|
|
437
437
|
resolveProviderReference
|
|
438
438
|
} from "@ai-sdk/provider-utils";
|
|
439
|
+
var SKIP_THOUGHT_SIGNATURE_VALIDATOR = "skip_thought_signature_validator";
|
|
439
440
|
var dataUrlRegex = /^data:([^;,]+);base64,(.+)$/s;
|
|
440
441
|
function parseBase64DataUrl(value) {
|
|
441
442
|
const match = dataUrlRegex.exec(value);
|
|
@@ -548,16 +549,25 @@ function appendLegacyToolResultParts(parts, toolName, outputValue, toolCallId) {
|
|
|
548
549
|
}
|
|
549
550
|
}
|
|
550
551
|
function convertToGoogleMessages(prompt, options) {
|
|
551
|
-
var _a, _b, _c, _d;
|
|
552
|
+
var _a, _b, _c, _d, _e;
|
|
552
553
|
const systemInstructionParts = [];
|
|
553
554
|
const contents = [];
|
|
554
555
|
let systemMessagesAllowed = true;
|
|
555
556
|
const isGemmaModel = (_a = options == null ? void 0 : options.isGemmaModel) != null ? _a : false;
|
|
556
|
-
const
|
|
557
|
+
const isGemini3Model2 = (_b = options == null ? void 0 : options.isGemini3Model) != null ? _b : false;
|
|
558
|
+
const onWarning = options == null ? void 0 : options.onWarning;
|
|
559
|
+
const providerOptionsNames = (_c = options == null ? void 0 : options.providerOptionsNames) != null ? _c : ["google"];
|
|
557
560
|
const isVertexLike = !providerOptionsNames.includes("google");
|
|
558
|
-
const supportsFunctionResponseParts = (
|
|
561
|
+
const supportsFunctionResponseParts = (_d = options == null ? void 0 : options.supportsFunctionResponseParts) != null ? _d : true;
|
|
562
|
+
let sentinelInjected = false;
|
|
563
|
+
const missingSignatureToolNames = [];
|
|
564
|
+
const injectSkipSignature = (toolName) => {
|
|
565
|
+
missingSignatureToolNames.push(toolName);
|
|
566
|
+
sentinelInjected = true;
|
|
567
|
+
return SKIP_THOUGHT_SIGNATURE_VALIDATOR;
|
|
568
|
+
};
|
|
559
569
|
const readProviderOpts = (part) => {
|
|
560
|
-
var _a2, _b2, _c2, _d2,
|
|
570
|
+
var _a2, _b2, _c2, _d2, _e2;
|
|
561
571
|
for (const name of providerOptionsNames) {
|
|
562
572
|
const v = (_a2 = part.providerOptions) == null ? void 0 : _a2[name];
|
|
563
573
|
if (v != null) return v;
|
|
@@ -565,7 +575,7 @@ function convertToGoogleMessages(prompt, options) {
|
|
|
565
575
|
if (isVertexLike) {
|
|
566
576
|
return (_b2 = part.providerOptions) == null ? void 0 : _b2.google;
|
|
567
577
|
}
|
|
568
|
-
return (
|
|
578
|
+
return (_e2 = (_c2 = part.providerOptions) == null ? void 0 : _c2.googleVertex) != null ? _e2 : (_d2 = part.providerOptions) == null ? void 0 : _d2.vertex;
|
|
569
579
|
};
|
|
570
580
|
for (const { role, content } of prompt) {
|
|
571
581
|
switch (role) {
|
|
@@ -737,6 +747,7 @@ function convertToGoogleMessages(prompt, options) {
|
|
|
737
747
|
case "tool-call": {
|
|
738
748
|
const serverToolCallId = (providerOpts == null ? void 0 : providerOpts.serverToolCallId) != null ? String(providerOpts.serverToolCallId) : void 0;
|
|
739
749
|
const serverToolType = (providerOpts == null ? void 0 : providerOpts.serverToolType) != null ? String(providerOpts.serverToolType) : void 0;
|
|
750
|
+
const effectiveThoughtSignature = thoughtSignature != null ? thoughtSignature : isGemini3Model2 ? injectSkipSignature(part.toolName) : void 0;
|
|
740
751
|
if (serverToolCallId && serverToolType) {
|
|
741
752
|
return {
|
|
742
753
|
toolCall: {
|
|
@@ -744,7 +755,7 @@ function convertToGoogleMessages(prompt, options) {
|
|
|
744
755
|
args: typeof part.input === "string" ? JSON.parse(part.input) : part.input,
|
|
745
756
|
id: serverToolCallId
|
|
746
757
|
},
|
|
747
|
-
thoughtSignature
|
|
758
|
+
thoughtSignature: effectiveThoughtSignature
|
|
748
759
|
};
|
|
749
760
|
}
|
|
750
761
|
return {
|
|
@@ -753,7 +764,7 @@ function convertToGoogleMessages(prompt, options) {
|
|
|
753
764
|
name: part.toolName,
|
|
754
765
|
args: part.input
|
|
755
766
|
},
|
|
756
|
-
thoughtSignature
|
|
767
|
+
thoughtSignature: effectiveThoughtSignature
|
|
757
768
|
};
|
|
758
769
|
}
|
|
759
770
|
case "tool-result": {
|
|
@@ -827,7 +838,7 @@ function convertToGoogleMessages(prompt, options) {
|
|
|
827
838
|
name: part.toolName,
|
|
828
839
|
response: {
|
|
829
840
|
name: part.toolName,
|
|
830
|
-
content: output.type === "execution-denied" ? (
|
|
841
|
+
content: output.type === "execution-denied" ? (_e = output.reason) != null ? _e : "Tool call execution denied." : output.value
|
|
831
842
|
}
|
|
832
843
|
}
|
|
833
844
|
});
|
|
@@ -845,6 +856,13 @@ function convertToGoogleMessages(prompt, options) {
|
|
|
845
856
|
const systemText = systemInstructionParts.map((part) => part.text).join("\n\n");
|
|
846
857
|
contents[0].parts.unshift({ text: systemText + "\n\n" });
|
|
847
858
|
}
|
|
859
|
+
if (sentinelInjected && onWarning != null) {
|
|
860
|
+
const uniqueToolNames = Array.from(new Set(missingSignatureToolNames));
|
|
861
|
+
onWarning({
|
|
862
|
+
type: "other",
|
|
863
|
+
message: `Replayed ${missingSignatureToolNames.length} \`functionCall\` part(s) for a Gemini 3 model without a \`thoughtSignature\` (tools: ${uniqueToolNames.map((name) => `\`${name}\``).join(", ")}). Injected the documented \`skip_thought_signature_validator\` sentinel to keep the request from failing with HTTP 400. The likely cause is application code that drops \`providerOptions.google.thoughtSignature\` when persisting or serializing assistant tool-call messages. See https://ai.google.dev/gemini-api/docs/thought-signatures.`
|
|
864
|
+
});
|
|
865
|
+
}
|
|
848
866
|
return {
|
|
849
867
|
systemInstruction: systemInstructionParts.length > 0 && !isGemmaModel ? { parts: systemInstructionParts } : void 0,
|
|
850
868
|
contents
|
|
@@ -1410,19 +1428,19 @@ var GoogleJSONAccumulator = class {
|
|
|
1410
1428
|
let fragment = "";
|
|
1411
1429
|
const startIdx = this.pathStack.length - 1;
|
|
1412
1430
|
for (let i = startIdx; i < targetContainer.length; i++) {
|
|
1413
|
-
const
|
|
1431
|
+
const pathSegment = targetContainer[i];
|
|
1414
1432
|
const parentEntry = this.pathStack[this.pathStack.length - 1];
|
|
1415
1433
|
if (parentEntry.childCount > 0) {
|
|
1416
1434
|
fragment += ",";
|
|
1417
1435
|
}
|
|
1418
1436
|
parentEntry.childCount++;
|
|
1419
|
-
if (typeof
|
|
1420
|
-
fragment += `${JSON.stringify(
|
|
1437
|
+
if (typeof pathSegment === "string") {
|
|
1438
|
+
fragment += `${JSON.stringify(pathSegment)}:`;
|
|
1421
1439
|
}
|
|
1422
1440
|
const childSeg = i + 1 < targetContainer.length ? targetContainer[i + 1] : leafSegment;
|
|
1423
1441
|
const isArray = typeof childSeg === "number";
|
|
1424
1442
|
fragment += isArray ? "[" : "{";
|
|
1425
|
-
this.pathStack.push({ segment:
|
|
1443
|
+
this.pathStack.push({ segment: pathSegment, isArray, childCount: 0 });
|
|
1426
1444
|
}
|
|
1427
1445
|
return fragment;
|
|
1428
1446
|
}
|
|
@@ -1468,21 +1486,21 @@ function parsePath(rawPath) {
|
|
|
1468
1486
|
}
|
|
1469
1487
|
function getNestedValue(obj, segments) {
|
|
1470
1488
|
let current = obj;
|
|
1471
|
-
for (const
|
|
1489
|
+
for (const pathSegment of segments) {
|
|
1472
1490
|
if (current == null || typeof current !== "object") return void 0;
|
|
1473
|
-
current = current[
|
|
1491
|
+
current = current[pathSegment];
|
|
1474
1492
|
}
|
|
1475
1493
|
return current;
|
|
1476
1494
|
}
|
|
1477
1495
|
function setNestedValue(obj, segments, value) {
|
|
1478
1496
|
let current = obj;
|
|
1479
1497
|
for (let i = 0; i < segments.length - 1; i++) {
|
|
1480
|
-
const
|
|
1498
|
+
const pathSegment = segments[i];
|
|
1481
1499
|
const nextSeg = segments[i + 1];
|
|
1482
|
-
if (current[
|
|
1483
|
-
current[
|
|
1500
|
+
if (current[pathSegment] == null) {
|
|
1501
|
+
current[pathSegment] = typeof nextSeg === "number" ? [] : {};
|
|
1484
1502
|
}
|
|
1485
|
-
current = current[
|
|
1503
|
+
current = current[pathSegment];
|
|
1486
1504
|
}
|
|
1487
1505
|
current[segments[segments.length - 1]] = value;
|
|
1488
1506
|
}
|
|
@@ -1617,9 +1635,12 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1617
1635
|
} : void 0;
|
|
1618
1636
|
const bodyServiceTier = isVertexProvider ? void 0 : googleOptions == null ? void 0 : googleOptions.serviceTier;
|
|
1619
1637
|
const isGemmaModel = this.modelId.toLowerCase().startsWith("gemma-");
|
|
1620
|
-
const
|
|
1638
|
+
const isGemini3Model2 = /^gemini-3[.-]/.test(this.modelId);
|
|
1639
|
+
const supportsFunctionResponseParts = isGemini3Model2;
|
|
1621
1640
|
const { contents, systemInstruction } = convertToGoogleMessages(prompt, {
|
|
1622
1641
|
isGemmaModel,
|
|
1642
|
+
isGemini3Model: isGemini3Model2,
|
|
1643
|
+
onWarning: (warning) => warnings.push(warning),
|
|
1623
1644
|
providerOptionsNames,
|
|
1624
1645
|
supportsFunctionResponseParts
|
|
1625
1646
|
});
|
|
@@ -3633,19 +3654,21 @@ function annotationToSource({
|
|
|
3633
3654
|
var _a, _b, _c, _d, _e;
|
|
3634
3655
|
switch (annotation.type) {
|
|
3635
3656
|
case "url_citation": {
|
|
3636
|
-
const
|
|
3637
|
-
if (
|
|
3657
|
+
const urlCitation = annotation;
|
|
3658
|
+
if (urlCitation.url == null || urlCitation.url.length === 0) {
|
|
3659
|
+
return void 0;
|
|
3660
|
+
}
|
|
3638
3661
|
return {
|
|
3639
3662
|
type: "source",
|
|
3640
3663
|
sourceType: "url",
|
|
3641
3664
|
id: generateId3(),
|
|
3642
|
-
url:
|
|
3643
|
-
...
|
|
3665
|
+
url: urlCitation.url,
|
|
3666
|
+
...urlCitation.title != null ? { title: urlCitation.title } : {}
|
|
3644
3667
|
};
|
|
3645
3668
|
}
|
|
3646
3669
|
case "file_citation": {
|
|
3647
|
-
const
|
|
3648
|
-
const uri = (_b = (_a =
|
|
3670
|
+
const fileCitation = annotation;
|
|
3671
|
+
const uri = (_b = (_a = fileCitation.url) != null ? _a : fileCitation.document_uri) != null ? _b : fileCitation.file_name;
|
|
3649
3672
|
if (uri == null || uri.length === 0) return void 0;
|
|
3650
3673
|
if (uri.startsWith("http://") || uri.startsWith("https://")) {
|
|
3651
3674
|
return {
|
|
@@ -3653,29 +3676,31 @@ function annotationToSource({
|
|
|
3653
3676
|
sourceType: "url",
|
|
3654
3677
|
id: generateId3(),
|
|
3655
3678
|
url: uri,
|
|
3656
|
-
...
|
|
3679
|
+
...fileCitation.file_name != null ? { title: fileCitation.file_name } : {}
|
|
3657
3680
|
};
|
|
3658
3681
|
}
|
|
3659
|
-
const filename = (_c =
|
|
3682
|
+
const filename = (_c = fileCitation.file_name) != null ? _c : basename(uri);
|
|
3660
3683
|
const mediaType = inferDocMediaType(uri);
|
|
3661
3684
|
return {
|
|
3662
3685
|
type: "source",
|
|
3663
3686
|
sourceType: "document",
|
|
3664
3687
|
id: generateId3(),
|
|
3665
3688
|
mediaType,
|
|
3666
|
-
title: (_e = (_d =
|
|
3689
|
+
title: (_e = (_d = fileCitation.file_name) != null ? _d : filename) != null ? _e : uri,
|
|
3667
3690
|
...filename != null ? { filename } : {}
|
|
3668
3691
|
};
|
|
3669
3692
|
}
|
|
3670
3693
|
case "place_citation": {
|
|
3671
|
-
const
|
|
3672
|
-
if (
|
|
3694
|
+
const placeCitation = annotation;
|
|
3695
|
+
if (placeCitation.url == null || placeCitation.url.length === 0) {
|
|
3696
|
+
return void 0;
|
|
3697
|
+
}
|
|
3673
3698
|
return {
|
|
3674
3699
|
type: "source",
|
|
3675
3700
|
sourceType: "url",
|
|
3676
3701
|
id: generateId3(),
|
|
3677
|
-
url:
|
|
3678
|
-
...
|
|
3702
|
+
url: placeCitation.url,
|
|
3703
|
+
...placeCitation.name != null ? { title: placeCitation.name } : {}
|
|
3679
3704
|
};
|
|
3680
3705
|
}
|
|
3681
3706
|
default:
|
|
@@ -4013,22 +4038,22 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
4013
4038
|
}
|
|
4014
4039
|
}
|
|
4015
4040
|
if (dtype === "image" && (open.kind === "pending_model_output" || open.kind === "text" || open.kind === "image")) {
|
|
4016
|
-
const
|
|
4041
|
+
const imageDelta = event.delta;
|
|
4017
4042
|
const google2 = {};
|
|
4018
4043
|
if (interactionId != null) google2.interactionId = interactionId;
|
|
4019
4044
|
const providerMetadata = Object.keys(google2).length > 0 ? { google: google2 } : void 0;
|
|
4020
|
-
if ((
|
|
4045
|
+
if ((imageDelta == null ? void 0 : imageDelta.data) != null && imageDelta.data.length > 0) {
|
|
4021
4046
|
controller.enqueue({
|
|
4022
4047
|
type: "file",
|
|
4023
|
-
mediaType: (_k =
|
|
4024
|
-
data: { type: "data", data:
|
|
4048
|
+
mediaType: (_k = imageDelta.mime_type) != null ? _k : "image/png",
|
|
4049
|
+
data: { type: "data", data: imageDelta.data },
|
|
4025
4050
|
...providerMetadata ? { providerMetadata } : {}
|
|
4026
4051
|
});
|
|
4027
|
-
} else if ((
|
|
4052
|
+
} else if ((imageDelta == null ? void 0 : imageDelta.uri) != null && imageDelta.uri.length > 0) {
|
|
4028
4053
|
controller.enqueue({
|
|
4029
4054
|
type: "file",
|
|
4030
|
-
mediaType: (_l =
|
|
4031
|
-
data: { type: "url", url: new URL(
|
|
4055
|
+
mediaType: (_l = imageDelta.mime_type) != null ? _l : "image/png",
|
|
4056
|
+
data: { type: "url", url: new URL(imageDelta.uri) },
|
|
4032
4057
|
...providerMetadata ? { providerMetadata } : {}
|
|
4033
4058
|
});
|
|
4034
4059
|
}
|
|
@@ -5699,11 +5724,11 @@ function streamGoogleInteractionEvents({
|
|
|
5699
5724
|
}
|
|
5700
5725
|
receivedAnyEventThisAttempt = true;
|
|
5701
5726
|
if (value.success) {
|
|
5702
|
-
const
|
|
5703
|
-
if (typeof
|
|
5704
|
-
lastEventId =
|
|
5727
|
+
const streamEvent = value.value;
|
|
5728
|
+
if (typeof streamEvent.event_id === "string" && streamEvent.event_id.length > 0) {
|
|
5729
|
+
lastEventId = streamEvent.event_id;
|
|
5705
5730
|
}
|
|
5706
|
-
if (
|
|
5731
|
+
if (streamEvent.event_type === "interaction.completed" || streamEvent.event_type === "error") {
|
|
5707
5732
|
complete = true;
|
|
5708
5733
|
}
|
|
5709
5734
|
}
|
|
@@ -5946,7 +5971,7 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
5946
5971
|
async getArgs(options) {
|
|
5947
5972
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
|
5948
5973
|
const warnings = [];
|
|
5949
|
-
const
|
|
5974
|
+
const googleOptions = await parseProviderOptions6({
|
|
5950
5975
|
provider: "google",
|
|
5951
5976
|
providerOptions: options.providerOptions,
|
|
5952
5977
|
schema: googleInteractionsLanguageModelOptions
|
|
@@ -5985,8 +6010,8 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
5985
6010
|
responseFormatEntries.push(entry);
|
|
5986
6011
|
}
|
|
5987
6012
|
}
|
|
5988
|
-
if ((
|
|
5989
|
-
for (const entry of
|
|
6013
|
+
if ((googleOptions == null ? void 0 : googleOptions.responseFormat) != null) {
|
|
6014
|
+
for (const entry of googleOptions.responseFormat) {
|
|
5990
6015
|
if (entry.type === "text") {
|
|
5991
6016
|
responseFormatEntries.push(
|
|
5992
6017
|
pruneUndefined({
|
|
@@ -6020,13 +6045,13 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
6020
6045
|
warnings: convWarnings
|
|
6021
6046
|
} = convertToGoogleInteractionsInput({
|
|
6022
6047
|
prompt: options.prompt,
|
|
6023
|
-
previousInteractionId: (_h =
|
|
6024
|
-
store: (_i =
|
|
6025
|
-
mediaResolution: (_j =
|
|
6048
|
+
previousInteractionId: (_h = googleOptions == null ? void 0 : googleOptions.previousInteractionId) != null ? _h : void 0,
|
|
6049
|
+
store: (_i = googleOptions == null ? void 0 : googleOptions.store) != null ? _i : void 0,
|
|
6050
|
+
mediaResolution: (_j = googleOptions == null ? void 0 : googleOptions.mediaResolution) != null ? _j : void 0
|
|
6026
6051
|
});
|
|
6027
6052
|
warnings.push(...convWarnings);
|
|
6028
6053
|
let systemInstruction = convertedSystemInstruction;
|
|
6029
|
-
const optionSystemInstruction = (_k =
|
|
6054
|
+
const optionSystemInstruction = (_k = googleOptions == null ? void 0 : googleOptions.systemInstruction) != null ? _k : void 0;
|
|
6030
6055
|
if (systemInstruction != null && optionSystemInstruction != null) {
|
|
6031
6056
|
warnings.push({
|
|
6032
6057
|
type: "other",
|
|
@@ -6046,11 +6071,12 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
6046
6071
|
}
|
|
6047
6072
|
if (options.maxOutputTokens != null)
|
|
6048
6073
|
droppedFields.push("maxOutputTokens");
|
|
6049
|
-
if ((
|
|
6050
|
-
|
|
6074
|
+
if ((googleOptions == null ? void 0 : googleOptions.thinkingLevel) != null)
|
|
6075
|
+
droppedFields.push("thinkingLevel");
|
|
6076
|
+
if ((googleOptions == null ? void 0 : googleOptions.thinkingSummaries) != null) {
|
|
6051
6077
|
droppedFields.push("thinkingSummaries");
|
|
6052
6078
|
}
|
|
6053
|
-
if ((
|
|
6079
|
+
if ((googleOptions == null ? void 0 : googleOptions.imageConfig) != null) droppedFields.push("imageConfig");
|
|
6054
6080
|
if (droppedFields.length > 0) {
|
|
6055
6081
|
warnings.push({
|
|
6056
6082
|
type: "other",
|
|
@@ -6065,11 +6091,11 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
6065
6091
|
seed: (_n = options.seed) != null ? _n : void 0,
|
|
6066
6092
|
stop_sequences: options.stopSequences != null && options.stopSequences.length > 0 ? options.stopSequences : void 0,
|
|
6067
6093
|
max_output_tokens: (_o = options.maxOutputTokens) != null ? _o : void 0,
|
|
6068
|
-
thinking_level: (_p =
|
|
6069
|
-
thinking_summaries: (_q =
|
|
6094
|
+
thinking_level: (_p = googleOptions == null ? void 0 : googleOptions.thinkingLevel) != null ? _p : void 0,
|
|
6095
|
+
thinking_summaries: (_q = googleOptions == null ? void 0 : googleOptions.thinkingSummaries) != null ? _q : void 0,
|
|
6070
6096
|
tool_choice: toolChoiceForBody
|
|
6071
6097
|
});
|
|
6072
|
-
if ((
|
|
6098
|
+
if ((googleOptions == null ? void 0 : googleOptions.imageConfig) != null) {
|
|
6073
6099
|
const alreadyHasImageEntry = responseFormatEntries.some(
|
|
6074
6100
|
(entry) => entry.type === "image"
|
|
6075
6101
|
);
|
|
@@ -6081,58 +6107,58 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
6081
6107
|
responseFormatEntries.push({
|
|
6082
6108
|
type: "image",
|
|
6083
6109
|
mime_type: "image/png",
|
|
6084
|
-
...
|
|
6085
|
-
...
|
|
6110
|
+
...googleOptions.imageConfig.aspectRatio != null ? { aspect_ratio: googleOptions.imageConfig.aspectRatio } : {},
|
|
6111
|
+
...googleOptions.imageConfig.imageSize != null ? { image_size: googleOptions.imageConfig.imageSize } : {}
|
|
6086
6112
|
});
|
|
6087
6113
|
}
|
|
6088
6114
|
}
|
|
6089
6115
|
}
|
|
6090
6116
|
let agentConfig;
|
|
6091
|
-
if (isAgent && (
|
|
6092
|
-
const
|
|
6093
|
-
if (
|
|
6117
|
+
if (isAgent && (googleOptions == null ? void 0 : googleOptions.agentConfig) != null) {
|
|
6118
|
+
const agentConfigOptions = googleOptions.agentConfig;
|
|
6119
|
+
if (agentConfigOptions.type === "deep-research") {
|
|
6094
6120
|
agentConfig = pruneUndefined({
|
|
6095
6121
|
type: "deep-research",
|
|
6096
|
-
thinking_summaries: (_r =
|
|
6097
|
-
visualization: (_s =
|
|
6098
|
-
collaborative_planning: (_t =
|
|
6122
|
+
thinking_summaries: (_r = agentConfigOptions.thinkingSummaries) != null ? _r : void 0,
|
|
6123
|
+
visualization: (_s = agentConfigOptions.visualization) != null ? _s : void 0,
|
|
6124
|
+
collaborative_planning: (_t = agentConfigOptions.collaborativePlanning) != null ? _t : void 0
|
|
6099
6125
|
});
|
|
6100
|
-
} else if (
|
|
6126
|
+
} else if (agentConfigOptions.type === "dynamic") {
|
|
6101
6127
|
agentConfig = { type: "dynamic" };
|
|
6102
6128
|
}
|
|
6103
6129
|
}
|
|
6104
6130
|
let environment;
|
|
6105
|
-
if ((
|
|
6131
|
+
if ((googleOptions == null ? void 0 : googleOptions.environment) != null) {
|
|
6106
6132
|
if (!isAgent) {
|
|
6107
6133
|
warnings.push({
|
|
6108
6134
|
type: "other",
|
|
6109
6135
|
message: "google.interactions: environment is only supported when an agent is set; environment will be omitted from the request body."
|
|
6110
6136
|
});
|
|
6111
|
-
} else if (typeof
|
|
6112
|
-
environment =
|
|
6137
|
+
} else if (typeof googleOptions.environment === "string") {
|
|
6138
|
+
environment = googleOptions.environment;
|
|
6113
6139
|
} else {
|
|
6114
|
-
const
|
|
6115
|
-
const sources = (_u =
|
|
6140
|
+
const environmentOptions = googleOptions.environment;
|
|
6141
|
+
const sources = (_u = environmentOptions.sources) == null ? void 0 : _u.map((source) => {
|
|
6116
6142
|
var _a2;
|
|
6117
|
-
if (
|
|
6143
|
+
if (source.type === "inline") {
|
|
6118
6144
|
return {
|
|
6119
6145
|
type: "inline",
|
|
6120
|
-
content:
|
|
6121
|
-
target:
|
|
6146
|
+
content: source.content,
|
|
6147
|
+
target: source.target
|
|
6122
6148
|
};
|
|
6123
6149
|
}
|
|
6124
6150
|
return pruneUndefined({
|
|
6125
|
-
type:
|
|
6126
|
-
source:
|
|
6127
|
-
target: (_a2 =
|
|
6151
|
+
type: source.type,
|
|
6152
|
+
source: source.source,
|
|
6153
|
+
target: (_a2 = source.target) != null ? _a2 : void 0
|
|
6128
6154
|
});
|
|
6129
6155
|
});
|
|
6130
6156
|
let network;
|
|
6131
|
-
if (
|
|
6157
|
+
if (environmentOptions.network === "disabled") {
|
|
6132
6158
|
network = "disabled";
|
|
6133
|
-
} else if (
|
|
6159
|
+
} else if (environmentOptions.network != null) {
|
|
6134
6160
|
network = {
|
|
6135
|
-
allowlist:
|
|
6161
|
+
allowlist: environmentOptions.network.allowlist.map(
|
|
6136
6162
|
(entry) => {
|
|
6137
6163
|
var _a2;
|
|
6138
6164
|
return pruneUndefined({
|
|
@@ -6156,21 +6182,21 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
6156
6182
|
system_instruction: systemInstruction,
|
|
6157
6183
|
tools: toolsForBody,
|
|
6158
6184
|
response_format: responseFormatEntries.length > 0 ? responseFormatEntries : void 0,
|
|
6159
|
-
response_modalities: (
|
|
6160
|
-
previous_interaction_id: (_v =
|
|
6161
|
-
service_tier: (_w =
|
|
6162
|
-
store: (_x =
|
|
6185
|
+
response_modalities: (googleOptions == null ? void 0 : googleOptions.responseModalities) != null ? googleOptions.responseModalities : void 0,
|
|
6186
|
+
previous_interaction_id: (_v = googleOptions == null ? void 0 : googleOptions.previousInteractionId) != null ? _v : void 0,
|
|
6187
|
+
service_tier: (_w = googleOptions == null ? void 0 : googleOptions.serviceTier) != null ? _w : void 0,
|
|
6188
|
+
store: (_x = googleOptions == null ? void 0 : googleOptions.store) != null ? _x : void 0,
|
|
6163
6189
|
generation_config: generationConfig != null && Object.keys(generationConfig).length > 0 ? generationConfig : void 0,
|
|
6164
6190
|
agent_config: agentConfig,
|
|
6165
6191
|
environment,
|
|
6166
|
-
background: (_y =
|
|
6192
|
+
background: (_y = googleOptions == null ? void 0 : googleOptions.background) != null ? _y : void 0
|
|
6167
6193
|
});
|
|
6168
6194
|
return {
|
|
6169
6195
|
args,
|
|
6170
6196
|
warnings,
|
|
6171
6197
|
isAgent,
|
|
6172
|
-
isBackground: (
|
|
6173
|
-
pollingTimeoutMs: (_z =
|
|
6198
|
+
isBackground: (googleOptions == null ? void 0 : googleOptions.background) === true,
|
|
6199
|
+
pollingTimeoutMs: (_z = googleOptions == null ? void 0 : googleOptions.pollingTimeoutMs) != null ? _z : void 0
|
|
6174
6200
|
};
|
|
6175
6201
|
}
|
|
6176
6202
|
async doGenerate(options) {
|