@ai-sdk/google 3.0.75 → 3.0.77
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 +13 -0
- package/dist/index.d.mts +39 -12
- package/dist/index.d.ts +39 -12
- package/dist/index.js +215 -69
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +215 -69
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +1 -2
- package/dist/internal/index.d.ts +1 -2
- package/dist/internal/index.js +97 -59
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +97 -59
- package/dist/internal/index.mjs.map +1 -1
- package/docs/15-google-generative-ai.mdx +1 -0
- package/package.json +1 -1
- package/src/google-generative-ai-language-model.ts +104 -56
- package/src/google-generative-ai-options.ts +24 -8
- package/src/google-provider.ts +9 -4
- package/src/interactions/google-interactions-agent.ts +6 -7
- package/src/interactions/google-interactions-language-model-options.ts +65 -0
- package/src/interactions/google-interactions-language-model.ts +73 -22
- package/src/interactions/google-interactions-prompt.ts +50 -0
- package/src/interactions/stream-google-interactions.ts +1 -1
|
@@ -3,7 +3,7 @@ import { Resolvable, FetchFunction, InferSchema } from '@ai-sdk/provider-utils';
|
|
|
3
3
|
import { LanguageModelV3, LanguageModelV3CallOptions, LanguageModelV3GenerateResult, LanguageModelV3StreamResult } from '@ai-sdk/provider';
|
|
4
4
|
import { z } from 'zod/v4';
|
|
5
5
|
|
|
6
|
-
type GoogleGenerativeAIModelId = 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-2.0-flash-lite' | 'gemini-2.0-flash-lite-001' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-image' | 'gemini-2.5-flash-lite' | 'gemini-2.5-flash-preview-tts' | 'gemini-2.5-pro-preview-tts' | 'gemini-2.5-flash-native-audio-latest' | 'gemini-2.5-flash-native-audio-preview-09-2025' | 'gemini-2.5-flash-native-audio-preview-12-2025' | 'gemini-2.5-computer-use-preview-10-2025' | 'gemini-3-pro-preview' | 'gemini-3-pro-image-preview' | 'gemini-3-flash-preview' | 'gemini-3.1-pro-preview' | 'gemini-3.1-pro-preview-customtools' | 'gemini-3.1-flash-image-preview' | 'gemini-3.1-flash-lite-preview' | 'gemini-3.1-flash-tts-preview' | 'gemini-pro-latest' | 'gemini-flash-latest' | 'gemini-flash-lite-latest' | 'deep-research-pro-preview-12-2025' | 'nano-banana-pro-preview' | 'aqa' | 'gemini-robotics-er-1.5-preview' | 'gemma-3-1b-it' | 'gemma-3-4b-it' | 'gemma-3n-e4b-it' | 'gemma-3n-e2b-it' | 'gemma-3-12b-it' | 'gemma-3-27b-it' | (string & {});
|
|
6
|
+
type GoogleGenerativeAIModelId = 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-2.0-flash-lite' | 'gemini-2.0-flash-lite-001' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-image' | 'gemini-2.5-flash-lite' | 'gemini-2.5-flash-preview-tts' | 'gemini-2.5-pro-preview-tts' | 'gemini-2.5-flash-native-audio-latest' | 'gemini-2.5-flash-native-audio-preview-09-2025' | 'gemini-2.5-flash-native-audio-preview-12-2025' | 'gemini-2.5-computer-use-preview-10-2025' | 'gemini-3-pro-preview' | 'gemini-3-pro-image-preview' | 'gemini-3-flash-preview' | 'gemini-3.1-pro-preview' | 'gemini-3.1-pro-preview-customtools' | 'gemini-3.1-flash-image-preview' | 'gemini-3.1-flash-lite-preview' | 'gemini-3.1-flash-tts-preview' | 'gemini-3.5-flash' | 'gemini-pro-latest' | 'gemini-flash-latest' | 'gemini-flash-lite-latest' | 'deep-research-pro-preview-12-2025' | 'nano-banana-pro-preview' | 'aqa' | 'gemini-robotics-er-1.5-preview' | 'gemma-3-1b-it' | 'gemma-3-4b-it' | 'gemma-3n-e4b-it' | 'gemma-3n-e2b-it' | 'gemma-3-12b-it' | 'gemma-3-27b-it' | (string & {});
|
|
7
7
|
|
|
8
8
|
type GoogleGenerativeAIConfig = {
|
|
9
9
|
provider: string;
|
|
@@ -226,7 +226,6 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
226
226
|
blocked?: boolean | null | undefined;
|
|
227
227
|
}[] | null | undefined;
|
|
228
228
|
} | null | undefined;
|
|
229
|
-
serviceTier?: string | null | undefined;
|
|
230
229
|
}>;
|
|
231
230
|
type GroundingMetadataSchema = NonNullable<InferSchema<typeof responseSchema>['candidates'][number]['groundingMetadata']>;
|
|
232
231
|
type UrlContextMetadataSchema = NonNullable<InferSchema<typeof responseSchema>['candidates'][number]['urlContextMetadata']>;
|
package/dist/internal/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { Resolvable, FetchFunction, InferSchema } from '@ai-sdk/provider-utils';
|
|
|
3
3
|
import { LanguageModelV3, LanguageModelV3CallOptions, LanguageModelV3GenerateResult, LanguageModelV3StreamResult } from '@ai-sdk/provider';
|
|
4
4
|
import { z } from 'zod/v4';
|
|
5
5
|
|
|
6
|
-
type GoogleGenerativeAIModelId = 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-2.0-flash-lite' | 'gemini-2.0-flash-lite-001' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-image' | 'gemini-2.5-flash-lite' | 'gemini-2.5-flash-preview-tts' | 'gemini-2.5-pro-preview-tts' | 'gemini-2.5-flash-native-audio-latest' | 'gemini-2.5-flash-native-audio-preview-09-2025' | 'gemini-2.5-flash-native-audio-preview-12-2025' | 'gemini-2.5-computer-use-preview-10-2025' | 'gemini-3-pro-preview' | 'gemini-3-pro-image-preview' | 'gemini-3-flash-preview' | 'gemini-3.1-pro-preview' | 'gemini-3.1-pro-preview-customtools' | 'gemini-3.1-flash-image-preview' | 'gemini-3.1-flash-lite-preview' | 'gemini-3.1-flash-tts-preview' | 'gemini-pro-latest' | 'gemini-flash-latest' | 'gemini-flash-lite-latest' | 'deep-research-pro-preview-12-2025' | 'nano-banana-pro-preview' | 'aqa' | 'gemini-robotics-er-1.5-preview' | 'gemma-3-1b-it' | 'gemma-3-4b-it' | 'gemma-3n-e4b-it' | 'gemma-3n-e2b-it' | 'gemma-3-12b-it' | 'gemma-3-27b-it' | (string & {});
|
|
6
|
+
type GoogleGenerativeAIModelId = 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-2.0-flash-lite' | 'gemini-2.0-flash-lite-001' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-image' | 'gemini-2.5-flash-lite' | 'gemini-2.5-flash-preview-tts' | 'gemini-2.5-pro-preview-tts' | 'gemini-2.5-flash-native-audio-latest' | 'gemini-2.5-flash-native-audio-preview-09-2025' | 'gemini-2.5-flash-native-audio-preview-12-2025' | 'gemini-2.5-computer-use-preview-10-2025' | 'gemini-3-pro-preview' | 'gemini-3-pro-image-preview' | 'gemini-3-flash-preview' | 'gemini-3.1-pro-preview' | 'gemini-3.1-pro-preview-customtools' | 'gemini-3.1-flash-image-preview' | 'gemini-3.1-flash-lite-preview' | 'gemini-3.1-flash-tts-preview' | 'gemini-3.5-flash' | 'gemini-pro-latest' | 'gemini-flash-latest' | 'gemini-flash-lite-latest' | 'deep-research-pro-preview-12-2025' | 'nano-banana-pro-preview' | 'aqa' | 'gemini-robotics-er-1.5-preview' | 'gemma-3-1b-it' | 'gemma-3-4b-it' | 'gemma-3n-e4b-it' | 'gemma-3n-e2b-it' | 'gemma-3-12b-it' | 'gemma-3-27b-it' | (string & {});
|
|
7
7
|
|
|
8
8
|
type GoogleGenerativeAIConfig = {
|
|
9
9
|
provider: string;
|
|
@@ -226,7 +226,6 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
226
226
|
blocked?: boolean | null | undefined;
|
|
227
227
|
}[] | null | undefined;
|
|
228
228
|
} | null | undefined;
|
|
229
|
-
serviceTier?: string | null | undefined;
|
|
230
229
|
}>;
|
|
231
230
|
type GroundingMetadataSchema = NonNullable<InferSchema<typeof responseSchema>['candidates'][number]['groundingMetadata']>;
|
|
232
231
|
type UrlContextMetadataSchema = NonNullable<InferSchema<typeof responseSchema>['candidates'][number]['urlContextMetadata']>;
|
package/dist/internal/index.js
CHANGED
|
@@ -653,17 +653,32 @@ var googleLanguageModelOptions = (0, import_provider_utils3.lazySchema)(
|
|
|
653
653
|
*/
|
|
654
654
|
streamFunctionCallArguments: import_v42.z.boolean().optional(),
|
|
655
655
|
/**
|
|
656
|
-
* Optional. The service tier to use for the request.
|
|
656
|
+
* Optional. The service tier to use for the request. Sent as the
|
|
657
|
+
* `serviceTier` body field. Gemini API only.
|
|
657
658
|
*/
|
|
658
|
-
serviceTier: import_v42.z.enum(["standard", "flex", "priority"]).optional()
|
|
659
|
+
serviceTier: import_v42.z.enum(["standard", "flex", "priority"]).optional(),
|
|
660
|
+
/**
|
|
661
|
+
* Optional. Vertex AI only. Sent as the
|
|
662
|
+
* `X-Vertex-AI-LLM-Shared-Request-Type` request header to select a
|
|
663
|
+
* shared (PayGo) tier. With Provisioned Throughput allocated and
|
|
664
|
+
* `requestType` unset, the request falls back to this tier only if
|
|
665
|
+
* PT capacity is exhausted.
|
|
666
|
+
*
|
|
667
|
+
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/priority-paygo
|
|
668
|
+
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/flex-paygo
|
|
669
|
+
*/
|
|
670
|
+
sharedRequestType: import_v42.z.enum(["priority", "flex", "standard"]).optional(),
|
|
671
|
+
/**
|
|
672
|
+
* Optional. Vertex AI only. Sent as the `X-Vertex-AI-LLM-Request-Type`
|
|
673
|
+
* request header. Set to `'shared'` together with `sharedRequestType`
|
|
674
|
+
* to bypass Provisioned Throughput entirely.
|
|
675
|
+
*
|
|
676
|
+
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/priority-paygo
|
|
677
|
+
*/
|
|
678
|
+
requestType: import_v42.z.enum(["shared"]).optional()
|
|
659
679
|
})
|
|
660
680
|
)
|
|
661
681
|
);
|
|
662
|
-
var VertexServiceTierMap = {
|
|
663
|
-
standard: "SERVICE_TIER_STANDARD",
|
|
664
|
-
flex: "SERVICE_TIER_FLEX",
|
|
665
|
-
priority: "SERVICE_TIER_PRIORITY"
|
|
666
|
-
};
|
|
667
682
|
|
|
668
683
|
// src/google-prepare-tools.ts
|
|
669
684
|
var import_provider2 = require("@ai-sdk/provider");
|
|
@@ -1228,10 +1243,27 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1228
1243
|
message: `'streamFunctionCallArguments' is only supported on the Vertex AI API and will be ignored with the current Google provider (${this.config.provider}). See https://docs.cloud.google.com/vertex-ai/generative-ai/docs/multimodal/function-calling#streaming-fc`
|
|
1229
1244
|
});
|
|
1230
1245
|
}
|
|
1231
|
-
let sanitizedServiceTier = googleOptions == null ? void 0 : googleOptions.serviceTier;
|
|
1232
1246
|
if ((googleOptions == null ? void 0 : googleOptions.serviceTier) && isVertexProvider) {
|
|
1233
|
-
|
|
1247
|
+
warnings.push({
|
|
1248
|
+
type: "other",
|
|
1249
|
+
message: "'serviceTier' is a Gemini API option and is not supported on Vertex AI. Use 'sharedRequestType' (and optionally 'requestType') instead. See https://docs.cloud.google.com/vertex-ai/generative-ai/docs/priority-paygo"
|
|
1250
|
+
});
|
|
1234
1251
|
}
|
|
1252
|
+
if (((googleOptions == null ? void 0 : googleOptions.sharedRequestType) || (googleOptions == null ? void 0 : googleOptions.requestType)) && !isVertexProvider) {
|
|
1253
|
+
warnings.push({
|
|
1254
|
+
type: "other",
|
|
1255
|
+
message: `'sharedRequestType' and 'requestType' are Vertex AI options and are ignored with the current Google provider (${this.config.provider}).`
|
|
1256
|
+
});
|
|
1257
|
+
}
|
|
1258
|
+
const vertexPaygoHeaders = isVertexProvider && ((googleOptions == null ? void 0 : googleOptions.sharedRequestType) || (googleOptions == null ? void 0 : googleOptions.requestType)) ? {
|
|
1259
|
+
...googleOptions.sharedRequestType && {
|
|
1260
|
+
"X-Vertex-AI-LLM-Shared-Request-Type": googleOptions.sharedRequestType
|
|
1261
|
+
},
|
|
1262
|
+
...googleOptions.requestType && {
|
|
1263
|
+
"X-Vertex-AI-LLM-Request-Type": googleOptions.requestType
|
|
1264
|
+
}
|
|
1265
|
+
} : void 0;
|
|
1266
|
+
const bodyServiceTier = isVertexProvider ? void 0 : googleOptions == null ? void 0 : googleOptions.serviceTier;
|
|
1235
1267
|
const isGemmaModel = this.modelId.toLowerCase().startsWith("gemma-");
|
|
1236
1268
|
const supportsFunctionResponseParts = this.modelId.startsWith("gemini-3");
|
|
1237
1269
|
const { contents, systemInstruction } = convertToGoogleGenerativeAIMessages(
|
|
@@ -1303,18 +1335,20 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1303
1335
|
toolConfig,
|
|
1304
1336
|
cachedContent: googleOptions == null ? void 0 : googleOptions.cachedContent,
|
|
1305
1337
|
labels: googleOptions == null ? void 0 : googleOptions.labels,
|
|
1306
|
-
serviceTier:
|
|
1338
|
+
serviceTier: bodyServiceTier
|
|
1307
1339
|
},
|
|
1308
1340
|
warnings: [...warnings, ...toolWarnings],
|
|
1309
|
-
providerOptionsName
|
|
1341
|
+
providerOptionsName,
|
|
1342
|
+
extraHeaders: vertexPaygoHeaders
|
|
1310
1343
|
};
|
|
1311
1344
|
}
|
|
1312
1345
|
async doGenerate(options) {
|
|
1313
1346
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
1314
|
-
const { args, warnings, providerOptionsName } = await this.getArgs(options);
|
|
1347
|
+
const { args, warnings, providerOptionsName, extraHeaders } = await this.getArgs(options);
|
|
1315
1348
|
const mergedHeaders = (0, import_provider_utils4.combineHeaders)(
|
|
1316
1349
|
await (0, import_provider_utils4.resolve)(this.config.headers),
|
|
1317
|
-
options.headers
|
|
1350
|
+
options.headers,
|
|
1351
|
+
extraHeaders
|
|
1318
1352
|
);
|
|
1319
1353
|
const {
|
|
1320
1354
|
responseHeaders,
|
|
@@ -1479,7 +1513,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1479
1513
|
safetyRatings: (_p = candidate.safetyRatings) != null ? _p : null,
|
|
1480
1514
|
usageMetadata: usageMetadata != null ? usageMetadata : null,
|
|
1481
1515
|
finishMessage: (_q = candidate.finishMessage) != null ? _q : null,
|
|
1482
|
-
serviceTier: (_r =
|
|
1516
|
+
serviceTier: (_r = responseHeaders == null ? void 0 : responseHeaders["x-gemini-service-tier"]) != null ? _r : null
|
|
1483
1517
|
}
|
|
1484
1518
|
},
|
|
1485
1519
|
request: { body: args },
|
|
@@ -1491,13 +1525,12 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1491
1525
|
};
|
|
1492
1526
|
}
|
|
1493
1527
|
async doStream(options) {
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
{ isStreaming: true }
|
|
1497
|
-
);
|
|
1528
|
+
var _a;
|
|
1529
|
+
const { args, warnings, providerOptionsName, extraHeaders } = await this.getArgs(options, { isStreaming: true });
|
|
1498
1530
|
const headers = (0, import_provider_utils4.combineHeaders)(
|
|
1499
1531
|
await (0, import_provider_utils4.resolve)(this.config.headers),
|
|
1500
|
-
options.headers
|
|
1532
|
+
options.headers,
|
|
1533
|
+
extraHeaders
|
|
1501
1534
|
);
|
|
1502
1535
|
const { responseHeaders, value: response } = await (0, import_provider_utils4.postJsonToApi)({
|
|
1503
1536
|
url: `${this.config.baseURL}/${getModelPath(
|
|
@@ -1518,7 +1551,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1518
1551
|
let providerMetadata = void 0;
|
|
1519
1552
|
let lastGroundingMetadata = null;
|
|
1520
1553
|
let lastUrlContextMetadata = null;
|
|
1521
|
-
|
|
1554
|
+
const serviceTier = (_a = responseHeaders == null ? void 0 : responseHeaders["x-gemini-service-tier"]) != null ? _a : null;
|
|
1522
1555
|
const generateId2 = this.config.generateId;
|
|
1523
1556
|
let hasToolCalls = false;
|
|
1524
1557
|
let currentTextBlockId = null;
|
|
@@ -1528,6 +1561,34 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1528
1561
|
let lastCodeExecutionToolCallId;
|
|
1529
1562
|
let lastServerToolCallId;
|
|
1530
1563
|
const activeStreamingToolCalls = [];
|
|
1564
|
+
const finishActiveStreamingToolCall = (controller) => {
|
|
1565
|
+
const active = activeStreamingToolCalls.pop();
|
|
1566
|
+
if (active == null) {
|
|
1567
|
+
return;
|
|
1568
|
+
}
|
|
1569
|
+
const { finalJSON, closingDelta } = active.accumulator.finalize();
|
|
1570
|
+
if (closingDelta.length > 0) {
|
|
1571
|
+
controller.enqueue({
|
|
1572
|
+
type: "tool-input-delta",
|
|
1573
|
+
id: active.toolCallId,
|
|
1574
|
+
delta: closingDelta,
|
|
1575
|
+
providerMetadata: active.providerMetadata
|
|
1576
|
+
});
|
|
1577
|
+
}
|
|
1578
|
+
controller.enqueue({
|
|
1579
|
+
type: "tool-input-end",
|
|
1580
|
+
id: active.toolCallId,
|
|
1581
|
+
providerMetadata: active.providerMetadata
|
|
1582
|
+
});
|
|
1583
|
+
controller.enqueue({
|
|
1584
|
+
type: "tool-call",
|
|
1585
|
+
toolCallId: active.toolCallId,
|
|
1586
|
+
toolName: active.toolName,
|
|
1587
|
+
input: finalJSON,
|
|
1588
|
+
providerMetadata: active.providerMetadata
|
|
1589
|
+
});
|
|
1590
|
+
hasToolCalls = true;
|
|
1591
|
+
};
|
|
1531
1592
|
return {
|
|
1532
1593
|
stream: response.pipeThrough(
|
|
1533
1594
|
new TransformStream({
|
|
@@ -1535,7 +1596,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1535
1596
|
controller.enqueue({ type: "stream-start", warnings });
|
|
1536
1597
|
},
|
|
1537
1598
|
transform(chunk, controller) {
|
|
1538
|
-
var
|
|
1599
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
1539
1600
|
if (options.includeRawChunks) {
|
|
1540
1601
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
1541
1602
|
}
|
|
@@ -1548,10 +1609,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1548
1609
|
if (usageMetadata != null) {
|
|
1549
1610
|
usage = usageMetadata;
|
|
1550
1611
|
}
|
|
1551
|
-
|
|
1552
|
-
serviceTier = value.serviceTier;
|
|
1553
|
-
}
|
|
1554
|
-
const candidate = (_a = value.candidates) == null ? void 0 : _a[0];
|
|
1612
|
+
const candidate = (_a2 = value.candidates) == null ? void 0 : _a2[0];
|
|
1555
1613
|
if (candidate == null) {
|
|
1556
1614
|
return;
|
|
1557
1615
|
}
|
|
@@ -1740,7 +1798,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1740
1798
|
const isCompleteCall = part.functionCall.name != null && part.functionCall.args != null && part.functionCall.partialArgs == null;
|
|
1741
1799
|
const isNoArgsCompleteCall = part.functionCall.name != null && part.functionCall.args == null && part.functionCall.partialArgs == null && part.functionCall.willContinue !== true;
|
|
1742
1800
|
if (isStreamingChunk) {
|
|
1743
|
-
if (part.functionCall.name != null
|
|
1801
|
+
if (part.functionCall.name != null) {
|
|
1744
1802
|
const toolCallId = (_i = part.functionCall.id) != null ? _i : generateId2();
|
|
1745
1803
|
const accumulator = new GoogleJSONAccumulator();
|
|
1746
1804
|
activeStreamingToolCalls.push({
|
|
@@ -1756,9 +1814,8 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1756
1814
|
providerMetadata: providerMeta
|
|
1757
1815
|
});
|
|
1758
1816
|
if (part.functionCall.partialArgs != null) {
|
|
1759
|
-
const
|
|
1760
|
-
|
|
1761
|
-
);
|
|
1817
|
+
const partialArgs = part.functionCall.partialArgs;
|
|
1818
|
+
const { textDelta } = accumulator.processPartialArgs(partialArgs);
|
|
1762
1819
|
if (textDelta.length > 0) {
|
|
1763
1820
|
controller.enqueue({
|
|
1764
1821
|
type: "tool-input-delta",
|
|
@@ -1767,12 +1824,14 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1767
1824
|
providerMetadata: providerMeta
|
|
1768
1825
|
});
|
|
1769
1826
|
}
|
|
1827
|
+
if (part.functionCall.willContinue !== true && partialArgs.every((arg) => arg.willContinue !== true)) {
|
|
1828
|
+
finishActiveStreamingToolCall(controller);
|
|
1829
|
+
}
|
|
1770
1830
|
}
|
|
1771
1831
|
} else if (part.functionCall.partialArgs != null && activeStreamingToolCalls.length > 0) {
|
|
1772
1832
|
const active = activeStreamingToolCalls[activeStreamingToolCalls.length - 1];
|
|
1773
|
-
const
|
|
1774
|
-
|
|
1775
|
-
);
|
|
1833
|
+
const partialArgs = part.functionCall.partialArgs;
|
|
1834
|
+
const { textDelta } = active.accumulator.processPartialArgs(partialArgs);
|
|
1776
1835
|
if (textDelta.length > 0) {
|
|
1777
1836
|
controller.enqueue({
|
|
1778
1837
|
type: "tool-input-delta",
|
|
@@ -1781,31 +1840,12 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1781
1840
|
providerMetadata: providerMeta
|
|
1782
1841
|
});
|
|
1783
1842
|
}
|
|
1843
|
+
if (part.functionCall.willContinue !== true && partialArgs.every((arg) => arg.willContinue !== true)) {
|
|
1844
|
+
finishActiveStreamingToolCall(controller);
|
|
1845
|
+
}
|
|
1784
1846
|
}
|
|
1785
1847
|
} else if (isTerminalChunk && activeStreamingToolCalls.length > 0) {
|
|
1786
|
-
|
|
1787
|
-
const { finalJSON, closingDelta } = active.accumulator.finalize();
|
|
1788
|
-
if (closingDelta.length > 0) {
|
|
1789
|
-
controller.enqueue({
|
|
1790
|
-
type: "tool-input-delta",
|
|
1791
|
-
id: active.toolCallId,
|
|
1792
|
-
delta: closingDelta,
|
|
1793
|
-
providerMetadata: active.providerMetadata
|
|
1794
|
-
});
|
|
1795
|
-
}
|
|
1796
|
-
controller.enqueue({
|
|
1797
|
-
type: "tool-input-end",
|
|
1798
|
-
id: active.toolCallId,
|
|
1799
|
-
providerMetadata: active.providerMetadata
|
|
1800
|
-
});
|
|
1801
|
-
controller.enqueue({
|
|
1802
|
-
type: "tool-call",
|
|
1803
|
-
toolCallId: active.toolCallId,
|
|
1804
|
-
toolName: active.toolName,
|
|
1805
|
-
input: finalJSON,
|
|
1806
|
-
providerMetadata: active.providerMetadata
|
|
1807
|
-
});
|
|
1808
|
-
hasToolCalls = true;
|
|
1848
|
+
finishActiveStreamingToolCall(controller);
|
|
1809
1849
|
} else if (isCompleteCall) {
|
|
1810
1850
|
const toolCallId = (_j = part.functionCall.id) != null ? _j : generateId2();
|
|
1811
1851
|
const toolName = part.functionCall.name;
|
|
@@ -2164,8 +2204,7 @@ var responseSchema = (0, import_provider_utils4.lazySchema)(
|
|
|
2164
2204
|
promptFeedback: import_v43.z.object({
|
|
2165
2205
|
blockReason: import_v43.z.string().nullish(),
|
|
2166
2206
|
safetyRatings: import_v43.z.array(getSafetyRatingSchema()).nullish()
|
|
2167
|
-
}).nullish()
|
|
2168
|
-
serviceTier: import_v43.z.string().nullish()
|
|
2207
|
+
}).nullish()
|
|
2169
2208
|
})
|
|
2170
2209
|
)
|
|
2171
2210
|
);
|
|
@@ -2186,8 +2225,7 @@ var chunkSchema = (0, import_provider_utils4.lazySchema)(
|
|
|
2186
2225
|
promptFeedback: import_v43.z.object({
|
|
2187
2226
|
blockReason: import_v43.z.string().nullish(),
|
|
2188
2227
|
safetyRatings: import_v43.z.array(getSafetyRatingSchema()).nullish()
|
|
2189
|
-
}).nullish()
|
|
2190
|
-
serviceTier: import_v43.z.string().nullish()
|
|
2228
|
+
}).nullish()
|
|
2191
2229
|
})
|
|
2192
2230
|
)
|
|
2193
2231
|
);
|