@ai-sdk/google 4.0.0-beta.8 → 4.0.0-beta.82
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 +608 -5
- package/README.md +6 -4
- package/dist/index.d.ts +297 -54
- package/dist/index.js +5409 -640
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +97 -26
- package/dist/internal/index.js +1653 -453
- package/dist/internal/index.js.map +1 -1
- package/docs/{15-google-generative-ai.mdx → 15-google.mdx} +784 -69
- package/package.json +16 -17
- package/src/{convert-google-generative-ai-usage.ts → convert-google-usage.ts} +13 -5
- package/src/convert-json-schema-to-openapi-schema.ts +1 -1
- package/src/convert-to-google-messages.ts +647 -0
- package/src/{google-generative-ai-embedding-options.ts → google-embedding-model-options.ts} +9 -2
- package/src/{google-generative-ai-embedding-model.ts → google-embedding-model.ts} +31 -18
- package/src/google-error.ts +1 -1
- package/src/google-files.ts +225 -0
- package/src/google-image-model-options.ts +35 -0
- package/src/{google-generative-ai-image-model.ts → google-image-model.ts} +116 -65
- package/src/{google-generative-ai-image-settings.ts → google-image-settings.ts} +2 -2
- package/src/google-json-accumulator.ts +371 -0
- package/src/{google-generative-ai-options.ts → google-language-model-options.ts} +50 -5
- package/src/{google-generative-ai-language-model.ts → google-language-model.ts} +691 -217
- package/src/google-prepare-tools.ts +72 -12
- package/src/google-prompt.ts +86 -0
- package/src/google-provider.ts +157 -53
- package/src/google-speech-api.ts +36 -0
- package/src/google-speech-model-options.ts +48 -0
- package/src/google-speech-model.ts +311 -0
- package/src/google-video-model-options.ts +43 -0
- package/src/{google-generative-ai-video-model.ts → google-video-model.ts} +25 -60
- package/src/{google-generative-ai-video-settings.ts → google-video-settings.ts} +2 -1
- package/src/index.ts +40 -9
- package/src/interactions/build-google-interactions-stream-transform.ts +818 -0
- package/src/interactions/cancel-google-interaction.ts +60 -0
- package/src/interactions/convert-google-interactions-usage.ts +47 -0
- package/src/interactions/convert-to-google-interactions-input.ts +557 -0
- package/src/interactions/extract-google-interactions-sources.ts +252 -0
- package/src/interactions/google-interactions-agent.ts +15 -0
- package/src/interactions/google-interactions-api.ts +530 -0
- package/src/interactions/google-interactions-language-model-options.ts +262 -0
- package/src/interactions/google-interactions-language-model.ts +776 -0
- package/src/interactions/google-interactions-prompt.ts +582 -0
- package/src/interactions/google-interactions-provider-metadata.ts +23 -0
- package/src/interactions/map-google-interactions-finish-reason.ts +31 -0
- package/src/interactions/parse-google-interactions-outputs.ts +252 -0
- package/src/interactions/poll-google-interactions.ts +129 -0
- package/src/interactions/prepare-google-interactions-tools.ts +245 -0
- package/src/interactions/stream-google-interactions.ts +242 -0
- package/src/interactions/synthesize-google-interactions-agent-stream.ts +185 -0
- package/src/internal/index.ts +3 -2
- package/src/{map-google-generative-ai-finish-reason.ts → map-google-finish-reason.ts} +3 -3
- package/src/realtime/google-realtime-event-mapper.ts +383 -0
- package/src/realtime/google-realtime-model-options.ts +3 -0
- package/src/realtime/google-realtime-model.ts +160 -0
- package/src/realtime/index.ts +2 -0
- package/src/tool/code-execution.ts +2 -2
- package/src/tool/enterprise-web-search.ts +9 -3
- package/src/tool/file-search.ts +5 -7
- package/src/tool/google-maps.ts +3 -2
- package/src/tool/google-search.ts +11 -12
- package/src/tool/url-context.ts +4 -2
- package/src/tool/vertex-rag-store.ts +9 -6
- package/dist/index.d.mts +0 -384
- package/dist/index.mjs +0 -2519
- package/dist/index.mjs.map +0 -1
- package/dist/internal/index.d.mts +0 -287
- package/dist/internal/index.mjs +0 -1708
- package/dist/internal/index.mjs.map +0 -1
- package/src/convert-to-google-generative-ai-messages.ts +0 -239
- package/src/google-generative-ai-prompt.ts +0 -47
package/dist/internal/index.d.ts
CHANGED
|
@@ -1,32 +1,41 @@
|
|
|
1
1
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
2
|
-
import { Resolvable, FetchFunction, InferSchema } from '@ai-sdk/provider-utils';
|
|
3
|
-
import
|
|
2
|
+
import { WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE, Resolvable, FetchFunction, InferSchema } from '@ai-sdk/provider-utils';
|
|
3
|
+
import * as _ai_sdk_provider from '@ai-sdk/provider';
|
|
4
|
+
import { LanguageModelV4, JSONObject, LanguageModelV4CallOptions, LanguageModelV4GenerateResult, LanguageModelV4StreamResult, SpeechModelV4 } from '@ai-sdk/provider';
|
|
4
5
|
import { z } from 'zod/v4';
|
|
5
6
|
|
|
6
|
-
type
|
|
7
|
+
type GoogleModelId = 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-2.0-flash-lite' | 'gemini-2.0-flash-lite-001' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-image' | 'gemini-2.5-flash-lite' | 'gemini-2.5-flash-preview-tts' | 'gemini-2.5-pro-preview-tts' | 'gemini-2.5-flash-native-audio-latest' | 'gemini-2.5-flash-native-audio-preview-09-2025' | 'gemini-2.5-flash-native-audio-preview-12-2025' | 'gemini-2.5-computer-use-preview-10-2025' | 'gemini-3-pro-preview' | 'gemini-3-pro-image-preview' | 'gemini-3-flash-preview' | 'gemini-3.1-pro-preview' | 'gemini-3.1-pro-preview-customtools' | 'gemini-3.1-flash-image-preview' | 'gemini-3.1-flash-lite-preview' | 'gemini-3.1-flash-tts-preview' | 'gemini-3.5-flash' | 'gemini-pro-latest' | 'gemini-flash-latest' | 'gemini-flash-lite-latest' | 'deep-research-pro-preview-12-2025' | 'deep-research-max-preview-04-2026' | 'deep-research-preview-04-2026' | 'nano-banana-pro-preview' | 'aqa' | 'gemini-robotics-er-1.5-preview' | 'gemma-3-1b-it' | 'gemma-3-4b-it' | 'gemma-3n-e4b-it' | 'gemma-3n-e2b-it' | 'gemma-3-12b-it' | 'gemma-3-27b-it' | (string & {});
|
|
7
8
|
|
|
8
|
-
type
|
|
9
|
+
type GoogleConfig = {
|
|
9
10
|
provider: string;
|
|
10
11
|
baseURL: string;
|
|
11
|
-
headers
|
|
12
|
+
headers?: Resolvable<Record<string, string | undefined>>;
|
|
12
13
|
fetch?: FetchFunction;
|
|
13
14
|
generateId: () => string;
|
|
14
15
|
/**
|
|
15
16
|
* The supported URLs for the model.
|
|
16
17
|
*/
|
|
17
|
-
supportedUrls?: () =>
|
|
18
|
+
supportedUrls?: () => LanguageModelV4['supportedUrls'];
|
|
18
19
|
};
|
|
19
|
-
declare class
|
|
20
|
-
readonly specificationVersion = "
|
|
21
|
-
readonly modelId:
|
|
20
|
+
declare class GoogleLanguageModel implements LanguageModelV4 {
|
|
21
|
+
readonly specificationVersion = "v4";
|
|
22
|
+
readonly modelId: GoogleModelId;
|
|
22
23
|
private readonly config;
|
|
23
24
|
private readonly generateId;
|
|
24
|
-
|
|
25
|
+
static [WORKFLOW_SERIALIZE](model: GoogleLanguageModel): {
|
|
26
|
+
modelId: string;
|
|
27
|
+
config: JSONObject;
|
|
28
|
+
};
|
|
29
|
+
static [WORKFLOW_DESERIALIZE](options: {
|
|
30
|
+
modelId: string;
|
|
31
|
+
config: GoogleConfig;
|
|
32
|
+
}): GoogleLanguageModel;
|
|
33
|
+
constructor(modelId: GoogleModelId, config: GoogleConfig);
|
|
25
34
|
get provider(): string;
|
|
26
35
|
get supportedUrls(): Record<string, RegExp[]> | PromiseLike<Record<string, RegExp[]>>;
|
|
27
36
|
private getArgs;
|
|
28
|
-
doGenerate(options:
|
|
29
|
-
doStream(options:
|
|
37
|
+
doGenerate(options: LanguageModelV4CallOptions): Promise<LanguageModelV4GenerateResult>;
|
|
38
|
+
doStream(options: LanguageModelV4CallOptions): Promise<LanguageModelV4StreamResult>;
|
|
30
39
|
}
|
|
31
40
|
declare const getGroundingMetadataSchema: () => z.ZodObject<{
|
|
32
41
|
webSearchQueries: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
@@ -86,8 +95,18 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
86
95
|
content?: Record<string, never> | {
|
|
87
96
|
parts?: ({
|
|
88
97
|
functionCall: {
|
|
89
|
-
|
|
90
|
-
|
|
98
|
+
id?: string | null | undefined;
|
|
99
|
+
name?: string | null | undefined;
|
|
100
|
+
args?: unknown;
|
|
101
|
+
partialArgs?: {
|
|
102
|
+
jsonPath: string;
|
|
103
|
+
stringValue?: string | null | undefined;
|
|
104
|
+
numberValue?: number | null | undefined;
|
|
105
|
+
boolValue?: boolean | null | undefined;
|
|
106
|
+
nullValue?: unknown;
|
|
107
|
+
willContinue?: boolean | null | undefined;
|
|
108
|
+
}[] | null | undefined;
|
|
109
|
+
willContinue?: boolean | null | undefined;
|
|
91
110
|
};
|
|
92
111
|
thoughtSignature?: string | null | undefined;
|
|
93
112
|
} | {
|
|
@@ -97,6 +116,20 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
97
116
|
};
|
|
98
117
|
thought?: boolean | null | undefined;
|
|
99
118
|
thoughtSignature?: string | null | undefined;
|
|
119
|
+
} | {
|
|
120
|
+
toolCall: {
|
|
121
|
+
toolType: string;
|
|
122
|
+
id: string;
|
|
123
|
+
args?: unknown;
|
|
124
|
+
};
|
|
125
|
+
thoughtSignature?: string | null | undefined;
|
|
126
|
+
} | {
|
|
127
|
+
toolResponse: {
|
|
128
|
+
toolType: string;
|
|
129
|
+
id: string;
|
|
130
|
+
response?: unknown;
|
|
131
|
+
};
|
|
132
|
+
thoughtSignature?: string | null | undefined;
|
|
100
133
|
} | {
|
|
101
134
|
executableCode?: {
|
|
102
135
|
language: string;
|
|
@@ -182,6 +215,15 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
182
215
|
candidatesTokenCount?: number | null | undefined;
|
|
183
216
|
totalTokenCount?: number | null | undefined;
|
|
184
217
|
trafficType?: string | null | undefined;
|
|
218
|
+
serviceTier?: string | null | undefined;
|
|
219
|
+
promptTokensDetails?: {
|
|
220
|
+
modality: string;
|
|
221
|
+
tokenCount: number;
|
|
222
|
+
}[] | null | undefined;
|
|
223
|
+
candidatesTokensDetails?: {
|
|
224
|
+
modality: string;
|
|
225
|
+
tokenCount: number;
|
|
226
|
+
}[] | null | undefined;
|
|
185
227
|
} | null | undefined;
|
|
186
228
|
promptFeedback?: {
|
|
187
229
|
blockReason?: string | null | undefined;
|
|
@@ -201,12 +243,41 @@ type SafetyRatingSchema = NonNullable<InferSchema<typeof responseSchema>['candid
|
|
|
201
243
|
type PromptFeedbackSchema = NonNullable<InferSchema<typeof responseSchema>['promptFeedback']>;
|
|
202
244
|
type UsageMetadataSchema = NonNullable<InferSchema<typeof responseSchema>['usageMetadata']>;
|
|
203
245
|
|
|
246
|
+
type GoogleSpeechModelId = 'gemini-2.5-flash-preview-tts' | 'gemini-2.5-pro-preview-tts' | 'gemini-3.1-flash-tts-preview' | (string & {});
|
|
247
|
+
|
|
248
|
+
interface GoogleSpeechModelConfig {
|
|
249
|
+
provider: string;
|
|
250
|
+
baseURL: string;
|
|
251
|
+
headers?: Resolvable<Record<string, string | undefined>>;
|
|
252
|
+
fetch?: FetchFunction;
|
|
253
|
+
_internal?: {
|
|
254
|
+
currentDate?: () => Date;
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
declare class GoogleSpeechModel implements SpeechModelV4 {
|
|
258
|
+
readonly modelId: GoogleSpeechModelId;
|
|
259
|
+
private readonly config;
|
|
260
|
+
readonly specificationVersion = "v4";
|
|
261
|
+
static [WORKFLOW_SERIALIZE](model: GoogleSpeechModel): {
|
|
262
|
+
modelId: string;
|
|
263
|
+
config: _ai_sdk_provider.JSONObject;
|
|
264
|
+
};
|
|
265
|
+
static [WORKFLOW_DESERIALIZE](options: {
|
|
266
|
+
modelId: GoogleSpeechModelId;
|
|
267
|
+
config: GoogleSpeechModelConfig;
|
|
268
|
+
}): GoogleSpeechModel;
|
|
269
|
+
get provider(): string;
|
|
270
|
+
constructor(modelId: GoogleSpeechModelId, config: GoogleSpeechModelConfig);
|
|
271
|
+
private getArgs;
|
|
272
|
+
doGenerate(options: Parameters<SpeechModelV4['doGenerate']>[0]): Promise<Awaited<ReturnType<SpeechModelV4['doGenerate']>>>;
|
|
273
|
+
}
|
|
274
|
+
|
|
204
275
|
declare const googleTools: {
|
|
205
276
|
/**
|
|
206
277
|
* Creates a Google search tool that gives Google direct access to real-time web content.
|
|
207
278
|
* Must have name "google_search".
|
|
208
279
|
*/
|
|
209
|
-
googleSearch: _ai_sdk_provider_utils.
|
|
280
|
+
googleSearch: _ai_sdk_provider_utils.ProviderExecutedToolFactory<{}, {}, {
|
|
210
281
|
[x: string]: unknown;
|
|
211
282
|
searchTypes?: {
|
|
212
283
|
webSearch?: Record<string, never> | undefined;
|
|
@@ -216,7 +287,7 @@ declare const googleTools: {
|
|
|
216
287
|
startTime: string;
|
|
217
288
|
endTime: string;
|
|
218
289
|
} | undefined;
|
|
219
|
-
}>;
|
|
290
|
+
}, {}>;
|
|
220
291
|
/**
|
|
221
292
|
* Creates an Enterprise Web Search tool for grounding responses using a compliance-focused web index.
|
|
222
293
|
* Designed for highly-regulated industries (finance, healthcare, public sector).
|
|
@@ -227,7 +298,7 @@ declare const googleTools: {
|
|
|
227
298
|
*
|
|
228
299
|
* @see https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/web-grounding-enterprise
|
|
229
300
|
*/
|
|
230
|
-
enterpriseWebSearch: _ai_sdk_provider_utils.
|
|
301
|
+
enterpriseWebSearch: _ai_sdk_provider_utils.ProviderExecutedToolFactory<{}, {}, {}, {}>;
|
|
231
302
|
/**
|
|
232
303
|
* Creates a Google Maps grounding tool that gives the model access to Google Maps data.
|
|
233
304
|
* Must have name "google_maps".
|
|
@@ -235,12 +306,12 @@ declare const googleTools: {
|
|
|
235
306
|
* @see https://ai.google.dev/gemini-api/docs/maps-grounding
|
|
236
307
|
* @see https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/grounding-with-google-maps
|
|
237
308
|
*/
|
|
238
|
-
googleMaps: _ai_sdk_provider_utils.
|
|
309
|
+
googleMaps: _ai_sdk_provider_utils.ProviderExecutedToolFactory<{}, {}, {}, {}>;
|
|
239
310
|
/**
|
|
240
311
|
* Creates a URL context tool that gives Google direct access to real-time web content.
|
|
241
312
|
* Must have name "url_context".
|
|
242
313
|
*/
|
|
243
|
-
urlContext: _ai_sdk_provider_utils.
|
|
314
|
+
urlContext: _ai_sdk_provider_utils.ProviderExecutedToolFactory<{}, {}, {}, {}>;
|
|
244
315
|
/**
|
|
245
316
|
* Enables Retrieval Augmented Generation (RAG) via the Gemini File Search tool.
|
|
246
317
|
* Must have name "file_search".
|
|
@@ -251,12 +322,12 @@ declare const googleTools: {
|
|
|
251
322
|
*
|
|
252
323
|
* @see https://ai.google.dev/gemini-api/docs/file-search
|
|
253
324
|
*/
|
|
254
|
-
fileSearch: _ai_sdk_provider_utils.
|
|
325
|
+
fileSearch: _ai_sdk_provider_utils.ProviderExecutedToolFactory<{}, {}, {
|
|
255
326
|
[x: string]: unknown;
|
|
256
327
|
fileSearchStoreNames: string[];
|
|
257
328
|
topK?: number | undefined;
|
|
258
329
|
metadataFilter?: string | undefined;
|
|
259
|
-
}>;
|
|
330
|
+
}, {}>;
|
|
260
331
|
/**
|
|
261
332
|
* A tool that enables the model to generate and run Python code.
|
|
262
333
|
* Must have name "code_execution".
|
|
@@ -267,21 +338,21 @@ declare const googleTools: {
|
|
|
267
338
|
* @see https://ai.google.dev/gemini-api/docs/code-execution (Google AI)
|
|
268
339
|
* @see https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/code-execution-api (Vertex AI)
|
|
269
340
|
*/
|
|
270
|
-
codeExecution: _ai_sdk_provider_utils.
|
|
341
|
+
codeExecution: _ai_sdk_provider_utils.ProviderExecutedToolFactory<{
|
|
271
342
|
language: string;
|
|
272
343
|
code: string;
|
|
273
344
|
}, {
|
|
274
345
|
outcome: string;
|
|
275
346
|
output: string;
|
|
276
|
-
}, {}>;
|
|
347
|
+
}, {}, {}>;
|
|
277
348
|
/**
|
|
278
349
|
* Creates a Vertex RAG Store tool that enables the model to perform RAG searches against a Vertex RAG Store.
|
|
279
350
|
* Must have name "vertex_rag_store".
|
|
280
351
|
*/
|
|
281
|
-
vertexRagStore: _ai_sdk_provider_utils.
|
|
352
|
+
vertexRagStore: _ai_sdk_provider_utils.ProviderExecutedToolFactory<{}, {}, {
|
|
282
353
|
ragCorpus: string;
|
|
283
354
|
topK?: number;
|
|
284
|
-
}>;
|
|
355
|
+
}, {}>;
|
|
285
356
|
};
|
|
286
357
|
|
|
287
|
-
export {
|
|
358
|
+
export { GoogleLanguageModel, type GoogleModelId, GoogleSpeechModel, type GroundingMetadataSchema, type PromptFeedbackSchema, type SafetyRatingSchema, type UrlContextMetadataSchema, type UsageMetadataSchema, getGroundingMetadataSchema, getUrlContextMetadataSchema, googleTools };
|