@ai-sdk/google 3.0.68 → 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 +26 -0
- package/dist/index.js +56 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +56 -20
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +46 -19
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +46 -19
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/google-generative-ai-language-model.ts +36 -6
- package/src/google-prepare-tools.ts +6 -2
- package/src/interactions/convert-to-google-interactions-input.ts +9 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
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
|
+
|
|
15
|
+
## 3.0.70
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- 4f3f564: fix(provider/google): fix lack of image consistency when using Interactions API in stateless mode
|
|
20
|
+
|
|
21
|
+
## 3.0.69
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- bb377ba: fix(google): omit passing includeServerSideToolInvocations for Vertex tool_config
|
|
26
|
+
- Updated dependencies [f591416]
|
|
27
|
+
- @ai-sdk/provider-utils@4.0.27
|
|
28
|
+
|
|
3
29
|
## 3.0.68
|
|
4
30
|
|
|
5
31
|
### 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");
|
|
@@ -848,7 +848,8 @@ var import_provider3 = require("@ai-sdk/provider");
|
|
|
848
848
|
function prepareTools({
|
|
849
849
|
tools,
|
|
850
850
|
toolChoice,
|
|
851
|
-
modelId
|
|
851
|
+
modelId,
|
|
852
|
+
isVertexProvider = false
|
|
852
853
|
}) {
|
|
853
854
|
var _a, _b;
|
|
854
855
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
@@ -984,7 +985,9 @@ function prepareTools({
|
|
|
984
985
|
}
|
|
985
986
|
const combinedToolConfig = {
|
|
986
987
|
functionCallingConfig: { mode: "VALIDATED" },
|
|
987
|
-
|
|
988
|
+
...!isVertexProvider && {
|
|
989
|
+
includeServerSideToolInvocations: true
|
|
990
|
+
}
|
|
988
991
|
};
|
|
989
992
|
if (toolChoice != null) {
|
|
990
993
|
switch (toolChoice.type) {
|
|
@@ -1424,7 +1427,8 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1424
1427
|
} = prepareTools({
|
|
1425
1428
|
tools,
|
|
1426
1429
|
toolChoice,
|
|
1427
|
-
modelId: this.modelId
|
|
1430
|
+
modelId: this.modelId,
|
|
1431
|
+
isVertexProvider
|
|
1428
1432
|
});
|
|
1429
1433
|
const streamFunctionCallArguments = isStreaming && isVertexProvider ? (_a = googleOptions == null ? void 0 : googleOptions.streamFunctionCallArguments) != null ? _a : false : void 0;
|
|
1430
1434
|
const toolConfig = googleToolConfig || streamFunctionCallArguments || (googleOptions == null ? void 0 : googleOptions.retrievalConfig) ? {
|
|
@@ -1484,7 +1488,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1484
1488
|
};
|
|
1485
1489
|
}
|
|
1486
1490
|
async doGenerate(options) {
|
|
1487
|
-
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;
|
|
1488
1492
|
const { args, warnings, providerOptionsName } = await this.getArgs(options);
|
|
1489
1493
|
const mergedHeaders = (0, import_provider_utils6.combineHeaders)(
|
|
1490
1494
|
await (0, import_provider_utils6.resolve)(this.config.headers),
|
|
@@ -1552,12 +1556,12 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1552
1556
|
providerMetadata: thoughtSignatureMetadata
|
|
1553
1557
|
});
|
|
1554
1558
|
}
|
|
1555
|
-
} else if ("functionCall" in part && part.functionCall.name != null
|
|
1559
|
+
} else if ("functionCall" in part && part.functionCall.name != null) {
|
|
1556
1560
|
content.push({
|
|
1557
1561
|
type: "tool-call",
|
|
1558
1562
|
toolCallId: this.config.generateId(),
|
|
1559
1563
|
toolName: part.functionCall.name,
|
|
1560
|
-
input: JSON.stringify(part.functionCall.args),
|
|
1564
|
+
input: JSON.stringify((_e = part.functionCall.args) != null ? _e : {}),
|
|
1561
1565
|
providerMetadata: part.thoughtSignature ? {
|
|
1562
1566
|
[providerOptionsName]: {
|
|
1563
1567
|
thoughtSignature: part.thoughtSignature
|
|
@@ -1579,13 +1583,13 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1579
1583
|
} : void 0
|
|
1580
1584
|
});
|
|
1581
1585
|
} else if ("toolCall" in part && part.toolCall) {
|
|
1582
|
-
const toolCallId = (
|
|
1586
|
+
const toolCallId = (_f = part.toolCall.id) != null ? _f : this.config.generateId();
|
|
1583
1587
|
lastServerToolCallId = toolCallId;
|
|
1584
1588
|
content.push({
|
|
1585
1589
|
type: "tool-call",
|
|
1586
1590
|
toolCallId,
|
|
1587
1591
|
toolName: `server:${part.toolCall.toolType}`,
|
|
1588
|
-
input: JSON.stringify((
|
|
1592
|
+
input: JSON.stringify((_g = part.toolCall.args) != null ? _g : {}),
|
|
1589
1593
|
providerExecuted: true,
|
|
1590
1594
|
dynamic: true,
|
|
1591
1595
|
providerMetadata: part.thoughtSignature ? {
|
|
@@ -1602,12 +1606,12 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1602
1606
|
}
|
|
1603
1607
|
});
|
|
1604
1608
|
} else if ("toolResponse" in part && part.toolResponse) {
|
|
1605
|
-
const responseToolCallId = (
|
|
1609
|
+
const responseToolCallId = (_h = lastServerToolCallId != null ? lastServerToolCallId : part.toolResponse.id) != null ? _h : this.config.generateId();
|
|
1606
1610
|
content.push({
|
|
1607
1611
|
type: "tool-result",
|
|
1608
1612
|
toolCallId: responseToolCallId,
|
|
1609
1613
|
toolName: `server:${part.toolResponse.toolType}`,
|
|
1610
|
-
result: (
|
|
1614
|
+
result: (_i = part.toolResponse.response) != null ? _i : {},
|
|
1611
1615
|
providerMetadata: part.thoughtSignature ? {
|
|
1612
1616
|
[providerOptionsName]: {
|
|
1613
1617
|
thoughtSignature: part.thoughtSignature,
|
|
@@ -1624,10 +1628,10 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1624
1628
|
lastServerToolCallId = void 0;
|
|
1625
1629
|
}
|
|
1626
1630
|
}
|
|
1627
|
-
const sources = (
|
|
1631
|
+
const sources = (_j = extractSources({
|
|
1628
1632
|
groundingMetadata: candidate.groundingMetadata,
|
|
1629
1633
|
generateId: this.config.generateId
|
|
1630
|
-
})) != null ?
|
|
1634
|
+
})) != null ? _j : [];
|
|
1631
1635
|
for (const source of sources) {
|
|
1632
1636
|
content.push(source);
|
|
1633
1637
|
}
|
|
@@ -1641,19 +1645,19 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1641
1645
|
(part) => part.type === "tool-call" && !part.providerExecuted
|
|
1642
1646
|
)
|
|
1643
1647
|
}),
|
|
1644
|
-
raw: (
|
|
1648
|
+
raw: (_k = candidate.finishReason) != null ? _k : void 0
|
|
1645
1649
|
},
|
|
1646
1650
|
usage: convertGoogleGenerativeAIUsage(usageMetadata),
|
|
1647
1651
|
warnings,
|
|
1648
1652
|
providerMetadata: {
|
|
1649
1653
|
[providerOptionsName]: {
|
|
1650
|
-
promptFeedback: (
|
|
1651
|
-
groundingMetadata: (
|
|
1652
|
-
urlContextMetadata: (
|
|
1653
|
-
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,
|
|
1654
1658
|
usageMetadata: usageMetadata != null ? usageMetadata : null,
|
|
1655
|
-
finishMessage: (
|
|
1656
|
-
serviceTier: (
|
|
1659
|
+
finishMessage: (_p = candidate.finishMessage) != null ? _p : null,
|
|
1660
|
+
serviceTier: (_q = response.serviceTier) != null ? _q : null
|
|
1657
1661
|
}
|
|
1658
1662
|
},
|
|
1659
1663
|
request: { body: args },
|
|
@@ -1912,6 +1916,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1912
1916
|
const isStreamingChunk = part.functionCall.partialArgs != null || part.functionCall.name != null && part.functionCall.willContinue === true;
|
|
1913
1917
|
const isTerminalChunk = part.functionCall.name == null && part.functionCall.args == null && part.functionCall.partialArgs == null && part.functionCall.willContinue == null;
|
|
1914
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;
|
|
1915
1920
|
if (isStreamingChunk) {
|
|
1916
1921
|
if (part.functionCall.name != null && part.functionCall.willContinue === true) {
|
|
1917
1922
|
const toolCallId = generateId3();
|
|
@@ -2008,6 +2013,28 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2008
2013
|
providerMetadata: providerMeta
|
|
2009
2014
|
});
|
|
2010
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;
|
|
2011
2038
|
}
|
|
2012
2039
|
}
|
|
2013
2040
|
}
|
|
@@ -3746,6 +3773,15 @@ function convertToGoogleInteractionsInput({
|
|
|
3746
3773
|
...signature != null ? { signature } : {},
|
|
3747
3774
|
summary: part.text.length > 0 ? [{ type: "text", text: part.text }] : void 0
|
|
3748
3775
|
});
|
|
3776
|
+
} else if (part.type === "file") {
|
|
3777
|
+
const fileBlock = convertFilePartToContent({
|
|
3778
|
+
part,
|
|
3779
|
+
warnings,
|
|
3780
|
+
mediaResolution
|
|
3781
|
+
});
|
|
3782
|
+
if (fileBlock != null) {
|
|
3783
|
+
content.push(fileBlock);
|
|
3784
|
+
}
|
|
3749
3785
|
} else if (part.type === "tool-call") {
|
|
3750
3786
|
const signature = (_d = (_c = part.providerOptions) == null ? void 0 : _c.google) == null ? void 0 : _d.signature;
|
|
3751
3787
|
const args = typeof part.input === "string" ? safeParseToolArgs(part.input) : (_e = part.input) != null ? _e : {};
|