@ai-sdk/google 2.0.2 → 2.0.4
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.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +64 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +64 -21
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +64 -21
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +64 -21
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# @ai-sdk/google
|
2
2
|
|
3
|
+
## 2.0.4
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 961dda1: add labels field to providerOptions
|
8
|
+
|
9
|
+
## 2.0.3
|
10
|
+
|
11
|
+
### Patch Changes
|
12
|
+
|
13
|
+
- 9fb0252: fix(google): add thought signature support for reasoning
|
14
|
+
|
3
15
|
## 2.0.2
|
4
16
|
|
5
17
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
@@ -51,6 +51,7 @@ declare const googleGenerativeAIProviderOptions: z.ZodObject<{
|
|
51
51
|
OFF: "OFF";
|
52
52
|
}>>;
|
53
53
|
audioTimestamp: z.ZodOptional<z.ZodBoolean>;
|
54
|
+
labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
54
55
|
}, z.core.$strip>;
|
55
56
|
type GoogleGenerativeAIProviderOptions = z.infer<typeof googleGenerativeAIProviderOptions>;
|
56
57
|
|
package/dist/index.d.ts
CHANGED
@@ -51,6 +51,7 @@ declare const googleGenerativeAIProviderOptions: z.ZodObject<{
|
|
51
51
|
OFF: "OFF";
|
52
52
|
}>>;
|
53
53
|
audioTimestamp: z.ZodOptional<z.ZodBoolean>;
|
54
|
+
labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
54
55
|
}, z.core.$strip>;
|
55
56
|
type GoogleGenerativeAIProviderOptions = z.infer<typeof googleGenerativeAIProviderOptions>;
|
56
57
|
|
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
|
}
|
@@ -464,7 +476,13 @@ var googleGenerativeAIProviderOptions = import_v44.z.object({
|
|
464
476
|
*
|
465
477
|
* https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/audio-understanding
|
466
478
|
*/
|
467
|
-
audioTimestamp: import_v44.z.boolean().optional()
|
479
|
+
audioTimestamp: import_v44.z.boolean().optional(),
|
480
|
+
/**
|
481
|
+
* Optional. Defines labels used in billing reports. Available on Vertex AI only.
|
482
|
+
*
|
483
|
+
* https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/add-labels-to-api-calls
|
484
|
+
*/
|
485
|
+
labels: import_v44.z.record(import_v44.z.string(), import_v44.z.string()).optional()
|
468
486
|
});
|
469
487
|
|
470
488
|
// src/google-prepare-tools.ts
|
@@ -782,7 +800,8 @@ var GoogleGenerativeAILanguageModel = class {
|
|
782
800
|
safetySettings: googleOptions == null ? void 0 : googleOptions.safetySettings,
|
783
801
|
tools: googleTools2,
|
784
802
|
toolConfig: googleToolConfig,
|
785
|
-
cachedContent: googleOptions == null ? void 0 : googleOptions.cachedContent
|
803
|
+
cachedContent: googleOptions == null ? void 0 : googleOptions.cachedContent,
|
804
|
+
labels: googleOptions == null ? void 0 : googleOptions.labels
|
786
805
|
},
|
787
806
|
warnings: [...warnings, ...toolWarnings]
|
788
807
|
};
|
@@ -840,17 +859,18 @@ var GoogleGenerativeAILanguageModel = class {
|
|
840
859
|
});
|
841
860
|
lastCodeExecutionToolCallId = void 0;
|
842
861
|
} else if ("text" in part && part.text != null && part.text.length > 0) {
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
}
|
862
|
+
content.push({
|
863
|
+
type: part.thought === true ? "reasoning" : "text",
|
864
|
+
text: part.text,
|
865
|
+
providerMetadata: part.thoughtSignature ? { google: { thoughtSignature: part.thoughtSignature } } : void 0
|
866
|
+
});
|
848
867
|
} else if ("functionCall" in part) {
|
849
868
|
content.push({
|
850
869
|
type: "tool-call",
|
851
870
|
toolCallId: this.config.generateId(),
|
852
871
|
toolName: part.functionCall.name,
|
853
|
-
input: JSON.stringify(part.functionCall.args)
|
872
|
+
input: JSON.stringify(part.functionCall.args),
|
873
|
+
providerMetadata: part.thoughtSignature ? { google: { thoughtSignature: part.thoughtSignature } } : void 0
|
854
874
|
});
|
855
875
|
} else if ("inlineData" in part) {
|
856
876
|
content.push({
|
@@ -1012,13 +1032,21 @@ var GoogleGenerativeAILanguageModel = class {
|
|
1012
1032
|
currentReasoningBlockId = String(blockCounter++);
|
1013
1033
|
controller.enqueue({
|
1014
1034
|
type: "reasoning-start",
|
1015
|
-
id: currentReasoningBlockId
|
1035
|
+
id: currentReasoningBlockId,
|
1036
|
+
providerMetadata: part.thoughtSignature ? {
|
1037
|
+
google: {
|
1038
|
+
thoughtSignature: part.thoughtSignature
|
1039
|
+
}
|
1040
|
+
} : void 0
|
1016
1041
|
});
|
1017
1042
|
}
|
1018
1043
|
controller.enqueue({
|
1019
1044
|
type: "reasoning-delta",
|
1020
1045
|
id: currentReasoningBlockId,
|
1021
|
-
delta: part.text
|
1046
|
+
delta: part.text,
|
1047
|
+
providerMetadata: part.thoughtSignature ? {
|
1048
|
+
google: { thoughtSignature: part.thoughtSignature }
|
1049
|
+
} : void 0
|
1022
1050
|
});
|
1023
1051
|
} else {
|
1024
1052
|
if (currentReasoningBlockId !== null) {
|
@@ -1032,13 +1060,21 @@ var GoogleGenerativeAILanguageModel = class {
|
|
1032
1060
|
currentTextBlockId = String(blockCounter++);
|
1033
1061
|
controller.enqueue({
|
1034
1062
|
type: "text-start",
|
1035
|
-
id: currentTextBlockId
|
1063
|
+
id: currentTextBlockId,
|
1064
|
+
providerMetadata: part.thoughtSignature ? {
|
1065
|
+
google: {
|
1066
|
+
thoughtSignature: part.thoughtSignature
|
1067
|
+
}
|
1068
|
+
} : void 0
|
1036
1069
|
});
|
1037
1070
|
}
|
1038
1071
|
controller.enqueue({
|
1039
1072
|
type: "text-delta",
|
1040
1073
|
id: currentTextBlockId,
|
1041
|
-
delta: part.text
|
1074
|
+
delta: part.text,
|
1075
|
+
providerMetadata: part.thoughtSignature ? {
|
1076
|
+
google: { thoughtSignature: part.thoughtSignature }
|
1077
|
+
} : void 0
|
1042
1078
|
});
|
1043
1079
|
}
|
1044
1080
|
}
|
@@ -1062,22 +1098,26 @@ var GoogleGenerativeAILanguageModel = class {
|
|
1062
1098
|
controller.enqueue({
|
1063
1099
|
type: "tool-input-start",
|
1064
1100
|
id: toolCall.toolCallId,
|
1065
|
-
toolName: toolCall.toolName
|
1101
|
+
toolName: toolCall.toolName,
|
1102
|
+
providerMetadata: toolCall.providerMetadata
|
1066
1103
|
});
|
1067
1104
|
controller.enqueue({
|
1068
1105
|
type: "tool-input-delta",
|
1069
1106
|
id: toolCall.toolCallId,
|
1070
|
-
delta: toolCall.args
|
1107
|
+
delta: toolCall.args,
|
1108
|
+
providerMetadata: toolCall.providerMetadata
|
1071
1109
|
});
|
1072
1110
|
controller.enqueue({
|
1073
1111
|
type: "tool-input-end",
|
1074
|
-
id: toolCall.toolCallId
|
1112
|
+
id: toolCall.toolCallId,
|
1113
|
+
providerMetadata: toolCall.providerMetadata
|
1075
1114
|
});
|
1076
1115
|
controller.enqueue({
|
1077
1116
|
type: "tool-call",
|
1078
1117
|
toolCallId: toolCall.toolCallId,
|
1079
1118
|
toolName: toolCall.toolName,
|
1080
|
-
input: toolCall.args
|
1119
|
+
input: toolCall.args,
|
1120
|
+
providerMetadata: toolCall.providerMetadata
|
1081
1121
|
});
|
1082
1122
|
hasToolCalls = true;
|
1083
1123
|
}
|
@@ -1138,7 +1178,8 @@ function getToolCallsFromParts({
|
|
1138
1178
|
type: "tool-call",
|
1139
1179
|
toolCallId: generateId3(),
|
1140
1180
|
toolName: part.functionCall.name,
|
1141
|
-
args: JSON.stringify(part.functionCall.args)
|
1181
|
+
args: JSON.stringify(part.functionCall.args),
|
1182
|
+
providerMetadata: part.thoughtSignature ? { google: { thoughtSignature: part.thoughtSignature } } : void 0
|
1142
1183
|
}));
|
1143
1184
|
}
|
1144
1185
|
function getInlineDataParts(parts) {
|
@@ -1169,7 +1210,8 @@ var contentSchema = import_v47.z.object({
|
|
1169
1210
|
functionCall: import_v47.z.object({
|
1170
1211
|
name: import_v47.z.string(),
|
1171
1212
|
args: import_v47.z.unknown()
|
1172
|
-
})
|
1213
|
+
}),
|
1214
|
+
thoughtSignature: import_v47.z.string().nullish()
|
1173
1215
|
}),
|
1174
1216
|
import_v47.z.object({
|
1175
1217
|
inlineData: import_v47.z.object({
|
@@ -1187,7 +1229,8 @@ var contentSchema = import_v47.z.object({
|
|
1187
1229
|
output: import_v47.z.string()
|
1188
1230
|
}).nullish(),
|
1189
1231
|
text: import_v47.z.string().nullish(),
|
1190
|
-
thought: import_v47.z.boolean().nullish()
|
1232
|
+
thought: import_v47.z.boolean().nullish(),
|
1233
|
+
thoughtSignature: import_v47.z.string().nullish()
|
1191
1234
|
})
|
1192
1235
|
])
|
1193
1236
|
).nullish()
|