@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.
- package/CHANGELOG.md +26 -0
- package/dist/index.d.ts +10 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +64 -50
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +41 -33
- package/dist/internal/index.js.map +1 -1
- package/docs/15-google.mdx +1 -1
- package/package.json +3 -3
- package/src/continue-google-stream.ts +11 -3
- package/src/google-batch.ts +37 -34
- package/src/google-embedding-model-options.ts +15 -14
- package/src/google-files.ts +1 -11
- package/src/google-image-model-options.ts +1 -1
- package/src/google-language-model.ts +60 -44
- package/src/google-speech-model-options.ts +17 -14
- package/src/google-video-model.ts +34 -27
- package/src/interactions/build-google-interactions-stream-transform.ts +12 -5
- package/src/tool/file-search.ts +34 -27
- package/src/tool/google-search.ts +16 -15
- package/src/transcription/google-transcription-model-options.ts +40 -31
- package/src/transcription/google-transcription-model.ts +37 -30
package/src/tool/file-search.ts
CHANGED
|
@@ -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 =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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 =
|
|
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 =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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 =
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Enables word-level timestamp generation.
|
|
35
|
+
*/
|
|
36
|
+
wordTimestamp: z.boolean().optional(),
|
|
30
37
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Enables speaker diarization.
|
|
40
|
+
*/
|
|
41
|
+
diarization: z.boolean().optional(),
|
|
35
42
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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 =
|
|
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 =
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
.
|
|
699
|
-
z.
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
.
|
|
703
|
-
z.
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
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
|
+
);
|