@ai-sdk/google 4.0.0-beta.9 → 4.0.0-canary.51
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 +354 -4
- package/README.md +6 -4
- package/dist/index.d.ts +97 -54
- package/dist/index.js +1643 -575
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +62 -22
- package/dist/internal/index.js +1261 -449
- package/dist/internal/index.js.map +1 -1
- package/docs/{15-google-generative-ai.mdx → 15-google.mdx} +46 -40
- package/package.json +13 -14
- package/src/{convert-google-generative-ai-usage.ts → convert-google-usage.ts} +11 -4
- package/src/convert-json-schema-to-openapi-schema.ts +1 -1
- package/src/convert-to-google-messages.ts +585 -0
- package/src/{google-generative-ai-embedding-options.ts → google-embedding-model-options.ts} +2 -2
- package/src/{google-generative-ai-embedding-model.ts → google-embedding-model.ts} +28 -15
- package/src/google-error.ts +1 -1
- package/src/google-files.ts +225 -0
- package/src/google-image-model-options.ts +23 -0
- package/src/{google-generative-ai-image-model.ts → google-image-model.ts} +61 -49
- package/src/{google-generative-ai-image-settings.ts → google-image-settings.ts} +2 -2
- package/src/google-json-accumulator.ts +336 -0
- package/src/{google-generative-ai-options.ts → google-language-model-options.ts} +32 -5
- package/src/{google-generative-ai-language-model.ts → google-language-model.ts} +586 -191
- package/src/google-prepare-tools.ts +68 -8
- package/src/google-prompt.ts +82 -0
- package/src/google-provider.ts +56 -47
- package/src/google-video-model-options.ts +43 -0
- package/src/{google-generative-ai-video-model.ts → google-video-model.ts} +11 -50
- package/src/{google-generative-ai-video-settings.ts → google-video-settings.ts} +2 -1
- package/src/index.ts +28 -9
- package/src/internal/index.ts +2 -2
- package/src/{map-google-generative-ai-finish-reason.ts → map-google-finish-reason.ts} +2 -2
- 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 +10 -11
- 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,14 +1,14 @@
|
|
|
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 { LanguageModelV4, LanguageModelV4CallOptions, LanguageModelV4GenerateResult, LanguageModelV4StreamResult } from '@ai-sdk/provider';
|
|
2
|
+
import { WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE, Resolvable, FetchFunction, InferSchema } from '@ai-sdk/provider-utils';
|
|
3
|
+
import { LanguageModelV4, JSONObject, LanguageModelV4CallOptions, LanguageModelV4GenerateResult, LanguageModelV4StreamResult } from '@ai-sdk/provider';
|
|
4
4
|
import { z } from 'zod/v4';
|
|
5
5
|
|
|
6
|
-
type
|
|
6
|
+
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-pro-latest' | 'gemini-flash-latest' | 'gemini-flash-lite-latest' | 'deep-research-pro-preview-12-2025' | '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
7
|
|
|
8
|
-
type
|
|
8
|
+
type GoogleConfig = {
|
|
9
9
|
provider: string;
|
|
10
10
|
baseURL: string;
|
|
11
|
-
headers
|
|
11
|
+
headers?: Resolvable<Record<string, string | undefined>>;
|
|
12
12
|
fetch?: FetchFunction;
|
|
13
13
|
generateId: () => string;
|
|
14
14
|
/**
|
|
@@ -16,12 +16,20 @@ type GoogleGenerativeAIConfig = {
|
|
|
16
16
|
*/
|
|
17
17
|
supportedUrls?: () => LanguageModelV4['supportedUrls'];
|
|
18
18
|
};
|
|
19
|
-
declare class
|
|
19
|
+
declare class GoogleLanguageModel implements LanguageModelV4 {
|
|
20
20
|
readonly specificationVersion = "v4";
|
|
21
|
-
readonly modelId:
|
|
21
|
+
readonly modelId: GoogleModelId;
|
|
22
22
|
private readonly config;
|
|
23
23
|
private readonly generateId;
|
|
24
|
-
|
|
24
|
+
static [WORKFLOW_SERIALIZE](model: GoogleLanguageModel): {
|
|
25
|
+
modelId: string;
|
|
26
|
+
config: JSONObject;
|
|
27
|
+
};
|
|
28
|
+
static [WORKFLOW_DESERIALIZE](options: {
|
|
29
|
+
modelId: string;
|
|
30
|
+
config: GoogleConfig;
|
|
31
|
+
}): GoogleLanguageModel;
|
|
32
|
+
constructor(modelId: GoogleModelId, config: GoogleConfig);
|
|
25
33
|
get provider(): string;
|
|
26
34
|
get supportedUrls(): Record<string, RegExp[]> | PromiseLike<Record<string, RegExp[]>>;
|
|
27
35
|
private getArgs;
|
|
@@ -86,8 +94,17 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
86
94
|
content?: Record<string, never> | {
|
|
87
95
|
parts?: ({
|
|
88
96
|
functionCall: {
|
|
89
|
-
name
|
|
90
|
-
args
|
|
97
|
+
name?: string | null | undefined;
|
|
98
|
+
args?: unknown;
|
|
99
|
+
partialArgs?: {
|
|
100
|
+
jsonPath: string;
|
|
101
|
+
stringValue?: string | null | undefined;
|
|
102
|
+
numberValue?: number | null | undefined;
|
|
103
|
+
boolValue?: boolean | null | undefined;
|
|
104
|
+
nullValue?: unknown;
|
|
105
|
+
willContinue?: boolean | null | undefined;
|
|
106
|
+
}[] | null | undefined;
|
|
107
|
+
willContinue?: boolean | null | undefined;
|
|
91
108
|
};
|
|
92
109
|
thoughtSignature?: string | null | undefined;
|
|
93
110
|
} | {
|
|
@@ -97,6 +114,20 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
97
114
|
};
|
|
98
115
|
thought?: boolean | null | undefined;
|
|
99
116
|
thoughtSignature?: string | null | undefined;
|
|
117
|
+
} | {
|
|
118
|
+
toolCall: {
|
|
119
|
+
toolType: string;
|
|
120
|
+
id: string;
|
|
121
|
+
args?: unknown;
|
|
122
|
+
};
|
|
123
|
+
thoughtSignature?: string | null | undefined;
|
|
124
|
+
} | {
|
|
125
|
+
toolResponse: {
|
|
126
|
+
toolType: string;
|
|
127
|
+
id: string;
|
|
128
|
+
response?: unknown;
|
|
129
|
+
};
|
|
130
|
+
thoughtSignature?: string | null | undefined;
|
|
100
131
|
} | {
|
|
101
132
|
executableCode?: {
|
|
102
133
|
language: string;
|
|
@@ -182,6 +213,14 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
182
213
|
candidatesTokenCount?: number | null | undefined;
|
|
183
214
|
totalTokenCount?: number | null | undefined;
|
|
184
215
|
trafficType?: string | null | undefined;
|
|
216
|
+
promptTokensDetails?: {
|
|
217
|
+
modality: string;
|
|
218
|
+
tokenCount: number;
|
|
219
|
+
}[] | null | undefined;
|
|
220
|
+
candidatesTokensDetails?: {
|
|
221
|
+
modality: string;
|
|
222
|
+
tokenCount: number;
|
|
223
|
+
}[] | null | undefined;
|
|
185
224
|
} | null | undefined;
|
|
186
225
|
promptFeedback?: {
|
|
187
226
|
blockReason?: string | null | undefined;
|
|
@@ -194,6 +233,7 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
194
233
|
blocked?: boolean | null | undefined;
|
|
195
234
|
}[] | null | undefined;
|
|
196
235
|
} | null | undefined;
|
|
236
|
+
serviceTier?: string | null | undefined;
|
|
197
237
|
}>;
|
|
198
238
|
type GroundingMetadataSchema = NonNullable<InferSchema<typeof responseSchema>['candidates'][number]['groundingMetadata']>;
|
|
199
239
|
type UrlContextMetadataSchema = NonNullable<InferSchema<typeof responseSchema>['candidates'][number]['urlContextMetadata']>;
|
|
@@ -206,7 +246,7 @@ declare const googleTools: {
|
|
|
206
246
|
* Creates a Google search tool that gives Google direct access to real-time web content.
|
|
207
247
|
* Must have name "google_search".
|
|
208
248
|
*/
|
|
209
|
-
googleSearch: _ai_sdk_provider_utils.
|
|
249
|
+
googleSearch: _ai_sdk_provider_utils.ProviderExecutedToolFactory<{}, {}, {
|
|
210
250
|
[x: string]: unknown;
|
|
211
251
|
searchTypes?: {
|
|
212
252
|
webSearch?: Record<string, never> | undefined;
|
|
@@ -216,7 +256,7 @@ declare const googleTools: {
|
|
|
216
256
|
startTime: string;
|
|
217
257
|
endTime: string;
|
|
218
258
|
} | undefined;
|
|
219
|
-
}>;
|
|
259
|
+
}, {}>;
|
|
220
260
|
/**
|
|
221
261
|
* Creates an Enterprise Web Search tool for grounding responses using a compliance-focused web index.
|
|
222
262
|
* Designed for highly-regulated industries (finance, healthcare, public sector).
|
|
@@ -227,7 +267,7 @@ declare const googleTools: {
|
|
|
227
267
|
*
|
|
228
268
|
* @see https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/web-grounding-enterprise
|
|
229
269
|
*/
|
|
230
|
-
enterpriseWebSearch: _ai_sdk_provider_utils.
|
|
270
|
+
enterpriseWebSearch: _ai_sdk_provider_utils.ProviderExecutedToolFactory<{}, {}, {}, {}>;
|
|
231
271
|
/**
|
|
232
272
|
* Creates a Google Maps grounding tool that gives the model access to Google Maps data.
|
|
233
273
|
* Must have name "google_maps".
|
|
@@ -235,12 +275,12 @@ declare const googleTools: {
|
|
|
235
275
|
* @see https://ai.google.dev/gemini-api/docs/maps-grounding
|
|
236
276
|
* @see https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/grounding-with-google-maps
|
|
237
277
|
*/
|
|
238
|
-
googleMaps: _ai_sdk_provider_utils.
|
|
278
|
+
googleMaps: _ai_sdk_provider_utils.ProviderExecutedToolFactory<{}, {}, {}, {}>;
|
|
239
279
|
/**
|
|
240
280
|
* Creates a URL context tool that gives Google direct access to real-time web content.
|
|
241
281
|
* Must have name "url_context".
|
|
242
282
|
*/
|
|
243
|
-
urlContext: _ai_sdk_provider_utils.
|
|
283
|
+
urlContext: _ai_sdk_provider_utils.ProviderExecutedToolFactory<{}, {}, {}, {}>;
|
|
244
284
|
/**
|
|
245
285
|
* Enables Retrieval Augmented Generation (RAG) via the Gemini File Search tool.
|
|
246
286
|
* Must have name "file_search".
|
|
@@ -251,12 +291,12 @@ declare const googleTools: {
|
|
|
251
291
|
*
|
|
252
292
|
* @see https://ai.google.dev/gemini-api/docs/file-search
|
|
253
293
|
*/
|
|
254
|
-
fileSearch: _ai_sdk_provider_utils.
|
|
294
|
+
fileSearch: _ai_sdk_provider_utils.ProviderExecutedToolFactory<{}, {}, {
|
|
255
295
|
[x: string]: unknown;
|
|
256
296
|
fileSearchStoreNames: string[];
|
|
257
297
|
topK?: number | undefined;
|
|
258
298
|
metadataFilter?: string | undefined;
|
|
259
|
-
}>;
|
|
299
|
+
}, {}>;
|
|
260
300
|
/**
|
|
261
301
|
* A tool that enables the model to generate and run Python code.
|
|
262
302
|
* Must have name "code_execution".
|
|
@@ -267,21 +307,21 @@ declare const googleTools: {
|
|
|
267
307
|
* @see https://ai.google.dev/gemini-api/docs/code-execution (Google AI)
|
|
268
308
|
* @see https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/code-execution-api (Vertex AI)
|
|
269
309
|
*/
|
|
270
|
-
codeExecution: _ai_sdk_provider_utils.
|
|
310
|
+
codeExecution: _ai_sdk_provider_utils.ProviderExecutedToolFactory<{
|
|
271
311
|
language: string;
|
|
272
312
|
code: string;
|
|
273
313
|
}, {
|
|
274
314
|
outcome: string;
|
|
275
315
|
output: string;
|
|
276
|
-
}, {}>;
|
|
316
|
+
}, {}, {}>;
|
|
277
317
|
/**
|
|
278
318
|
* Creates a Vertex RAG Store tool that enables the model to perform RAG searches against a Vertex RAG Store.
|
|
279
319
|
* Must have name "vertex_rag_store".
|
|
280
320
|
*/
|
|
281
|
-
vertexRagStore: _ai_sdk_provider_utils.
|
|
321
|
+
vertexRagStore: _ai_sdk_provider_utils.ProviderExecutedToolFactory<{}, {}, {
|
|
282
322
|
ragCorpus: string;
|
|
283
323
|
topK?: number;
|
|
284
|
-
}>;
|
|
324
|
+
}, {}>;
|
|
285
325
|
};
|
|
286
326
|
|
|
287
|
-
export {
|
|
327
|
+
export { GoogleLanguageModel, type GoogleModelId, type GroundingMetadataSchema, type PromptFeedbackSchema, type SafetyRatingSchema, type UrlContextMetadataSchema, type UsageMetadataSchema, getGroundingMetadataSchema, getUrlContextMetadataSchema, googleTools };
|