@ai-sdk/google 3.0.72 → 3.0.74

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.
@@ -1581,7 +1581,7 @@ The following optional provider options are available for Google Generative AI e
1581
1581
 
1582
1582
  - **content**: _array_
1583
1583
 
1584
- Optional. Per-value multimodal content parts for embedding non-text content (images, video, PDF, audio). Each entry corresponds to the embedding value at the same index — its parts are merged with the text value in the request. Use `null` for entries that are text-only. The array length must match the number of values being embedded. Each non-null entry is an array of parts, where each part can be either `{ text: string }` or `{ inlineData: { mimeType: string, data: string } }`. Supported by `gemini-embedding-2-preview`.
1584
+ Optional. Per-value multimodal content parts for embedding non-text content (images, video, PDF, audio). Each entry corresponds to the embedding value at the same index — its parts are merged with the text value in the request. Use `null` for entries that are text-only. The array length must match the number of values being embedded. Each non-null entry is an array of parts, where each part can be `{ text: string }`, `{ inlineData: { mimeType: string, data: string } }` for inline base64 data, or `{ fileData: { fileUri: string, mimeType: string } }` to reference remote content via HTTP URL or Google Cloud Storage URI (`gs://...`). Supported by `gemini-embedding-2-preview`.
1585
1585
 
1586
1586
  ### Model Capabilities
1587
1587
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/google",
3
- "version": "3.0.72",
3
+ "version": "3.0.74",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -36,8 +36,8 @@
36
36
  }
37
37
  },
38
38
  "dependencies": {
39
- "@ai-sdk/provider-utils": "4.0.27",
40
- "@ai-sdk/provider": "3.0.10"
39
+ "@ai-sdk/provider": "3.0.10",
40
+ "@ai-sdk/provider-utils": "4.0.27"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/node": "20.17.24",
@@ -57,6 +57,7 @@ function appendToolResultParts(
57
57
  type: string;
58
58
  [key: string]: unknown;
59
59
  }>,
60
+ toolCallId?: string,
60
61
  ): void {
61
62
  const functionResponseParts: GoogleGenerativeAIFunctionResponsePart[] = [];
62
63
  const responseTextParts: string[] = [];
@@ -99,6 +100,7 @@ function appendToolResultParts(
99
100
 
100
101
  parts.push({
101
102
  functionResponse: {
103
+ ...(toolCallId != null ? { id: toolCallId } : {}),
102
104
  name: toolName,
103
105
  response: {
104
106
  name: toolName,
@@ -126,12 +128,14 @@ function appendLegacyToolResultParts(
126
128
  type: string;
127
129
  [key: string]: unknown;
128
130
  }>,
131
+ toolCallId?: string,
129
132
  ): void {
130
133
  for (const contentPart of outputValue) {
131
134
  switch (contentPart.type) {
132
135
  case 'text':
133
136
  parts.push({
134
137
  functionResponse: {
138
+ ...(toolCallId != null ? { id: toolCallId } : {}),
135
139
  name: toolName,
136
140
  response: {
137
141
  name: toolName,
@@ -315,6 +319,9 @@ export function convertToGoogleGenerativeAIMessages(
315
319
 
316
320
  return {
317
321
  functionCall: {
322
+ ...(part.toolCallId != null
323
+ ? { id: part.toolCallId }
324
+ : {}),
318
325
  name: part.toolName,
319
326
  args: part.input,
320
327
  },
@@ -405,13 +412,24 @@ export function convertToGoogleGenerativeAIMessages(
405
412
 
406
413
  if (output.type === 'content') {
407
414
  if (supportsFunctionResponseParts) {
408
- appendToolResultParts(parts, part.toolName, output.value);
415
+ appendToolResultParts(
416
+ parts,
417
+ part.toolName,
418
+ output.value,
419
+ part.toolCallId,
420
+ );
409
421
  } else {
410
- appendLegacyToolResultParts(parts, part.toolName, output.value);
422
+ appendLegacyToolResultParts(
423
+ parts,
424
+ part.toolName,
425
+ output.value,
426
+ part.toolCallId,
427
+ );
411
428
  }
412
429
  } else {
413
430
  parts.push({
414
431
  functionResponse: {
432
+ ...(part.toolCallId != null ? { id: part.toolCallId } : {}),
415
433
  name: part.toolName,
416
434
  response: {
417
435
  name: part.toolName,
@@ -18,6 +18,12 @@ const googleEmbeddingContentPartSchema = z.union([
18
18
  data: z.string(),
19
19
  }),
20
20
  }),
21
+ z.object({
22
+ fileData: z.object({
23
+ fileUri: z.string(),
24
+ mimeType: z.string(),
25
+ }),
26
+ }),
21
27
  ]);
22
28
 
23
29
  export const googleEmbeddingModelOptions = lazySchema(() =>
@@ -349,7 +349,7 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV3 {
349
349
  } else if ('functionCall' in part && part.functionCall.name != null) {
350
350
  content.push({
351
351
  type: 'tool-call' as const,
352
- toolCallId: this.config.generateId(),
352
+ toolCallId: part.functionCall.id ?? this.config.generateId(),
353
353
  toolName: part.functionCall.name,
354
354
  input: JSON.stringify(part.functionCall.args ?? {}),
355
355
  providerMetadata: part.thoughtSignature
@@ -828,7 +828,7 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV3 {
828
828
  part.functionCall.name != null &&
829
829
  part.functionCall.willContinue === true
830
830
  ) {
831
- const toolCallId = generateId();
831
+ const toolCallId = part.functionCall.id ?? generateId();
832
832
  const accumulator = new GoogleJSONAccumulator();
833
833
  activeStreamingToolCalls.push({
834
834
  toolCallId,
@@ -910,7 +910,7 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV3 {
910
910
 
911
911
  hasToolCalls = true;
912
912
  } else if (isCompleteCall) {
913
- const toolCallId = generateId();
913
+ const toolCallId = part.functionCall.id ?? generateId();
914
914
  const toolName = part.functionCall.name!;
915
915
  const args =
916
916
  typeof part.functionCall.args === 'string'
@@ -947,7 +947,7 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV3 {
947
947
 
948
948
  hasToolCalls = true;
949
949
  } else if (isNoArgsCompleteCall) {
950
- const toolCallId = generateId();
950
+ const toolCallId = part.functionCall.id ?? generateId();
951
951
  const toolName = part.functionCall.name!;
952
952
 
953
953
  controller.enqueue({
@@ -1257,6 +1257,7 @@ const getContentSchema = () =>
1257
1257
  // note: order matters since text can be fully empty
1258
1258
  z.object({
1259
1259
  functionCall: z.object({
1260
+ id: z.string().nullish(),
1260
1261
  name: z.string().nullish(),
1261
1262
  args: z.unknown().nullish(),
1262
1263
  partialArgs: z.array(partialArgSchema).nullish(),
@@ -23,9 +23,13 @@ export type GoogleGenerativeAIContent = {
23
23
  export type GoogleGenerativeAIContentPart =
24
24
  | { text: string; thought?: boolean; thoughtSignature?: string }
25
25
  | { inlineData: { mimeType: string; data: string } }
26
- | { functionCall: { name: string; args: unknown }; thoughtSignature?: string }
26
+ | {
27
+ functionCall: { id?: string; name: string; args: unknown };
28
+ thoughtSignature?: string;
29
+ }
27
30
  | {
28
31
  functionResponse: {
32
+ id?: string;
29
33
  name: string;
30
34
  response: unknown;
31
35
  parts?: Array<GoogleGenerativeAIFunctionResponsePart>;