@ai-sdk/google 4.0.0-beta.2 → 4.0.0-beta.4

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.
@@ -125,6 +125,9 @@ export function convertToGoogleGenerativeAIMessages(
125
125
  mimeType: part.mediaType,
126
126
  data: convertToBase64(part.data),
127
127
  },
128
+ ...(providerOpts?.thought === true
129
+ ? { thought: true }
130
+ : {}),
128
131
  thoughtSignature,
129
132
  };
130
133
  }
@@ -304,17 +304,23 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV3 {
304
304
  : undefined,
305
305
  });
306
306
  } else if ('inlineData' in part) {
307
+ const hasThought = part.thought === true;
308
+ const hasThoughtSignature = !!part.thoughtSignature;
307
309
  content.push({
308
310
  type: 'file' as const,
309
311
  data: part.inlineData.data,
310
312
  mediaType: part.inlineData.mimeType,
311
- providerMetadata: part.thoughtSignature
312
- ? {
313
- [providerOptionsName]: {
314
- thoughtSignature: part.thoughtSignature,
315
- },
316
- }
317
- : undefined,
313
+ providerMetadata:
314
+ hasThought || hasThoughtSignature
315
+ ? {
316
+ [providerOptionsName]: {
317
+ ...(hasThought ? { thought: true } : {}),
318
+ ...(hasThoughtSignature
319
+ ? { thoughtSignature: part.thoughtSignature }
320
+ : {}),
321
+ },
322
+ }
323
+ : undefined,
318
324
  });
319
325
  }
320
326
  }
@@ -590,19 +596,24 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV3 {
590
596
  currentReasoningBlockId = null;
591
597
  }
592
598
 
593
- // Process file parts inline to preserve order with text
594
- const thoughtSignatureMetadata = part.thoughtSignature
595
- ? {
596
- [providerOptionsName]: {
597
- thoughtSignature: part.thoughtSignature,
598
- },
599
- }
600
- : undefined;
599
+ const hasThought = part.thought === true;
600
+ const hasThoughtSignature = !!part.thoughtSignature;
601
+ const fileMeta =
602
+ hasThought || hasThoughtSignature
603
+ ? {
604
+ [providerOptionsName]: {
605
+ ...(hasThought ? { thought: true } : {}),
606
+ ...(hasThoughtSignature
607
+ ? { thoughtSignature: part.thoughtSignature }
608
+ : {}),
609
+ },
610
+ }
611
+ : undefined;
601
612
  controller.enqueue({
602
613
  type: 'file',
603
614
  mediaType: part.inlineData.mimeType,
604
615
  data: part.inlineData.data,
605
- providerMetadata: thoughtSignatureMetadata,
616
+ providerMetadata: fileMeta,
606
617
  });
607
618
  }
608
619
  }
@@ -935,6 +946,7 @@ const getContentSchema = () =>
935
946
  mimeType: z.string(),
936
947
  data: z.string(),
937
948
  }),
949
+ thought: z.boolean().nullish(),
938
950
  thoughtSignature: z.string().nullish(),
939
951
  }),
940
952
  z.object({