@ai-sdk/google 2.0.2 → 2.0.3
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 +6 -0
- package/dist/index.js +55 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +55 -19
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +55 -19
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +55 -19
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
@@ -332,9 +332,20 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
332
332
|
contents.push({
|
333
333
|
role: "model",
|
334
334
|
parts: content.map((part) => {
|
335
|
+
var _a2, _b, _c, _d, _e, _f;
|
335
336
|
switch (part.type) {
|
336
337
|
case "text": {
|
337
|
-
return part.text.length === 0 ? void 0 : {
|
338
|
+
return part.text.length === 0 ? void 0 : {
|
339
|
+
text: part.text,
|
340
|
+
thoughtSignature: (_b = (_a2 = part.providerOptions) == null ? void 0 : _a2.google) == null ? void 0 : _b.thoughtSignature
|
341
|
+
};
|
342
|
+
}
|
343
|
+
case "reasoning": {
|
344
|
+
return part.text.length === 0 ? void 0 : {
|
345
|
+
text: part.text,
|
346
|
+
thought: true,
|
347
|
+
thoughtSignature: (_d = (_c = part.providerOptions) == null ? void 0 : _c.google) == null ? void 0 : _d.thoughtSignature
|
348
|
+
};
|
338
349
|
}
|
339
350
|
case "file": {
|
340
351
|
if (part.mediaType !== "image/png") {
|
@@ -359,7 +370,8 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
359
370
|
functionCall: {
|
360
371
|
name: part.toolName,
|
361
372
|
args: part.input
|
362
|
-
}
|
373
|
+
},
|
374
|
+
thoughtSignature: (_f = (_e = part.providerOptions) == null ? void 0 : _e.google) == null ? void 0 : _f.thoughtSignature
|
363
375
|
};
|
364
376
|
}
|
365
377
|
}
|
@@ -837,17 +849,18 @@ var GoogleGenerativeAILanguageModel = class {
|
|
837
849
|
});
|
838
850
|
lastCodeExecutionToolCallId = void 0;
|
839
851
|
} else if ("text" in part && part.text != null && part.text.length > 0) {
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
}
|
852
|
+
content.push({
|
853
|
+
type: part.thought === true ? "reasoning" : "text",
|
854
|
+
text: part.text,
|
855
|
+
providerMetadata: part.thoughtSignature ? { google: { thoughtSignature: part.thoughtSignature } } : void 0
|
856
|
+
});
|
845
857
|
} else if ("functionCall" in part) {
|
846
858
|
content.push({
|
847
859
|
type: "tool-call",
|
848
860
|
toolCallId: this.config.generateId(),
|
849
861
|
toolName: part.functionCall.name,
|
850
|
-
input: JSON.stringify(part.functionCall.args)
|
862
|
+
input: JSON.stringify(part.functionCall.args),
|
863
|
+
providerMetadata: part.thoughtSignature ? { google: { thoughtSignature: part.thoughtSignature } } : void 0
|
851
864
|
});
|
852
865
|
} else if ("inlineData" in part) {
|
853
866
|
content.push({
|
@@ -1009,13 +1022,21 @@ var GoogleGenerativeAILanguageModel = class {
|
|
1009
1022
|
currentReasoningBlockId = String(blockCounter++);
|
1010
1023
|
controller.enqueue({
|
1011
1024
|
type: "reasoning-start",
|
1012
|
-
id: currentReasoningBlockId
|
1025
|
+
id: currentReasoningBlockId,
|
1026
|
+
providerMetadata: part.thoughtSignature ? {
|
1027
|
+
google: {
|
1028
|
+
thoughtSignature: part.thoughtSignature
|
1029
|
+
}
|
1030
|
+
} : void 0
|
1013
1031
|
});
|
1014
1032
|
}
|
1015
1033
|
controller.enqueue({
|
1016
1034
|
type: "reasoning-delta",
|
1017
1035
|
id: currentReasoningBlockId,
|
1018
|
-
delta: part.text
|
1036
|
+
delta: part.text,
|
1037
|
+
providerMetadata: part.thoughtSignature ? {
|
1038
|
+
google: { thoughtSignature: part.thoughtSignature }
|
1039
|
+
} : void 0
|
1019
1040
|
});
|
1020
1041
|
} else {
|
1021
1042
|
if (currentReasoningBlockId !== null) {
|
@@ -1029,13 +1050,21 @@ var GoogleGenerativeAILanguageModel = class {
|
|
1029
1050
|
currentTextBlockId = String(blockCounter++);
|
1030
1051
|
controller.enqueue({
|
1031
1052
|
type: "text-start",
|
1032
|
-
id: currentTextBlockId
|
1053
|
+
id: currentTextBlockId,
|
1054
|
+
providerMetadata: part.thoughtSignature ? {
|
1055
|
+
google: {
|
1056
|
+
thoughtSignature: part.thoughtSignature
|
1057
|
+
}
|
1058
|
+
} : void 0
|
1033
1059
|
});
|
1034
1060
|
}
|
1035
1061
|
controller.enqueue({
|
1036
1062
|
type: "text-delta",
|
1037
1063
|
id: currentTextBlockId,
|
1038
|
-
delta: part.text
|
1064
|
+
delta: part.text,
|
1065
|
+
providerMetadata: part.thoughtSignature ? {
|
1066
|
+
google: { thoughtSignature: part.thoughtSignature }
|
1067
|
+
} : void 0
|
1039
1068
|
});
|
1040
1069
|
}
|
1041
1070
|
}
|
@@ -1059,22 +1088,26 @@ var GoogleGenerativeAILanguageModel = class {
|
|
1059
1088
|
controller.enqueue({
|
1060
1089
|
type: "tool-input-start",
|
1061
1090
|
id: toolCall.toolCallId,
|
1062
|
-
toolName: toolCall.toolName
|
1091
|
+
toolName: toolCall.toolName,
|
1092
|
+
providerMetadata: toolCall.providerMetadata
|
1063
1093
|
});
|
1064
1094
|
controller.enqueue({
|
1065
1095
|
type: "tool-input-delta",
|
1066
1096
|
id: toolCall.toolCallId,
|
1067
|
-
delta: toolCall.args
|
1097
|
+
delta: toolCall.args,
|
1098
|
+
providerMetadata: toolCall.providerMetadata
|
1068
1099
|
});
|
1069
1100
|
controller.enqueue({
|
1070
1101
|
type: "tool-input-end",
|
1071
|
-
id: toolCall.toolCallId
|
1102
|
+
id: toolCall.toolCallId,
|
1103
|
+
providerMetadata: toolCall.providerMetadata
|
1072
1104
|
});
|
1073
1105
|
controller.enqueue({
|
1074
1106
|
type: "tool-call",
|
1075
1107
|
toolCallId: toolCall.toolCallId,
|
1076
1108
|
toolName: toolCall.toolName,
|
1077
|
-
input: toolCall.args
|
1109
|
+
input: toolCall.args,
|
1110
|
+
providerMetadata: toolCall.providerMetadata
|
1078
1111
|
});
|
1079
1112
|
hasToolCalls = true;
|
1080
1113
|
}
|
@@ -1135,7 +1168,8 @@ function getToolCallsFromParts({
|
|
1135
1168
|
type: "tool-call",
|
1136
1169
|
toolCallId: generateId3(),
|
1137
1170
|
toolName: part.functionCall.name,
|
1138
|
-
args: JSON.stringify(part.functionCall.args)
|
1171
|
+
args: JSON.stringify(part.functionCall.args),
|
1172
|
+
providerMetadata: part.thoughtSignature ? { google: { thoughtSignature: part.thoughtSignature } } : void 0
|
1139
1173
|
}));
|
1140
1174
|
}
|
1141
1175
|
function getInlineDataParts(parts) {
|
@@ -1166,7 +1200,8 @@ var contentSchema = z7.object({
|
|
1166
1200
|
functionCall: z7.object({
|
1167
1201
|
name: z7.string(),
|
1168
1202
|
args: z7.unknown()
|
1169
|
-
})
|
1203
|
+
}),
|
1204
|
+
thoughtSignature: z7.string().nullish()
|
1170
1205
|
}),
|
1171
1206
|
z7.object({
|
1172
1207
|
inlineData: z7.object({
|
@@ -1184,7 +1219,8 @@ var contentSchema = z7.object({
|
|
1184
1219
|
output: z7.string()
|
1185
1220
|
}).nullish(),
|
1186
1221
|
text: z7.string().nullish(),
|
1187
|
-
thought: z7.boolean().nullish()
|
1222
|
+
thought: z7.boolean().nullish(),
|
1223
|
+
thoughtSignature: z7.string().nullish()
|
1188
1224
|
})
|
1189
1225
|
])
|
1190
1226
|
).nullish()
|