@ai-sdk/google 4.0.46 → 4.0.47
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 +8 -0
- package/dist/index.js +63 -59
- package/dist/index.js.map +1 -1
- package/dist/internal/index.js +62 -58
- package/dist/internal/index.js.map +1 -1
- package/package.json +2 -2
- package/src/google-language-model.ts +10 -10
- package/src/interactions/build-google-interactions-stream-transform.ts +10 -6
- package/src/interactions/parse-google-interactions-outputs.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/google",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.47",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@ai-sdk/provider": "4.0.7",
|
|
39
|
-
"@ai-sdk/provider-utils": "5.0.
|
|
39
|
+
"@ai-sdk/provider-utils": "5.0.28"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/node": "22.19.19",
|
|
@@ -466,7 +466,7 @@ export class GoogleLanguageModel implements LanguageModelV4 {
|
|
|
466
466
|
} else if ('functionCall' in part && part.functionCall.name != null) {
|
|
467
467
|
content.push({
|
|
468
468
|
type: 'tool-call' as const,
|
|
469
|
-
toolCallId: part.functionCall.id
|
|
469
|
+
toolCallId: part.functionCall.id || this.config.generateId(),
|
|
470
470
|
toolName: part.functionCall.name,
|
|
471
471
|
input: JSON.stringify(part.functionCall.args ?? {}),
|
|
472
472
|
providerMetadata: part.thoughtSignature
|
|
@@ -489,7 +489,7 @@ export class GoogleLanguageModel implements LanguageModelV4 {
|
|
|
489
489
|
: undefined,
|
|
490
490
|
});
|
|
491
491
|
} else if ('toolCall' in part && part.toolCall) {
|
|
492
|
-
const toolCallId = part.toolCall.id
|
|
492
|
+
const toolCallId = part.toolCall.id || this.config.generateId();
|
|
493
493
|
lastServerToolCallId = toolCallId;
|
|
494
494
|
content.push({
|
|
495
495
|
type: 'tool-call',
|
|
@@ -511,8 +511,8 @@ export class GoogleLanguageModel implements LanguageModelV4 {
|
|
|
511
511
|
});
|
|
512
512
|
} else if ('toolResponse' in part && part.toolResponse) {
|
|
513
513
|
const responseToolCallId =
|
|
514
|
-
lastServerToolCallId
|
|
515
|
-
part.toolResponse.id
|
|
514
|
+
lastServerToolCallId ||
|
|
515
|
+
part.toolResponse.id ||
|
|
516
516
|
this.config.generateId();
|
|
517
517
|
content.push({
|
|
518
518
|
type: 'tool-result',
|
|
@@ -876,7 +876,7 @@ export class GoogleLanguageModel implements LanguageModelV4 {
|
|
|
876
876
|
providerMetadata: fileMeta,
|
|
877
877
|
});
|
|
878
878
|
} else if ('toolCall' in part && part.toolCall) {
|
|
879
|
-
const toolCallId = part.toolCall.id
|
|
879
|
+
const toolCallId = part.toolCall.id || generateId();
|
|
880
880
|
lastServerToolCallId = toolCallId;
|
|
881
881
|
const serverMeta = wrapProviderMetadata({
|
|
882
882
|
...(part.thoughtSignature
|
|
@@ -897,8 +897,8 @@ export class GoogleLanguageModel implements LanguageModelV4 {
|
|
|
897
897
|
});
|
|
898
898
|
} else if ('toolResponse' in part && part.toolResponse) {
|
|
899
899
|
const responseToolCallId =
|
|
900
|
-
lastServerToolCallId
|
|
901
|
-
part.toolResponse.id
|
|
900
|
+
lastServerToolCallId ||
|
|
901
|
+
part.toolResponse.id ||
|
|
902
902
|
generateId();
|
|
903
903
|
const serverMeta = wrapProviderMetadata({
|
|
904
904
|
...(part.thoughtSignature
|
|
@@ -952,7 +952,7 @@ export class GoogleLanguageModel implements LanguageModelV4 {
|
|
|
952
952
|
|
|
953
953
|
if (isStreamingChunk) {
|
|
954
954
|
if (part.functionCall.name != null) {
|
|
955
|
-
const toolCallId = part.functionCall.id
|
|
955
|
+
const toolCallId = part.functionCall.id || generateId();
|
|
956
956
|
const accumulator = new GoogleJSONAccumulator();
|
|
957
957
|
activeStreamingToolCalls.push({
|
|
958
958
|
toolCallId,
|
|
@@ -1021,7 +1021,7 @@ export class GoogleLanguageModel implements LanguageModelV4 {
|
|
|
1021
1021
|
) {
|
|
1022
1022
|
finishActiveStreamingToolCall(controller);
|
|
1023
1023
|
} else if (isCompleteCall) {
|
|
1024
|
-
const toolCallId = part.functionCall.id
|
|
1024
|
+
const toolCallId = part.functionCall.id || generateId();
|
|
1025
1025
|
const toolName = part.functionCall.name!;
|
|
1026
1026
|
const args =
|
|
1027
1027
|
typeof part.functionCall.args === 'string'
|
|
@@ -1058,7 +1058,7 @@ export class GoogleLanguageModel implements LanguageModelV4 {
|
|
|
1058
1058
|
|
|
1059
1059
|
hasToolCalls = true;
|
|
1060
1060
|
} else if (isNoArgsCompleteCall) {
|
|
1061
|
-
const toolCallId = part.functionCall.id
|
|
1061
|
+
const toolCallId = part.functionCall.id || generateId();
|
|
1062
1062
|
const toolName = part.functionCall.name!;
|
|
1063
1063
|
|
|
1064
1064
|
controller.enqueue({
|
|
@@ -335,7 +335,7 @@ export function buildGoogleInteractionsStreamTransform({
|
|
|
335
335
|
}
|
|
336
336
|
}
|
|
337
337
|
} else if (stepType === 'function_call') {
|
|
338
|
-
const toolCallId = step?.id
|
|
338
|
+
const toolCallId = step?.id || blockId;
|
|
339
339
|
const toolName = step?.name ?? 'unknown';
|
|
340
340
|
hasFunctionCall = true;
|
|
341
341
|
const state: Extract<OpenBlockState, { kind: 'function_call' }> = {
|
|
@@ -360,7 +360,7 @@ export function buildGoogleInteractionsStreamTransform({
|
|
|
360
360
|
stepType === 'mcp_server_tool_call'
|
|
361
361
|
? (step?.name ?? 'mcp_server_tool')
|
|
362
362
|
: builtinToolNameFromCallType(stepType);
|
|
363
|
-
const toolCallId = step?.id
|
|
363
|
+
const toolCallId = step?.id || blockId;
|
|
364
364
|
const state: Extract<
|
|
365
365
|
OpenBlockState,
|
|
366
366
|
{ kind: 'builtin_tool_call' }
|
|
@@ -382,7 +382,7 @@ export function buildGoogleInteractionsStreamTransform({
|
|
|
382
382
|
stepType === 'mcp_server_tool_result'
|
|
383
383
|
? (step?.name ?? 'mcp_server_tool')
|
|
384
384
|
: builtinToolNameFromResultType(stepType);
|
|
385
|
-
const callId = step?.call_id
|
|
385
|
+
const callId = step?.call_id || blockId;
|
|
386
386
|
const state: Extract<
|
|
387
387
|
OpenBlockState,
|
|
388
388
|
{ kind: 'builtin_tool_result' }
|
|
@@ -608,7 +608,7 @@ export function buildGoogleInteractionsStreamTransform({
|
|
|
608
608
|
delta: slice,
|
|
609
609
|
});
|
|
610
610
|
}
|
|
611
|
-
if (delta.id != null) {
|
|
611
|
+
if (delta.id != null && delta.id.length > 0) {
|
|
612
612
|
open.toolCallId = delta.id;
|
|
613
613
|
}
|
|
614
614
|
if (delta.signature != null) {
|
|
@@ -619,7 +619,9 @@ export function buildGoogleInteractionsStreamTransform({
|
|
|
619
619
|
open.kind === 'builtin_tool_call' &&
|
|
620
620
|
delta?.type === open.blockType
|
|
621
621
|
) {
|
|
622
|
-
if (delta.id != null
|
|
622
|
+
if (delta.id != null && delta.id.length > 0) {
|
|
623
|
+
open.toolCallId = delta.id;
|
|
624
|
+
}
|
|
623
625
|
if (
|
|
624
626
|
delta.arguments != null &&
|
|
625
627
|
typeof delta.arguments === 'object'
|
|
@@ -636,7 +638,9 @@ export function buildGoogleInteractionsStreamTransform({
|
|
|
636
638
|
open.kind === 'builtin_tool_result' &&
|
|
637
639
|
delta?.type === open.blockType
|
|
638
640
|
) {
|
|
639
|
-
if (delta.call_id != null
|
|
641
|
+
if (delta.call_id != null && delta.call_id.length > 0) {
|
|
642
|
+
open.callId = delta.call_id;
|
|
643
|
+
}
|
|
640
644
|
if (delta.result !== undefined) open.result = delta.result;
|
|
641
645
|
if (delta.is_error != null) open.isError = delta.is_error;
|
|
642
646
|
if (
|
|
@@ -233,7 +233,7 @@ export function parseGoogleInteractionsOutputs({
|
|
|
233
233
|
const input = JSON.stringify(call.arguments ?? {});
|
|
234
234
|
content.push({
|
|
235
235
|
type: 'tool-call',
|
|
236
|
-
toolCallId: call.id
|
|
236
|
+
toolCallId: call.id || generateId(),
|
|
237
237
|
toolName,
|
|
238
238
|
input,
|
|
239
239
|
providerExecuted: true,
|
|
@@ -251,7 +251,7 @@ export function parseGoogleInteractionsOutputs({
|
|
|
251
251
|
: builtinToolNameFromResultType(type);
|
|
252
252
|
content.push({
|
|
253
253
|
type: 'tool-result',
|
|
254
|
-
toolCallId: result.call_id
|
|
254
|
+
toolCallId: result.call_id || generateId(),
|
|
255
255
|
toolName,
|
|
256
256
|
result: (result.result ?? null) as NonNullable<JSONValue>,
|
|
257
257
|
});
|