@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/google",
3
- "version": "3.0.70",
3
+ "version": "3.0.71",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -346,16 +346,12 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV3 {
346
346
  providerMetadata: thoughtSignatureMetadata,
347
347
  });
348
348
  }
349
- } else if (
350
- 'functionCall' in part &&
351
- part.functionCall.name != null &&
352
- part.functionCall.args != null
353
- ) {
349
+ } else if ('functionCall' in part && part.functionCall.name != null) {
354
350
  content.push({
355
351
  type: 'tool-call' as const,
356
352
  toolCallId: this.config.generateId(),
357
353
  toolName: part.functionCall.name,
358
- input: JSON.stringify(part.functionCall.args),
354
+ input: JSON.stringify(part.functionCall.args ?? {}),
359
355
  providerMetadata: part.thoughtSignature
360
356
  ? {
361
357
  [providerOptionsName]: {
@@ -819,6 +815,13 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV3 {
819
815
  part.functionCall.name != null &&
820
816
  part.functionCall.args != null &&
821
817
  part.functionCall.partialArgs == null;
818
+ // Single-chunk no-args call: `{ name: 'X' }` with no `args`,
819
+ // `partialArgs`, or `willContinue`. Carries `thoughtSignature`.
820
+ const isNoArgsCompleteCall =
821
+ part.functionCall.name != null &&
822
+ part.functionCall.args == null &&
823
+ part.functionCall.partialArgs == null &&
824
+ part.functionCall.willContinue !== true;
822
825
 
823
826
  if (isStreamingChunk) {
824
827
  if (
@@ -942,6 +945,32 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV3 {
942
945
  providerMetadata: providerMeta,
943
946
  });
944
947
 
948
+ hasToolCalls = true;
949
+ } else if (isNoArgsCompleteCall) {
950
+ const toolCallId = generateId();
951
+ const toolName = part.functionCall.name!;
952
+
953
+ controller.enqueue({
954
+ type: 'tool-input-start',
955
+ id: toolCallId,
956
+ toolName,
957
+ providerMetadata: providerMeta,
958
+ });
959
+
960
+ controller.enqueue({
961
+ type: 'tool-input-end',
962
+ id: toolCallId,
963
+ providerMetadata: providerMeta,
964
+ });
965
+
966
+ controller.enqueue({
967
+ type: 'tool-call',
968
+ toolCallId,
969
+ toolName,
970
+ input: '{}',
971
+ providerMetadata: providerMeta,
972
+ });
973
+
945
974
  hasToolCalls = true;
946
975
  }
947
976
  }