@ai-sdk/google 4.0.23 → 4.0.24
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 +16 -12
- package/dist/index.js.map +1 -1
- package/dist/internal/index.js +15 -11
- package/dist/internal/index.js.map +1 -1
- package/package.json +1 -1
- package/src/convert-to-google-messages.ts +16 -4
- package/src/google-language-model.ts +1 -0
package/dist/internal/index.js
CHANGED
|
@@ -209,7 +209,7 @@ function convertUrlToolResultPart(url) {
|
|
|
209
209
|
}
|
|
210
210
|
};
|
|
211
211
|
}
|
|
212
|
-
function appendToolResultParts(parts, toolName, outputValue, toolCallId) {
|
|
212
|
+
function appendToolResultParts(parts, toolName, outputValue, toolCallId, includeFunctionCallIds = true) {
|
|
213
213
|
const functionResponseParts = [];
|
|
214
214
|
const responseTextParts = [];
|
|
215
215
|
for (const contentPart of outputValue) {
|
|
@@ -248,7 +248,7 @@ function appendToolResultParts(parts, toolName, outputValue, toolCallId) {
|
|
|
248
248
|
}
|
|
249
249
|
parts.push({
|
|
250
250
|
functionResponse: {
|
|
251
|
-
...toolCallId != null ? { id: toolCallId } : {},
|
|
251
|
+
...includeFunctionCallIds && toolCallId != null ? { id: toolCallId } : {},
|
|
252
252
|
name: toolName,
|
|
253
253
|
response: {
|
|
254
254
|
name: toolName,
|
|
@@ -258,13 +258,13 @@ function appendToolResultParts(parts, toolName, outputValue, toolCallId) {
|
|
|
258
258
|
}
|
|
259
259
|
});
|
|
260
260
|
}
|
|
261
|
-
function appendLegacyToolResultParts(parts, toolName, outputValue, toolCallId) {
|
|
261
|
+
function appendLegacyToolResultParts(parts, toolName, outputValue, toolCallId, includeFunctionCallIds = true) {
|
|
262
262
|
for (const contentPart of outputValue) {
|
|
263
263
|
switch (contentPart.type) {
|
|
264
264
|
case "text":
|
|
265
265
|
parts.push({
|
|
266
266
|
functionResponse: {
|
|
267
|
-
...toolCallId != null ? { id: toolCallId } : {},
|
|
267
|
+
...includeFunctionCallIds && toolCallId != null ? { id: toolCallId } : {},
|
|
268
268
|
name: toolName,
|
|
269
269
|
response: {
|
|
270
270
|
name: toolName,
|
|
@@ -299,7 +299,7 @@ function appendLegacyToolResultParts(parts, toolName, outputValue, toolCallId) {
|
|
|
299
299
|
}
|
|
300
300
|
}
|
|
301
301
|
function convertToGoogleMessages(prompt, options) {
|
|
302
|
-
var _a, _b, _c, _d, _e;
|
|
302
|
+
var _a, _b, _c, _d, _e, _f;
|
|
303
303
|
const systemInstructionParts = [];
|
|
304
304
|
const contents = [];
|
|
305
305
|
let systemMessagesAllowed = true;
|
|
@@ -309,6 +309,7 @@ function convertToGoogleMessages(prompt, options) {
|
|
|
309
309
|
const providerOptionsNames = (_c = options == null ? void 0 : options.providerOptionsNames) != null ? _c : ["google"];
|
|
310
310
|
const isVertexLike = !providerOptionsNames.includes("google");
|
|
311
311
|
const supportsFunctionResponseParts = (_d = options == null ? void 0 : options.supportsFunctionResponseParts) != null ? _d : true;
|
|
312
|
+
const includeFunctionCallIds = (_e = options == null ? void 0 : options.includeFunctionCallIds) != null ? _e : true;
|
|
312
313
|
let sentinelInjected = false;
|
|
313
314
|
const missingSignatureToolNames = [];
|
|
314
315
|
const injectSkipSignature = (toolName) => {
|
|
@@ -522,7 +523,7 @@ function convertToGoogleMessages(prompt, options) {
|
|
|
522
523
|
}
|
|
523
524
|
return {
|
|
524
525
|
functionCall: {
|
|
525
|
-
...part.toolCallId != null ? { id: part.toolCallId } : {},
|
|
526
|
+
...includeFunctionCallIds && part.toolCallId != null ? { id: part.toolCallId } : {},
|
|
526
527
|
name: part.toolName,
|
|
527
528
|
args: part.input
|
|
528
529
|
},
|
|
@@ -583,24 +584,26 @@ function convertToGoogleMessages(prompt, options) {
|
|
|
583
584
|
parts,
|
|
584
585
|
part.toolName,
|
|
585
586
|
output.value,
|
|
586
|
-
part.toolCallId
|
|
587
|
+
part.toolCallId,
|
|
588
|
+
includeFunctionCallIds
|
|
587
589
|
);
|
|
588
590
|
} else {
|
|
589
591
|
appendLegacyToolResultParts(
|
|
590
592
|
parts,
|
|
591
593
|
part.toolName,
|
|
592
594
|
output.value,
|
|
593
|
-
part.toolCallId
|
|
595
|
+
part.toolCallId,
|
|
596
|
+
includeFunctionCallIds
|
|
594
597
|
);
|
|
595
598
|
}
|
|
596
599
|
} else {
|
|
597
600
|
parts.push({
|
|
598
601
|
functionResponse: {
|
|
599
|
-
...part.toolCallId != null ? { id: part.toolCallId } : {},
|
|
602
|
+
...includeFunctionCallIds && part.toolCallId != null ? { id: part.toolCallId } : {},
|
|
600
603
|
name: part.toolName,
|
|
601
604
|
response: {
|
|
602
605
|
name: part.toolName,
|
|
603
|
-
content: output.type === "execution-denied" ? (
|
|
606
|
+
content: output.type === "execution-denied" ? (_f = output.reason) != null ? _f : "Tool call execution denied." : output.value
|
|
604
607
|
}
|
|
605
608
|
}
|
|
606
609
|
});
|
|
@@ -1516,7 +1519,8 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1516
1519
|
isGemini3Model: usesGemini3Features,
|
|
1517
1520
|
onWarning: (warning) => warnings.push(warning),
|
|
1518
1521
|
providerOptionsNames,
|
|
1519
|
-
supportsFunctionResponseParts: usesGemini3Features
|
|
1522
|
+
supportsFunctionResponseParts: usesGemini3Features,
|
|
1523
|
+
includeFunctionCallIds: !isVertexProvider
|
|
1520
1524
|
});
|
|
1521
1525
|
const {
|
|
1522
1526
|
tools: googleTools2,
|