@ai-sdk/google 3.0.70 → 3.0.71
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.js +40 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +40 -17
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +39 -16
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +39 -16
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/google-generative-ai-language-model.ts +35 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @ai-sdk/google
|
|
2
2
|
|
|
3
|
+
## 3.0.71
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 59530cf: fix(google): emit Vertex no-args streaming tool calls and preserve thoughtSignature
|
|
8
|
+
|
|
9
|
+
Vertex emits a no-args function call as a single chunk shaped `{ functionCall: { name: 'X' } }` with no `args`, no `partialArgs`, and no `willContinue`. The streaming parser had no branch for this shape, so the call was dropped along with any `thoughtSignature` it carried. For Gemini 3 thinking models this caused the next multi-turn step to 400 with `missing thought_signature`. The unary (`doGenerate`) path had the same drop.
|
|
10
|
+
|
|
11
|
+
Both paths now emit the call as a complete tool call with `'{}'` input and propagate `thoughtSignature` provider metadata.
|
|
12
|
+
|
|
13
|
+
Fixes #14847.
|
|
14
|
+
|
|
3
15
|
## 3.0.70
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -30,7 +30,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
30
30
|
var import_provider_utils21 = require("@ai-sdk/provider-utils");
|
|
31
31
|
|
|
32
32
|
// src/version.ts
|
|
33
|
-
var VERSION = true ? "3.0.
|
|
33
|
+
var VERSION = true ? "3.0.71" : "0.0.0-test";
|
|
34
34
|
|
|
35
35
|
// src/google-generative-ai-embedding-model.ts
|
|
36
36
|
var import_provider = require("@ai-sdk/provider");
|
|
@@ -1488,7 +1488,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1488
1488
|
};
|
|
1489
1489
|
}
|
|
1490
1490
|
async doGenerate(options) {
|
|
1491
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
1491
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
1492
1492
|
const { args, warnings, providerOptionsName } = await this.getArgs(options);
|
|
1493
1493
|
const mergedHeaders = (0, import_provider_utils6.combineHeaders)(
|
|
1494
1494
|
await (0, import_provider_utils6.resolve)(this.config.headers),
|
|
@@ -1556,12 +1556,12 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1556
1556
|
providerMetadata: thoughtSignatureMetadata
|
|
1557
1557
|
});
|
|
1558
1558
|
}
|
|
1559
|
-
} else if ("functionCall" in part && part.functionCall.name != null
|
|
1559
|
+
} else if ("functionCall" in part && part.functionCall.name != null) {
|
|
1560
1560
|
content.push({
|
|
1561
1561
|
type: "tool-call",
|
|
1562
1562
|
toolCallId: this.config.generateId(),
|
|
1563
1563
|
toolName: part.functionCall.name,
|
|
1564
|
-
input: JSON.stringify(part.functionCall.args),
|
|
1564
|
+
input: JSON.stringify((_e = part.functionCall.args) != null ? _e : {}),
|
|
1565
1565
|
providerMetadata: part.thoughtSignature ? {
|
|
1566
1566
|
[providerOptionsName]: {
|
|
1567
1567
|
thoughtSignature: part.thoughtSignature
|
|
@@ -1583,13 +1583,13 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1583
1583
|
} : void 0
|
|
1584
1584
|
});
|
|
1585
1585
|
} else if ("toolCall" in part && part.toolCall) {
|
|
1586
|
-
const toolCallId = (
|
|
1586
|
+
const toolCallId = (_f = part.toolCall.id) != null ? _f : this.config.generateId();
|
|
1587
1587
|
lastServerToolCallId = toolCallId;
|
|
1588
1588
|
content.push({
|
|
1589
1589
|
type: "tool-call",
|
|
1590
1590
|
toolCallId,
|
|
1591
1591
|
toolName: `server:${part.toolCall.toolType}`,
|
|
1592
|
-
input: JSON.stringify((
|
|
1592
|
+
input: JSON.stringify((_g = part.toolCall.args) != null ? _g : {}),
|
|
1593
1593
|
providerExecuted: true,
|
|
1594
1594
|
dynamic: true,
|
|
1595
1595
|
providerMetadata: part.thoughtSignature ? {
|
|
@@ -1606,12 +1606,12 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1606
1606
|
}
|
|
1607
1607
|
});
|
|
1608
1608
|
} else if ("toolResponse" in part && part.toolResponse) {
|
|
1609
|
-
const responseToolCallId = (
|
|
1609
|
+
const responseToolCallId = (_h = lastServerToolCallId != null ? lastServerToolCallId : part.toolResponse.id) != null ? _h : this.config.generateId();
|
|
1610
1610
|
content.push({
|
|
1611
1611
|
type: "tool-result",
|
|
1612
1612
|
toolCallId: responseToolCallId,
|
|
1613
1613
|
toolName: `server:${part.toolResponse.toolType}`,
|
|
1614
|
-
result: (
|
|
1614
|
+
result: (_i = part.toolResponse.response) != null ? _i : {},
|
|
1615
1615
|
providerMetadata: part.thoughtSignature ? {
|
|
1616
1616
|
[providerOptionsName]: {
|
|
1617
1617
|
thoughtSignature: part.thoughtSignature,
|
|
@@ -1628,10 +1628,10 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1628
1628
|
lastServerToolCallId = void 0;
|
|
1629
1629
|
}
|
|
1630
1630
|
}
|
|
1631
|
-
const sources = (
|
|
1631
|
+
const sources = (_j = extractSources({
|
|
1632
1632
|
groundingMetadata: candidate.groundingMetadata,
|
|
1633
1633
|
generateId: this.config.generateId
|
|
1634
|
-
})) != null ?
|
|
1634
|
+
})) != null ? _j : [];
|
|
1635
1635
|
for (const source of sources) {
|
|
1636
1636
|
content.push(source);
|
|
1637
1637
|
}
|
|
@@ -1645,19 +1645,19 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1645
1645
|
(part) => part.type === "tool-call" && !part.providerExecuted
|
|
1646
1646
|
)
|
|
1647
1647
|
}),
|
|
1648
|
-
raw: (
|
|
1648
|
+
raw: (_k = candidate.finishReason) != null ? _k : void 0
|
|
1649
1649
|
},
|
|
1650
1650
|
usage: convertGoogleGenerativeAIUsage(usageMetadata),
|
|
1651
1651
|
warnings,
|
|
1652
1652
|
providerMetadata: {
|
|
1653
1653
|
[providerOptionsName]: {
|
|
1654
|
-
promptFeedback: (
|
|
1655
|
-
groundingMetadata: (
|
|
1656
|
-
urlContextMetadata: (
|
|
1657
|
-
safetyRatings: (
|
|
1654
|
+
promptFeedback: (_l = response.promptFeedback) != null ? _l : null,
|
|
1655
|
+
groundingMetadata: (_m = candidate.groundingMetadata) != null ? _m : null,
|
|
1656
|
+
urlContextMetadata: (_n = candidate.urlContextMetadata) != null ? _n : null,
|
|
1657
|
+
safetyRatings: (_o = candidate.safetyRatings) != null ? _o : null,
|
|
1658
1658
|
usageMetadata: usageMetadata != null ? usageMetadata : null,
|
|
1659
|
-
finishMessage: (
|
|
1660
|
-
serviceTier: (
|
|
1659
|
+
finishMessage: (_p = candidate.finishMessage) != null ? _p : null,
|
|
1660
|
+
serviceTier: (_q = response.serviceTier) != null ? _q : null
|
|
1661
1661
|
}
|
|
1662
1662
|
},
|
|
1663
1663
|
request: { body: args },
|
|
@@ -1916,6 +1916,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1916
1916
|
const isStreamingChunk = part.functionCall.partialArgs != null || part.functionCall.name != null && part.functionCall.willContinue === true;
|
|
1917
1917
|
const isTerminalChunk = part.functionCall.name == null && part.functionCall.args == null && part.functionCall.partialArgs == null && part.functionCall.willContinue == null;
|
|
1918
1918
|
const isCompleteCall = part.functionCall.name != null && part.functionCall.args != null && part.functionCall.partialArgs == null;
|
|
1919
|
+
const isNoArgsCompleteCall = part.functionCall.name != null && part.functionCall.args == null && part.functionCall.partialArgs == null && part.functionCall.willContinue !== true;
|
|
1919
1920
|
if (isStreamingChunk) {
|
|
1920
1921
|
if (part.functionCall.name != null && part.functionCall.willContinue === true) {
|
|
1921
1922
|
const toolCallId = generateId3();
|
|
@@ -2012,6 +2013,28 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2012
2013
|
providerMetadata: providerMeta
|
|
2013
2014
|
});
|
|
2014
2015
|
hasToolCalls = true;
|
|
2016
|
+
} else if (isNoArgsCompleteCall) {
|
|
2017
|
+
const toolCallId = generateId3();
|
|
2018
|
+
const toolName = part.functionCall.name;
|
|
2019
|
+
controller.enqueue({
|
|
2020
|
+
type: "tool-input-start",
|
|
2021
|
+
id: toolCallId,
|
|
2022
|
+
toolName,
|
|
2023
|
+
providerMetadata: providerMeta
|
|
2024
|
+
});
|
|
2025
|
+
controller.enqueue({
|
|
2026
|
+
type: "tool-input-end",
|
|
2027
|
+
id: toolCallId,
|
|
2028
|
+
providerMetadata: providerMeta
|
|
2029
|
+
});
|
|
2030
|
+
controller.enqueue({
|
|
2031
|
+
type: "tool-call",
|
|
2032
|
+
toolCallId,
|
|
2033
|
+
toolName,
|
|
2034
|
+
input: "{}",
|
|
2035
|
+
providerMetadata: providerMeta
|
|
2036
|
+
});
|
|
2037
|
+
hasToolCalls = true;
|
|
2015
2038
|
}
|
|
2016
2039
|
}
|
|
2017
2040
|
}
|