@ai-sdk/google 4.0.101 → 4.0.103

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.
@@ -1,4 +1,5 @@
1
1
  import {
2
+ type InferSchema,
2
3
  createProviderExecutedToolFactory,
3
4
  lazySchema,
4
5
  zodSchema,
@@ -6,35 +7,41 @@ import {
6
7
  import { z } from 'zod/v4';
7
8
 
8
9
  /** Tool to retrieve knowledge from the File Search Stores. */
9
- const fileSearchArgsBaseSchema = z.looseObject({
10
- /** The names of the file_search_stores to retrieve from.
11
- * Example: `fileSearchStores/my-file-search-store-123`
12
- */
13
- fileSearchStoreNames: z
14
- .array(z.string())
15
- .describe(
16
- 'The names of the file_search_stores to retrieve from. Example: `fileSearchStores/my-file-search-store-123`',
17
- ),
18
- /** The number of file search retrieval chunks to retrieve. */
19
- topK: z
20
- .number()
21
- .int()
22
- .positive()
23
- .describe('The number of file search retrieval chunks to retrieve.')
24
- .optional(),
10
+ const fileSearchArgsBaseSchema = lazySchema(() =>
11
+ zodSchema(
12
+ z.looseObject({
13
+ /** The names of the file_search_stores to retrieve from.
14
+ * Example: `fileSearchStores/my-file-search-store-123`
15
+ */
16
+ fileSearchStoreNames: z
17
+ .array(z.string())
18
+ .describe(
19
+ 'The names of the file_search_stores to retrieve from. Example: `fileSearchStores/my-file-search-store-123`',
20
+ ),
21
+ /** The number of file search retrieval chunks to retrieve. */
22
+ topK: z
23
+ .number()
24
+ .int()
25
+ .positive()
26
+ .describe('The number of file search retrieval chunks to retrieve.')
27
+ .optional(),
25
28
 
26
- /** Metadata filter to apply to the file search retrieval documents.
27
- * See https://google.aip.dev/160 for the syntax of the filter expression.
28
- */
29
- metadataFilter: z
30
- .string()
31
- .describe(
32
- 'Metadata filter to apply to the file search retrieval documents. See https://google.aip.dev/160 for the syntax of the filter expression.',
33
- )
34
- .optional(),
35
- });
29
+ /** Metadata filter to apply to the file search retrieval documents.
30
+ * See https://google.aip.dev/160 for the syntax of the filter expression.
31
+ */
32
+ metadataFilter: z
33
+ .string()
34
+ .describe(
35
+ 'Metadata filter to apply to the file search retrieval documents. See https://google.aip.dev/160 for the syntax of the filter expression.',
36
+ )
37
+ .optional(),
38
+ }),
39
+ ),
40
+ );
36
41
 
37
- export type GoogleFileSearchToolArgs = z.infer<typeof fileSearchArgsBaseSchema>;
42
+ export type GoogleFileSearchToolArgs = InferSchema<
43
+ typeof fileSearchArgsBaseSchema
44
+ >;
38
45
 
39
46
  export const fileSearch = createProviderExecutedToolFactory<
40
47
  {},
@@ -9,24 +9,25 @@ import { z } from 'zod/v4';
9
9
  // https://ai.google.dev/api/generate-content#GroundingSupport
10
10
  // https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/grounding-with-google-search
11
11
 
12
- export const googleSearchToolArgsBaseSchema = z.looseObject({
13
- searchTypes: z
14
- .object({
15
- webSearch: z.object({}).optional(),
16
- imageSearch: z.object({}).optional(),
17
- })
18
- .optional(),
12
+ export const googleSearchToolArgsBaseSchema = () =>
13
+ z.looseObject({
14
+ searchTypes: z
15
+ .object({
16
+ webSearch: z.object({}).optional(),
17
+ imageSearch: z.object({}).optional(),
18
+ })
19
+ .optional(),
19
20
 
20
- timeRangeFilter: z
21
- .object({
22
- startTime: z.string(),
23
- endTime: z.string(),
24
- })
25
- .optional(),
26
- });
21
+ timeRangeFilter: z
22
+ .object({
23
+ startTime: z.string(),
24
+ endTime: z.string(),
25
+ })
26
+ .optional(),
27
+ });
27
28
 
28
29
  export type GoogleSearchToolArgs = z.infer<
29
- typeof googleSearchToolArgsBaseSchema
30
+ ReturnType<typeof googleSearchToolArgsBaseSchema>
30
31
  >;
31
32
 
32
33
  export const googleSearch = createProviderExecutedToolFactory<
@@ -1,3 +1,8 @@
1
+ import {
2
+ lazySchema,
3
+ zodSchema,
4
+ type InferSchema,
5
+ } from '@ai-sdk/provider-utils';
1
6
  import { z } from 'zod/v4';
2
7
 
3
8
  export type GoogleTranscriptionModelId =
@@ -10,41 +15,45 @@ export type GoogleTranscriptionModelId =
10
15
  * live (`gemini-3.5-transcribe-live`) transcription. Maps onto Google's
11
16
  * `AudioTranscriptionConfig`.
12
17
  */
13
- export const googleTranscriptionModelOptions = z.object({
14
- /**
15
- * BCP-47 language codes providing hints about the languages present in the
16
- * audio. If omitted or empty, defaults to automatic language detection.
17
- */
18
- languageCodes: z.array(z.string()).optional(),
18
+ export const googleTranscriptionModelOptions = lazySchema(() =>
19
+ zodSchema(
20
+ z.object({
21
+ /**
22
+ * BCP-47 language codes providing hints about the languages present in the
23
+ * audio. If omitted or empty, defaults to automatic language detection.
24
+ */
25
+ languageCodes: z.array(z.string()).optional(),
19
26
 
20
- /**
21
- * Custom vocabulary phrases, which bias the speech recognition model
22
- * toward recognizing specific terms.
23
- */
24
- customVocabulary: z.array(z.string()).optional(),
27
+ /**
28
+ * Custom vocabulary phrases, which bias the speech recognition model
29
+ * toward recognizing specific terms.
30
+ */
31
+ customVocabulary: z.array(z.string()).optional(),
25
32
 
26
- /**
27
- * Enables word-level timestamp generation.
28
- */
29
- wordTimestamp: z.boolean().optional(),
33
+ /**
34
+ * Enables word-level timestamp generation.
35
+ */
36
+ wordTimestamp: z.boolean().optional(),
30
37
 
31
- /**
32
- * Enables speaker diarization.
33
- */
34
- diarization: z.boolean().optional(),
38
+ /**
39
+ * Enables speaker diarization.
40
+ */
41
+ diarization: z.boolean().optional(),
35
42
 
36
- /**
37
- * Transcription output formatting mode.
38
- *
39
- * - `VERBATIM` (default): exact literal transcript preserving filler
40
- * words, repetitions, and false starts.
41
- * - `SMART`: cleans up and structures the transcript in real time —
42
- * disfluency removal, inline self-corrections, structured formatting
43
- * (lists, numbers, dates, paragraph breaks), and grammar/casing polish.
44
- */
45
- mode: z.enum(['SMART', 'VERBATIM']).optional(),
46
- });
43
+ /**
44
+ * Transcription output formatting mode.
45
+ *
46
+ * - `VERBATIM` (default): exact literal transcript preserving filler
47
+ * words, repetitions, and false starts.
48
+ * - `SMART`: cleans up and structures the transcript in real time —
49
+ * disfluency removal, inline self-corrections, structured formatting
50
+ * (lists, numbers, dates, paragraph breaks), and grammar/casing polish.
51
+ */
52
+ mode: z.enum(['SMART', 'VERBATIM']).optional(),
53
+ }),
54
+ ),
55
+ );
47
56
 
48
- export type GoogleTranscriptionModelOptions = z.infer<
57
+ export type GoogleTranscriptionModelOptions = InferSchema<
49
58
  typeof googleTranscriptionModelOptions
50
59
  >;
@@ -7,6 +7,8 @@ import {
7
7
  type TranscriptionModelV4,
8
8
  } from '@ai-sdk/provider';
9
9
  import {
10
+ lazySchema,
11
+ zodSchema,
10
12
  combineHeaders,
11
13
  connectToWebSocket,
12
14
  convertToBase64,
@@ -684,33 +686,38 @@ function validateLiveInputAudioFormat(
684
686
  }
685
687
  }
686
688
 
687
- const googleInteractionsWordAnnotationSchema = z.object({
688
- type: z.string().nullish(),
689
- text: z.string().nullish(),
690
- speaker: z.string().nullish(),
691
- start_offset: z.string().nullish(),
692
- end_offset: z.string().nullish(),
693
- });
694
-
695
- const googleInteractionsTranscriptionResponseSchema = z.object({
696
- status: z.string().nullish(),
697
- steps: z
698
- .array(
699
- z.object({
700
- type: z.string().nullish(),
701
- content: z
702
- .array(
703
- z.object({
704
- type: z.string().nullish(),
705
- text: z.string().nullish(),
706
- annotations: z
707
- .array(googleInteractionsWordAnnotationSchema)
708
- .nullish(),
709
- }),
710
- )
711
- .nullish(),
712
- }),
713
- )
714
- .nullish(),
715
- usage: z.record(z.string(), z.json()).nullish(),
716
- });
689
+ const googleInteractionsWordAnnotationSchema = () =>
690
+ z.object({
691
+ type: z.string().nullish(),
692
+ text: z.string().nullish(),
693
+ speaker: z.string().nullish(),
694
+ start_offset: z.string().nullish(),
695
+ end_offset: z.string().nullish(),
696
+ });
697
+
698
+ const googleInteractionsTranscriptionResponseSchema = lazySchema(() =>
699
+ zodSchema(
700
+ z.object({
701
+ status: z.string().nullish(),
702
+ steps: z
703
+ .array(
704
+ z.object({
705
+ type: z.string().nullish(),
706
+ content: z
707
+ .array(
708
+ z.object({
709
+ type: z.string().nullish(),
710
+ text: z.string().nullish(),
711
+ annotations: z
712
+ .array(googleInteractionsWordAnnotationSchema())
713
+ .nullish(),
714
+ }),
715
+ )
716
+ .nullish(),
717
+ }),
718
+ )
719
+ .nullish(),
720
+ usage: z.record(z.string(), z.json()).nullish(),
721
+ }),
722
+ ),
723
+ );