@ai-sdk/google 4.0.63 → 4.0.65
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 +20 -0
- package/dist/index.d.ts +8 -5
- package/dist/index.js +205 -129
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +10 -3
- package/dist/internal/index.js +104 -57
- package/dist/internal/index.js.map +1 -1
- package/docs/15-google.mdx +37 -13
- package/package.json +3 -3
- package/src/convert-json-schema-to-openapi-schema.ts +10 -0
- package/src/google-batch.ts +61 -35
- package/src/google-image-model.ts +3 -0
- package/src/google-language-model.ts +84 -36
- package/src/google-provider.ts +52 -34
package/dist/internal/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
2
|
-
import { WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE, Resolvable, FetchFunction, InferSchema } from '@ai-sdk/provider-utils';
|
|
2
|
+
import { WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE, Resolvable, FetchFunction, InferSchema, createToolNameMapping } from '@ai-sdk/provider-utils';
|
|
3
3
|
import * as _ai_sdk_provider from '@ai-sdk/provider';
|
|
4
4
|
import { LanguageModelV4, JSONObject, LanguageModelV4CallOptions, SharedV4Warning, LanguageModelV4GenerateResult, LanguageModelV4StreamResult, SpeechModelV4 } from '@ai-sdk/provider';
|
|
5
5
|
import { z } from 'zod/v4';
|
|
@@ -96,7 +96,10 @@ declare class GoogleLanguageModel implements LanguageModelV4 {
|
|
|
96
96
|
constructor(modelId: GoogleModelId, config: GoogleLanguageModelConfig);
|
|
97
97
|
get provider(): string;
|
|
98
98
|
get supportedUrls(): Record<string, RegExp[]> | PromiseLike<Record<string, RegExp[]>>;
|
|
99
|
-
|
|
99
|
+
static prepareRequest({ modelId, config, options: { prompt, maxOutputTokens, temperature, topP, topK, frequencyPenalty, presencePenalty, stopSequences, responseFormat, seed, tools, toolChoice, reasoning, providerOptions, }, isStreaming, }: {
|
|
100
|
+
modelId: GoogleModelId;
|
|
101
|
+
config: GoogleLanguageModelConfig;
|
|
102
|
+
options: LanguageModelV4CallOptions;
|
|
100
103
|
isStreaming?: boolean;
|
|
101
104
|
}): Promise<{
|
|
102
105
|
args: {
|
|
@@ -169,11 +172,15 @@ declare class GoogleLanguageModel implements LanguageModelV4 {
|
|
|
169
172
|
warnings: SharedV4Warning[];
|
|
170
173
|
providerOptionsNames: readonly string[];
|
|
171
174
|
extraHeaders: Record<string, string> | undefined;
|
|
175
|
+
toolNameMapping: _ai_sdk_provider_utils.ToolNameMapping;
|
|
172
176
|
}>;
|
|
173
|
-
|
|
177
|
+
private getArgs;
|
|
178
|
+
static convertGenerateContentResponse({ config, response, warnings, providerOptionsNames, toolNameMapping, }: {
|
|
179
|
+
config: GoogleLanguageModelConfig;
|
|
174
180
|
response: InferSchema<typeof responseSchema>;
|
|
175
181
|
warnings: SharedV4Warning[];
|
|
176
182
|
providerOptionsNames: readonly string[];
|
|
183
|
+
toolNameMapping?: ReturnType<typeof createToolNameMapping>;
|
|
177
184
|
}): LanguageModelV4GenerateResult;
|
|
178
185
|
doGenerate(options: LanguageModelV4CallOptions): Promise<LanguageModelV4GenerateResult>;
|
|
179
186
|
doStream(options: LanguageModelV4CallOptions): Promise<LanguageModelV4StreamResult>;
|
package/dist/internal/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// src/google-language-model.ts
|
|
2
2
|
import {
|
|
3
3
|
combineHeaders,
|
|
4
|
+
createToolNameMapping,
|
|
4
5
|
createEventSourceResponseHandler,
|
|
5
6
|
createJsonResponseHandler,
|
|
6
7
|
generateId,
|
|
@@ -97,6 +98,8 @@ function convertJSONSchemaDefinition(jsonSchema, isRoot, referenceContext) {
|
|
|
97
98
|
format,
|
|
98
99
|
const: constValue,
|
|
99
100
|
minLength,
|
|
101
|
+
minItems,
|
|
102
|
+
maxItems,
|
|
100
103
|
enum: enumValues
|
|
101
104
|
} = jsonSchema;
|
|
102
105
|
const result = {};
|
|
@@ -179,6 +182,12 @@ function convertJSONSchemaDefinition(jsonSchema, isRoot, referenceContext) {
|
|
|
179
182
|
if (minLength !== void 0) {
|
|
180
183
|
result.minLength = minLength;
|
|
181
184
|
}
|
|
185
|
+
if (minItems !== void 0) {
|
|
186
|
+
result.minItems = minItems;
|
|
187
|
+
}
|
|
188
|
+
if (maxItems !== void 0) {
|
|
189
|
+
result.maxItems = maxItems;
|
|
190
|
+
}
|
|
182
191
|
return result;
|
|
183
192
|
}
|
|
184
193
|
function convertJSONSchemaReference({
|
|
@@ -1578,25 +1587,32 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1578
1587
|
var _a, _b, _c;
|
|
1579
1588
|
return (_c = (_b = (_a = this.config).supportedUrls) == null ? void 0 : _b.call(_a)) != null ? _c : {};
|
|
1580
1589
|
}
|
|
1581
|
-
async
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1590
|
+
static async prepareRequest({
|
|
1591
|
+
modelId,
|
|
1592
|
+
config,
|
|
1593
|
+
options: {
|
|
1594
|
+
prompt,
|
|
1595
|
+
maxOutputTokens,
|
|
1596
|
+
temperature,
|
|
1597
|
+
topP,
|
|
1598
|
+
topK,
|
|
1599
|
+
frequencyPenalty,
|
|
1600
|
+
presencePenalty,
|
|
1601
|
+
stopSequences,
|
|
1602
|
+
responseFormat,
|
|
1603
|
+
seed,
|
|
1604
|
+
tools,
|
|
1605
|
+
toolChoice,
|
|
1606
|
+
reasoning,
|
|
1607
|
+
providerOptions
|
|
1608
|
+
},
|
|
1609
|
+
isStreaming = false
|
|
1610
|
+
}) {
|
|
1597
1611
|
var _a, _b, _c;
|
|
1598
1612
|
const warnings = [];
|
|
1599
|
-
const providerOptionsNames =
|
|
1613
|
+
const providerOptionsNames = config.provider.includes(
|
|
1614
|
+
"vertex"
|
|
1615
|
+
) ? ["googleVertex", "vertex"] : ["google"];
|
|
1600
1616
|
let googleOptions;
|
|
1601
1617
|
for (const name of providerOptionsNames) {
|
|
1602
1618
|
googleOptions = await parseProviderOptions({
|
|
@@ -1613,19 +1629,19 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1613
1629
|
schema: googleLanguageModelOptions
|
|
1614
1630
|
});
|
|
1615
1631
|
}
|
|
1616
|
-
const isVertexProvider =
|
|
1632
|
+
const isVertexProvider = config.provider.startsWith("google.vertex.");
|
|
1617
1633
|
if ((tools == null ? void 0 : tools.some(
|
|
1618
1634
|
(tool) => tool.type === "provider" && tool.id === "google.vertex_rag_store"
|
|
1619
1635
|
)) && !isVertexProvider) {
|
|
1620
1636
|
warnings.push({
|
|
1621
1637
|
type: "other",
|
|
1622
|
-
message: `The 'vertex_rag_store' tool is only supported with the Google Vertex provider and might not be supported or could behave unexpectedly with the current Google provider (${
|
|
1638
|
+
message: `The 'vertex_rag_store' tool is only supported with the Google Vertex provider and might not be supported or could behave unexpectedly with the current Google provider (${config.provider}).`
|
|
1623
1639
|
});
|
|
1624
1640
|
}
|
|
1625
1641
|
if ((googleOptions == null ? void 0 : googleOptions.streamFunctionCallArguments) && !isVertexProvider) {
|
|
1626
1642
|
warnings.push({
|
|
1627
1643
|
type: "other",
|
|
1628
|
-
message: `'streamFunctionCallArguments' is only supported on the Vertex AI API and will be ignored with the current Google provider (${
|
|
1644
|
+
message: `'streamFunctionCallArguments' is only supported on the Vertex AI API and will be ignored with the current Google provider (${config.provider}). See https://docs.cloud.google.com/vertex-ai/generative-ai/docs/multimodal/function-calling#streaming-fc`
|
|
1629
1645
|
});
|
|
1630
1646
|
}
|
|
1631
1647
|
if ((googleOptions == null ? void 0 : googleOptions.serviceTier) && isVertexProvider) {
|
|
@@ -1637,7 +1653,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1637
1653
|
if (((googleOptions == null ? void 0 : googleOptions.sharedRequestType) || (googleOptions == null ? void 0 : googleOptions.requestType)) && !isVertexProvider) {
|
|
1638
1654
|
warnings.push({
|
|
1639
1655
|
type: "other",
|
|
1640
|
-
message: `'sharedRequestType' and 'requestType' are Vertex AI options and are ignored with the current Google provider (${
|
|
1656
|
+
message: `'sharedRequestType' and 'requestType' are Vertex AI options and are ignored with the current Google provider (${config.provider}).`
|
|
1641
1657
|
});
|
|
1642
1658
|
}
|
|
1643
1659
|
const vertexPaygoHeaders = isVertexProvider && ((googleOptions == null ? void 0 : googleOptions.sharedRequestType) || (googleOptions == null ? void 0 : googleOptions.requestType)) ? {
|
|
@@ -1665,13 +1681,13 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1665
1681
|
if (droppedImageConfigFields.length > 0) {
|
|
1666
1682
|
warnings.push({
|
|
1667
1683
|
type: "other",
|
|
1668
|
-
message: `${droppedImageConfigFields.join(", ")} ${droppedImageConfigFields.length === 1 ? "is a Vertex AI option and is" : "are Vertex AI options and are"} ignored with the current Google provider (${
|
|
1684
|
+
message: `${droppedImageConfigFields.join(", ")} ${droppedImageConfigFields.length === 1 ? "is a Vertex AI option and is" : "are Vertex AI options and are"} ignored with the current Google provider (${config.provider}).`
|
|
1669
1685
|
});
|
|
1670
1686
|
imageConfig = geminiApiImageConfig;
|
|
1671
1687
|
}
|
|
1672
1688
|
}
|
|
1673
|
-
const isGemmaModel =
|
|
1674
|
-
const isGemini25DeveloperApiModel = !isVertexProvider && gemini25ModelPattern2.test(
|
|
1689
|
+
const isGemmaModel = modelId.toLowerCase().startsWith("gemma-");
|
|
1690
|
+
const isGemini25DeveloperApiModel = !isVertexProvider && gemini25ModelPattern2.test(modelId);
|
|
1675
1691
|
if (isGemini25DeveloperApiModel && frequencyPenalty != null) {
|
|
1676
1692
|
warnings.push({
|
|
1677
1693
|
type: "unsupported",
|
|
@@ -1684,7 +1700,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1684
1700
|
feature: "presencePenalty"
|
|
1685
1701
|
});
|
|
1686
1702
|
}
|
|
1687
|
-
const { usesGemini3Features } = getGoogleModelCapabilities(
|
|
1703
|
+
const { usesGemini3Features } = getGoogleModelCapabilities(modelId);
|
|
1688
1704
|
const { contents, systemInstruction } = convertToGoogleMessages(prompt, {
|
|
1689
1705
|
isGemmaModel,
|
|
1690
1706
|
isGemini3Model: usesGemini3Features,
|
|
@@ -1700,12 +1716,18 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1700
1716
|
} = prepareTools({
|
|
1701
1717
|
tools,
|
|
1702
1718
|
toolChoice,
|
|
1703
|
-
modelId
|
|
1719
|
+
modelId,
|
|
1704
1720
|
isVertexProvider
|
|
1705
1721
|
});
|
|
1722
|
+
const toolNameMapping = createToolNameMapping({
|
|
1723
|
+
tools,
|
|
1724
|
+
providerToolNames: {
|
|
1725
|
+
"google.code_execution": "code_execution"
|
|
1726
|
+
}
|
|
1727
|
+
});
|
|
1706
1728
|
const resolvedThinking = resolveThinkingConfig({
|
|
1707
1729
|
reasoning,
|
|
1708
|
-
modelId
|
|
1730
|
+
modelId,
|
|
1709
1731
|
warnings
|
|
1710
1732
|
});
|
|
1711
1733
|
const thinkingConfig = (googleOptions == null ? void 0 : googleOptions.thinkingConfig) || resolvedThinking ? { ...resolvedThinking, ...googleOptions == null ? void 0 : googleOptions.thinkingConfig } : void 0;
|
|
@@ -1767,15 +1789,26 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1767
1789
|
},
|
|
1768
1790
|
warnings: [...warnings, ...toolWarnings],
|
|
1769
1791
|
providerOptionsNames,
|
|
1770
|
-
extraHeaders: vertexPaygoHeaders
|
|
1792
|
+
extraHeaders: vertexPaygoHeaders,
|
|
1793
|
+
toolNameMapping
|
|
1771
1794
|
};
|
|
1772
1795
|
}
|
|
1773
|
-
|
|
1796
|
+
getArgs(options, { isStreaming = false } = {}) {
|
|
1797
|
+
return _GoogleLanguageModel.prepareRequest({
|
|
1798
|
+
modelId: this.modelId,
|
|
1799
|
+
config: this.config,
|
|
1800
|
+
options,
|
|
1801
|
+
isStreaming
|
|
1802
|
+
});
|
|
1803
|
+
}
|
|
1804
|
+
static convertGenerateContentResponse({
|
|
1805
|
+
config,
|
|
1774
1806
|
response,
|
|
1775
1807
|
warnings,
|
|
1776
|
-
providerOptionsNames
|
|
1808
|
+
providerOptionsNames,
|
|
1809
|
+
toolNameMapping
|
|
1777
1810
|
}) {
|
|
1778
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
1811
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
1779
1812
|
const wrapProviderMetadata = (payload) => Object.fromEntries(
|
|
1780
1813
|
providerOptionsNames.map((name) => [name, payload])
|
|
1781
1814
|
);
|
|
@@ -1790,12 +1823,12 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1790
1823
|
let lastServerToolCallId;
|
|
1791
1824
|
for (const part of parts) {
|
|
1792
1825
|
if ("executableCode" in part && ((_g = part.executableCode) == null ? void 0 : _g.code)) {
|
|
1793
|
-
const toolCallId =
|
|
1826
|
+
const toolCallId = config.generateId();
|
|
1794
1827
|
lastCodeExecutionToolCallId = toolCallId;
|
|
1795
1828
|
content.push({
|
|
1796
1829
|
type: "tool-call",
|
|
1797
1830
|
toolCallId,
|
|
1798
|
-
toolName: "code_execution",
|
|
1831
|
+
toolName: (_h = toolNameMapping == null ? void 0 : toolNameMapping.toCustomToolName("code_execution")) != null ? _h : "code_execution",
|
|
1799
1832
|
input: JSON.stringify(part.executableCode),
|
|
1800
1833
|
providerExecuted: true
|
|
1801
1834
|
});
|
|
@@ -1804,10 +1837,10 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1804
1837
|
type: "tool-result",
|
|
1805
1838
|
// Results correspond to the most recent executable code part.
|
|
1806
1839
|
toolCallId: lastCodeExecutionToolCallId,
|
|
1807
|
-
toolName: "code_execution",
|
|
1840
|
+
toolName: (_i = toolNameMapping == null ? void 0 : toolNameMapping.toCustomToolName("code_execution")) != null ? _i : "code_execution",
|
|
1808
1841
|
result: {
|
|
1809
1842
|
outcome: part.codeExecutionResult.outcome,
|
|
1810
|
-
output: (
|
|
1843
|
+
output: (_j = part.codeExecutionResult.output) != null ? _j : ""
|
|
1811
1844
|
}
|
|
1812
1845
|
});
|
|
1813
1846
|
} else if ("text" in part && part.text != null) {
|
|
@@ -1829,9 +1862,9 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1829
1862
|
} else if ("functionCall" in part && part.functionCall.name != null) {
|
|
1830
1863
|
content.push({
|
|
1831
1864
|
type: "tool-call",
|
|
1832
|
-
toolCallId: part.functionCall.id ||
|
|
1865
|
+
toolCallId: part.functionCall.id || config.generateId(),
|
|
1833
1866
|
toolName: part.functionCall.name,
|
|
1834
|
-
input: JSON.stringify((
|
|
1867
|
+
input: JSON.stringify((_k = part.functionCall.args) != null ? _k : {}),
|
|
1835
1868
|
providerMetadata: part.thoughtSignature ? wrapProviderMetadata({
|
|
1836
1869
|
thoughtSignature: part.thoughtSignature
|
|
1837
1870
|
}) : void 0
|
|
@@ -1848,13 +1881,13 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1848
1881
|
}) : void 0
|
|
1849
1882
|
});
|
|
1850
1883
|
} else if ("toolCall" in part && part.toolCall) {
|
|
1851
|
-
const toolCallId = part.toolCall.id ||
|
|
1884
|
+
const toolCallId = part.toolCall.id || config.generateId();
|
|
1852
1885
|
lastServerToolCallId = toolCallId;
|
|
1853
1886
|
content.push({
|
|
1854
1887
|
type: "tool-call",
|
|
1855
1888
|
toolCallId,
|
|
1856
1889
|
toolName: `server:${part.toolCall.toolType}`,
|
|
1857
|
-
input: JSON.stringify((
|
|
1890
|
+
input: JSON.stringify((_l = part.toolCall.args) != null ? _l : {}),
|
|
1858
1891
|
providerExecuted: true,
|
|
1859
1892
|
dynamic: true,
|
|
1860
1893
|
providerMetadata: part.thoughtSignature ? wrapProviderMetadata({
|
|
@@ -1867,12 +1900,12 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1867
1900
|
})
|
|
1868
1901
|
});
|
|
1869
1902
|
} else if ("toolResponse" in part && part.toolResponse) {
|
|
1870
|
-
const responseToolCallId = lastServerToolCallId || part.toolResponse.id ||
|
|
1903
|
+
const responseToolCallId = lastServerToolCallId || part.toolResponse.id || config.generateId();
|
|
1871
1904
|
content.push({
|
|
1872
1905
|
type: "tool-result",
|
|
1873
1906
|
toolCallId: responseToolCallId,
|
|
1874
1907
|
toolName: `server:${part.toolResponse.toolType}`,
|
|
1875
|
-
result: (
|
|
1908
|
+
result: (_m = part.toolResponse.response) != null ? _m : {},
|
|
1876
1909
|
providerMetadata: part.thoughtSignature ? wrapProviderMetadata({
|
|
1877
1910
|
thoughtSignature: part.thoughtSignature,
|
|
1878
1911
|
serverToolCallId: responseToolCallId,
|
|
@@ -1885,10 +1918,10 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1885
1918
|
lastServerToolCallId = void 0;
|
|
1886
1919
|
}
|
|
1887
1920
|
}
|
|
1888
|
-
const sources = (
|
|
1921
|
+
const sources = (_n = extractSources({
|
|
1889
1922
|
groundingMetadata: candidate == null ? void 0 : candidate.groundingMetadata,
|
|
1890
|
-
generateId:
|
|
1891
|
-
})) != null ?
|
|
1923
|
+
generateId: config.generateId
|
|
1924
|
+
})) != null ? _n : [];
|
|
1892
1925
|
for (const source of sources) {
|
|
1893
1926
|
content.push(source);
|
|
1894
1927
|
}
|
|
@@ -1907,22 +1940,28 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1907
1940
|
usage: convertGoogleUsage(usageMetadata),
|
|
1908
1941
|
warnings,
|
|
1909
1942
|
providerMetadata: wrapProviderMetadata({
|
|
1910
|
-
promptFeedback: (
|
|
1911
|
-
groundingMetadata: (
|
|
1912
|
-
urlContextMetadata: (
|
|
1913
|
-
safetyRatings: (
|
|
1943
|
+
promptFeedback: (_o = response.promptFeedback) != null ? _o : null,
|
|
1944
|
+
groundingMetadata: (_p = candidate == null ? void 0 : candidate.groundingMetadata) != null ? _p : null,
|
|
1945
|
+
urlContextMetadata: (_q = candidate == null ? void 0 : candidate.urlContextMetadata) != null ? _q : null,
|
|
1946
|
+
safetyRatings: (_r = candidate == null ? void 0 : candidate.safetyRatings) != null ? _r : null,
|
|
1914
1947
|
usageMetadata: usageMetadata != null ? usageMetadata : null,
|
|
1915
|
-
finishMessage: (
|
|
1916
|
-
serviceTier: (
|
|
1948
|
+
finishMessage: (_s = candidate == null ? void 0 : candidate.finishMessage) != null ? _s : null,
|
|
1949
|
+
serviceTier: (_t = usageMetadata == null ? void 0 : usageMetadata.serviceTier) != null ? _t : null
|
|
1917
1950
|
}),
|
|
1918
1951
|
response: {
|
|
1919
1952
|
// TODO timestamp, model id
|
|
1920
|
-
id: (
|
|
1953
|
+
id: (_u = response.responseId) != null ? _u : void 0
|
|
1921
1954
|
}
|
|
1922
1955
|
};
|
|
1923
1956
|
}
|
|
1924
1957
|
async doGenerate(options) {
|
|
1925
|
-
const {
|
|
1958
|
+
const {
|
|
1959
|
+
args,
|
|
1960
|
+
warnings,
|
|
1961
|
+
providerOptionsNames,
|
|
1962
|
+
extraHeaders,
|
|
1963
|
+
toolNameMapping
|
|
1964
|
+
} = await this.getArgs(options);
|
|
1926
1965
|
const mergedHeaders = combineHeaders(
|
|
1927
1966
|
this.config.headers ? await resolve(this.config.headers) : void 0,
|
|
1928
1967
|
options.headers,
|
|
@@ -1943,10 +1982,12 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1943
1982
|
abortSignal: options.abortSignal,
|
|
1944
1983
|
fetch: this.config.fetch
|
|
1945
1984
|
});
|
|
1946
|
-
const result =
|
|
1985
|
+
const result = _GoogleLanguageModel.convertGenerateContentResponse({
|
|
1986
|
+
config: this.config,
|
|
1947
1987
|
response,
|
|
1948
1988
|
warnings,
|
|
1949
|
-
providerOptionsNames
|
|
1989
|
+
providerOptionsNames,
|
|
1990
|
+
toolNameMapping
|
|
1950
1991
|
});
|
|
1951
1992
|
return {
|
|
1952
1993
|
...result,
|
|
@@ -1959,7 +2000,13 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1959
2000
|
};
|
|
1960
2001
|
}
|
|
1961
2002
|
async doStream(options) {
|
|
1962
|
-
const {
|
|
2003
|
+
const {
|
|
2004
|
+
args,
|
|
2005
|
+
warnings,
|
|
2006
|
+
providerOptionsNames,
|
|
2007
|
+
extraHeaders,
|
|
2008
|
+
toolNameMapping
|
|
2009
|
+
} = await this.getArgs(options, { isStreaming: true });
|
|
1963
2010
|
const wrapProviderMetadata = (payload) => Object.fromEntries(
|
|
1964
2011
|
providerOptionsNames.map((name) => [name, payload])
|
|
1965
2012
|
);
|
|
@@ -2100,7 +2147,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2100
2147
|
controller.enqueue({
|
|
2101
2148
|
type: "tool-call",
|
|
2102
2149
|
toolCallId,
|
|
2103
|
-
toolName: "code_execution",
|
|
2150
|
+
toolName: toolNameMapping.toCustomToolName("code_execution"),
|
|
2104
2151
|
input: JSON.stringify(part.executableCode),
|
|
2105
2152
|
providerExecuted: true
|
|
2106
2153
|
});
|
|
@@ -2110,7 +2157,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
2110
2157
|
controller.enqueue({
|
|
2111
2158
|
type: "tool-result",
|
|
2112
2159
|
toolCallId,
|
|
2113
|
-
toolName: "code_execution",
|
|
2160
|
+
toolName: toolNameMapping.toCustomToolName("code_execution"),
|
|
2114
2161
|
result: {
|
|
2115
2162
|
outcome: part.codeExecutionResult.outcome,
|
|
2116
2163
|
output: (_g = part.codeExecutionResult.output) != null ? _g : ""
|