@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/dist/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "@ai-sdk/provider-utils";
|
|
8
8
|
|
|
9
9
|
// src/version.ts
|
|
10
|
-
var VERSION = true ? "3.0.
|
|
10
|
+
var VERSION = true ? "3.0.71" : "0.0.0-test";
|
|
11
11
|
|
|
12
12
|
// src/google-generative-ai-embedding-model.ts
|
|
13
13
|
import {
|
|
@@ -1499,7 +1499,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1499
1499
|
};
|
|
1500
1500
|
}
|
|
1501
1501
|
async doGenerate(options) {
|
|
1502
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
1502
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
1503
1503
|
const { args, warnings, providerOptionsName } = await this.getArgs(options);
|
|
1504
1504
|
const mergedHeaders = combineHeaders2(
|
|
1505
1505
|
await resolve2(this.config.headers),
|
|
@@ -1567,12 +1567,12 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1567
1567
|
providerMetadata: thoughtSignatureMetadata
|
|
1568
1568
|
});
|
|
1569
1569
|
}
|
|
1570
|
-
} else if ("functionCall" in part && part.functionCall.name != null
|
|
1570
|
+
} else if ("functionCall" in part && part.functionCall.name != null) {
|
|
1571
1571
|
content.push({
|
|
1572
1572
|
type: "tool-call",
|
|
1573
1573
|
toolCallId: this.config.generateId(),
|
|
1574
1574
|
toolName: part.functionCall.name,
|
|
1575
|
-
input: JSON.stringify(part.functionCall.args),
|
|
1575
|
+
input: JSON.stringify((_e = part.functionCall.args) != null ? _e : {}),
|
|
1576
1576
|
providerMetadata: part.thoughtSignature ? {
|
|
1577
1577
|
[providerOptionsName]: {
|
|
1578
1578
|
thoughtSignature: part.thoughtSignature
|
|
@@ -1594,13 +1594,13 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1594
1594
|
} : void 0
|
|
1595
1595
|
});
|
|
1596
1596
|
} else if ("toolCall" in part && part.toolCall) {
|
|
1597
|
-
const toolCallId = (
|
|
1597
|
+
const toolCallId = (_f = part.toolCall.id) != null ? _f : this.config.generateId();
|
|
1598
1598
|
lastServerToolCallId = toolCallId;
|
|
1599
1599
|
content.push({
|
|
1600
1600
|
type: "tool-call",
|
|
1601
1601
|
toolCallId,
|
|
1602
1602
|
toolName: `server:${part.toolCall.toolType}`,
|
|
1603
|
-
input: JSON.stringify((
|
|
1603
|
+
input: JSON.stringify((_g = part.toolCall.args) != null ? _g : {}),
|
|
1604
1604
|
providerExecuted: true,
|
|
1605
1605
|
dynamic: true,
|
|
1606
1606
|
providerMetadata: part.thoughtSignature ? {
|
|
@@ -1617,12 +1617,12 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1617
1617
|
}
|
|
1618
1618
|
});
|
|
1619
1619
|
} else if ("toolResponse" in part && part.toolResponse) {
|
|
1620
|
-
const responseToolCallId = (
|
|
1620
|
+
const responseToolCallId = (_h = lastServerToolCallId != null ? lastServerToolCallId : part.toolResponse.id) != null ? _h : this.config.generateId();
|
|
1621
1621
|
content.push({
|
|
1622
1622
|
type: "tool-result",
|
|
1623
1623
|
toolCallId: responseToolCallId,
|
|
1624
1624
|
toolName: `server:${part.toolResponse.toolType}`,
|
|
1625
|
-
result: (
|
|
1625
|
+
result: (_i = part.toolResponse.response) != null ? _i : {},
|
|
1626
1626
|
providerMetadata: part.thoughtSignature ? {
|
|
1627
1627
|
[providerOptionsName]: {
|
|
1628
1628
|
thoughtSignature: part.thoughtSignature,
|
|
@@ -1639,10 +1639,10 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1639
1639
|
lastServerToolCallId = void 0;
|
|
1640
1640
|
}
|
|
1641
1641
|
}
|
|
1642
|
-
const sources = (
|
|
1642
|
+
const sources = (_j = extractSources({
|
|
1643
1643
|
groundingMetadata: candidate.groundingMetadata,
|
|
1644
1644
|
generateId: this.config.generateId
|
|
1645
|
-
})) != null ?
|
|
1645
|
+
})) != null ? _j : [];
|
|
1646
1646
|
for (const source of sources) {
|
|
1647
1647
|
content.push(source);
|
|
1648
1648
|
}
|
|
@@ -1656,19 +1656,19 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1656
1656
|
(part) => part.type === "tool-call" && !part.providerExecuted
|
|
1657
1657
|
)
|
|
1658
1658
|
}),
|
|
1659
|
-
raw: (
|
|
1659
|
+
raw: (_k = candidate.finishReason) != null ? _k : void 0
|
|
1660
1660
|
},
|
|
1661
1661
|
usage: convertGoogleGenerativeAIUsage(usageMetadata),
|
|
1662
1662
|
warnings,
|
|
1663
1663
|
providerMetadata: {
|
|
1664
1664
|
[providerOptionsName]: {
|
|
1665
|
-
promptFeedback: (
|
|
1666
|
-
groundingMetadata: (
|
|
1667
|
-
urlContextMetadata: (
|
|
1668
|
-
safetyRatings: (
|
|
1665
|
+
promptFeedback: (_l = response.promptFeedback) != null ? _l : null,
|
|
1666
|
+
groundingMetadata: (_m = candidate.groundingMetadata) != null ? _m : null,
|
|
1667
|
+
urlContextMetadata: (_n = candidate.urlContextMetadata) != null ? _n : null,
|
|
1668
|
+
safetyRatings: (_o = candidate.safetyRatings) != null ? _o : null,
|
|
1669
1669
|
usageMetadata: usageMetadata != null ? usageMetadata : null,
|
|
1670
|
-
finishMessage: (
|
|
1671
|
-
serviceTier: (
|
|
1670
|
+
finishMessage: (_p = candidate.finishMessage) != null ? _p : null,
|
|
1671
|
+
serviceTier: (_q = response.serviceTier) != null ? _q : null
|
|
1672
1672
|
}
|
|
1673
1673
|
},
|
|
1674
1674
|
request: { body: args },
|
|
@@ -1927,6 +1927,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1927
1927
|
const isStreamingChunk = part.functionCall.partialArgs != null || part.functionCall.name != null && part.functionCall.willContinue === true;
|
|
1928
1928
|
const isTerminalChunk = part.functionCall.name == null && part.functionCall.args == null && part.functionCall.partialArgs == null && part.functionCall.willContinue == null;
|
|
1929
1929
|
const isCompleteCall = part.functionCall.name != null && part.functionCall.args != null && part.functionCall.partialArgs == null;
|
|
1930
|
+
const isNoArgsCompleteCall = part.functionCall.name != null && part.functionCall.args == null && part.functionCall.partialArgs == null && part.functionCall.willContinue !== true;
|
|
1930
1931
|
if (isStreamingChunk) {
|
|
1931
1932
|
if (part.functionCall.name != null && part.functionCall.willContinue === true) {
|
|
1932
1933
|
const toolCallId = generateId3();
|
|
@@ -2023,6 +2024,28 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2023
2024
|
providerMetadata: providerMeta
|
|
2024
2025
|
});
|
|
2025
2026
|
hasToolCalls = true;
|
|
2027
|
+
} else if (isNoArgsCompleteCall) {
|
|
2028
|
+
const toolCallId = generateId3();
|
|
2029
|
+
const toolName = part.functionCall.name;
|
|
2030
|
+
controller.enqueue({
|
|
2031
|
+
type: "tool-input-start",
|
|
2032
|
+
id: toolCallId,
|
|
2033
|
+
toolName,
|
|
2034
|
+
providerMetadata: providerMeta
|
|
2035
|
+
});
|
|
2036
|
+
controller.enqueue({
|
|
2037
|
+
type: "tool-input-end",
|
|
2038
|
+
id: toolCallId,
|
|
2039
|
+
providerMetadata: providerMeta
|
|
2040
|
+
});
|
|
2041
|
+
controller.enqueue({
|
|
2042
|
+
type: "tool-call",
|
|
2043
|
+
toolCallId,
|
|
2044
|
+
toolName,
|
|
2045
|
+
input: "{}",
|
|
2046
|
+
providerMetadata: providerMeta
|
|
2047
|
+
});
|
|
2048
|
+
hasToolCalls = true;
|
|
2026
2049
|
}
|
|
2027
2050
|
}
|
|
2028
2051
|
}
|