@ai-sdk/google 2.0.1 → 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 +13 -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 +2 -2
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
# @ai-sdk/google
|
2
2
|
|
3
|
+
## 2.0.3
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 9fb0252: fix(google): add thought signature support for reasoning
|
8
|
+
|
9
|
+
## 2.0.2
|
10
|
+
|
11
|
+
### Patch Changes
|
12
|
+
|
13
|
+
- Updated dependencies [90d212f]
|
14
|
+
- @ai-sdk/provider-utils@3.0.1
|
15
|
+
|
3
16
|
## 2.0.1
|
4
17
|
|
5
18
|
### Patch Changes
|
package/dist/index.js
CHANGED
@@ -337,9 +337,20 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
337
337
|
contents.push({
|
338
338
|
role: "model",
|
339
339
|
parts: content.map((part) => {
|
340
|
+
var _a2, _b, _c, _d, _e, _f;
|
340
341
|
switch (part.type) {
|
341
342
|
case "text": {
|
342
|
-
return part.text.length === 0 ? void 0 : {
|
343
|
+
return part.text.length === 0 ? void 0 : {
|
344
|
+
text: part.text,
|
345
|
+
thoughtSignature: (_b = (_a2 = part.providerOptions) == null ? void 0 : _a2.google) == null ? void 0 : _b.thoughtSignature
|
346
|
+
};
|
347
|
+
}
|
348
|
+
case "reasoning": {
|
349
|
+
return part.text.length === 0 ? void 0 : {
|
350
|
+
text: part.text,
|
351
|
+
thought: true,
|
352
|
+
thoughtSignature: (_d = (_c = part.providerOptions) == null ? void 0 : _c.google) == null ? void 0 : _d.thoughtSignature
|
353
|
+
};
|
343
354
|
}
|
344
355
|
case "file": {
|
345
356
|
if (part.mediaType !== "image/png") {
|
@@ -364,7 +375,8 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
364
375
|
functionCall: {
|
365
376
|
name: part.toolName,
|
366
377
|
args: part.input
|
367
|
-
}
|
378
|
+
},
|
379
|
+
thoughtSignature: (_f = (_e = part.providerOptions) == null ? void 0 : _e.google) == null ? void 0 : _f.thoughtSignature
|
368
380
|
};
|
369
381
|
}
|
370
382
|
}
|
@@ -840,17 +852,18 @@ var GoogleGenerativeAILanguageModel = class {
|
|
840
852
|
});
|
841
853
|
lastCodeExecutionToolCallId = void 0;
|
842
854
|
} else if ("text" in part && part.text != null && part.text.length > 0) {
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
}
|
855
|
+
content.push({
|
856
|
+
type: part.thought === true ? "reasoning" : "text",
|
857
|
+
text: part.text,
|
858
|
+
providerMetadata: part.thoughtSignature ? { google: { thoughtSignature: part.thoughtSignature } } : void 0
|
859
|
+
});
|
848
860
|
} else if ("functionCall" in part) {
|
849
861
|
content.push({
|
850
862
|
type: "tool-call",
|
851
863
|
toolCallId: this.config.generateId(),
|
852
864
|
toolName: part.functionCall.name,
|
853
|
-
input: JSON.stringify(part.functionCall.args)
|
865
|
+
input: JSON.stringify(part.functionCall.args),
|
866
|
+
providerMetadata: part.thoughtSignature ? { google: { thoughtSignature: part.thoughtSignature } } : void 0
|
854
867
|
});
|
855
868
|
} else if ("inlineData" in part) {
|
856
869
|
content.push({
|
@@ -1012,13 +1025,21 @@ var GoogleGenerativeAILanguageModel = class {
|
|
1012
1025
|
currentReasoningBlockId = String(blockCounter++);
|
1013
1026
|
controller.enqueue({
|
1014
1027
|
type: "reasoning-start",
|
1015
|
-
id: currentReasoningBlockId
|
1028
|
+
id: currentReasoningBlockId,
|
1029
|
+
providerMetadata: part.thoughtSignature ? {
|
1030
|
+
google: {
|
1031
|
+
thoughtSignature: part.thoughtSignature
|
1032
|
+
}
|
1033
|
+
} : void 0
|
1016
1034
|
});
|
1017
1035
|
}
|
1018
1036
|
controller.enqueue({
|
1019
1037
|
type: "reasoning-delta",
|
1020
1038
|
id: currentReasoningBlockId,
|
1021
|
-
delta: part.text
|
1039
|
+
delta: part.text,
|
1040
|
+
providerMetadata: part.thoughtSignature ? {
|
1041
|
+
google: { thoughtSignature: part.thoughtSignature }
|
1042
|
+
} : void 0
|
1022
1043
|
});
|
1023
1044
|
} else {
|
1024
1045
|
if (currentReasoningBlockId !== null) {
|
@@ -1032,13 +1053,21 @@ var GoogleGenerativeAILanguageModel = class {
|
|
1032
1053
|
currentTextBlockId = String(blockCounter++);
|
1033
1054
|
controller.enqueue({
|
1034
1055
|
type: "text-start",
|
1035
|
-
id: currentTextBlockId
|
1056
|
+
id: currentTextBlockId,
|
1057
|
+
providerMetadata: part.thoughtSignature ? {
|
1058
|
+
google: {
|
1059
|
+
thoughtSignature: part.thoughtSignature
|
1060
|
+
}
|
1061
|
+
} : void 0
|
1036
1062
|
});
|
1037
1063
|
}
|
1038
1064
|
controller.enqueue({
|
1039
1065
|
type: "text-delta",
|
1040
1066
|
id: currentTextBlockId,
|
1041
|
-
delta: part.text
|
1067
|
+
delta: part.text,
|
1068
|
+
providerMetadata: part.thoughtSignature ? {
|
1069
|
+
google: { thoughtSignature: part.thoughtSignature }
|
1070
|
+
} : void 0
|
1042
1071
|
});
|
1043
1072
|
}
|
1044
1073
|
}
|
@@ -1062,22 +1091,26 @@ var GoogleGenerativeAILanguageModel = class {
|
|
1062
1091
|
controller.enqueue({
|
1063
1092
|
type: "tool-input-start",
|
1064
1093
|
id: toolCall.toolCallId,
|
1065
|
-
toolName: toolCall.toolName
|
1094
|
+
toolName: toolCall.toolName,
|
1095
|
+
providerMetadata: toolCall.providerMetadata
|
1066
1096
|
});
|
1067
1097
|
controller.enqueue({
|
1068
1098
|
type: "tool-input-delta",
|
1069
1099
|
id: toolCall.toolCallId,
|
1070
|
-
delta: toolCall.args
|
1100
|
+
delta: toolCall.args,
|
1101
|
+
providerMetadata: toolCall.providerMetadata
|
1071
1102
|
});
|
1072
1103
|
controller.enqueue({
|
1073
1104
|
type: "tool-input-end",
|
1074
|
-
id: toolCall.toolCallId
|
1105
|
+
id: toolCall.toolCallId,
|
1106
|
+
providerMetadata: toolCall.providerMetadata
|
1075
1107
|
});
|
1076
1108
|
controller.enqueue({
|
1077
1109
|
type: "tool-call",
|
1078
1110
|
toolCallId: toolCall.toolCallId,
|
1079
1111
|
toolName: toolCall.toolName,
|
1080
|
-
input: toolCall.args
|
1112
|
+
input: toolCall.args,
|
1113
|
+
providerMetadata: toolCall.providerMetadata
|
1081
1114
|
});
|
1082
1115
|
hasToolCalls = true;
|
1083
1116
|
}
|
@@ -1138,7 +1171,8 @@ function getToolCallsFromParts({
|
|
1138
1171
|
type: "tool-call",
|
1139
1172
|
toolCallId: generateId3(),
|
1140
1173
|
toolName: part.functionCall.name,
|
1141
|
-
args: JSON.stringify(part.functionCall.args)
|
1174
|
+
args: JSON.stringify(part.functionCall.args),
|
1175
|
+
providerMetadata: part.thoughtSignature ? { google: { thoughtSignature: part.thoughtSignature } } : void 0
|
1142
1176
|
}));
|
1143
1177
|
}
|
1144
1178
|
function getInlineDataParts(parts) {
|
@@ -1169,7 +1203,8 @@ var contentSchema = import_v47.z.object({
|
|
1169
1203
|
functionCall: import_v47.z.object({
|
1170
1204
|
name: import_v47.z.string(),
|
1171
1205
|
args: import_v47.z.unknown()
|
1172
|
-
})
|
1206
|
+
}),
|
1207
|
+
thoughtSignature: import_v47.z.string().nullish()
|
1173
1208
|
}),
|
1174
1209
|
import_v47.z.object({
|
1175
1210
|
inlineData: import_v47.z.object({
|
@@ -1187,7 +1222,8 @@ var contentSchema = import_v47.z.object({
|
|
1187
1222
|
output: import_v47.z.string()
|
1188
1223
|
}).nullish(),
|
1189
1224
|
text: import_v47.z.string().nullish(),
|
1190
|
-
thought: import_v47.z.boolean().nullish()
|
1225
|
+
thought: import_v47.z.boolean().nullish(),
|
1226
|
+
thoughtSignature: import_v47.z.string().nullish()
|
1191
1227
|
})
|
1192
1228
|
])
|
1193
1229
|
).nullish()
|