@ai-sdk/google 2.1.0-beta.1 → 2.1.0-beta.11
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 +83 -0
- package/dist/index.d.mts +20 -12
- package/dist/index.d.ts +20 -12
- package/dist/index.js +65 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +66 -29
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +7 -7
- package/dist/internal/index.d.ts +7 -7
- package/dist/internal/index.js +47 -18
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +47 -18
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,88 @@
|
|
1
1
|
# @ai-sdk/google
|
2
2
|
|
3
|
+
## 2.1.0-beta.11
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 9a728c8: support latest gemini model id
|
8
|
+
|
9
|
+
## 2.1.0-beta.10
|
10
|
+
|
11
|
+
### Patch Changes
|
12
|
+
|
13
|
+
- e8109d3: feat: tool execution approval
|
14
|
+
- Updated dependencies [046aa3b]
|
15
|
+
- Updated dependencies [e8109d3]
|
16
|
+
- @ai-sdk/provider@2.1.0-beta.5
|
17
|
+
- @ai-sdk/provider-utils@3.1.0-beta.7
|
18
|
+
|
19
|
+
## 2.1.0-beta.9
|
20
|
+
|
21
|
+
### Patch Changes
|
22
|
+
|
23
|
+
- 0adc679: feat(provider): shared spec v3
|
24
|
+
- Updated dependencies [0adc679]
|
25
|
+
- Updated dependencies [2b0caef]
|
26
|
+
- @ai-sdk/provider-utils@3.1.0-beta.6
|
27
|
+
- @ai-sdk/provider@2.1.0-beta.4
|
28
|
+
|
29
|
+
## 2.1.0-beta.8
|
30
|
+
|
31
|
+
### Patch Changes
|
32
|
+
|
33
|
+
- 7728ac5: The mediaResolution option has been added and is now passed to the Google API.
|
34
|
+
|
35
|
+
## 2.1.0-beta.7
|
36
|
+
|
37
|
+
### Patch Changes
|
38
|
+
|
39
|
+
- 8dac895: feat: `LanguageModelV3`
|
40
|
+
- 10c1322: fix: moved dependency `@ai-sdk/test-server` to devDependencies
|
41
|
+
- Updated dependencies [8dac895]
|
42
|
+
- @ai-sdk/provider-utils@3.1.0-beta.5
|
43
|
+
- @ai-sdk/provider@2.1.0-beta.3
|
44
|
+
|
45
|
+
## 2.1.0-beta.6
|
46
|
+
|
47
|
+
### Patch Changes
|
48
|
+
|
49
|
+
- e833473: chore (provider/google): Add preview modelIds for gemini 2.5 flash and lite
|
50
|
+
|
51
|
+
## 2.1.0-beta.5
|
52
|
+
|
53
|
+
### Patch Changes
|
54
|
+
|
55
|
+
- 4616b86: chore: update zod peer depenedency version
|
56
|
+
- Updated dependencies [4616b86]
|
57
|
+
- @ai-sdk/provider-utils@3.1.0-beta.4
|
58
|
+
|
59
|
+
## 2.1.0-beta.4
|
60
|
+
|
61
|
+
### Patch Changes
|
62
|
+
|
63
|
+
- ed329cb: feat: `Provider-V3`
|
64
|
+
- 522f6b8: feat: `ImageModelV3`
|
65
|
+
- Updated dependencies [ed329cb]
|
66
|
+
- Updated dependencies [522f6b8]
|
67
|
+
- @ai-sdk/provider@2.1.0-beta.2
|
68
|
+
- @ai-sdk/provider-utils@3.1.0-beta.3
|
69
|
+
|
70
|
+
## 2.1.0-beta.3
|
71
|
+
|
72
|
+
### Patch Changes
|
73
|
+
|
74
|
+
- 0c4822d: feat: `EmbeddingModelV3`
|
75
|
+
- 1cad0ab: feat: add provider version to user-agent header
|
76
|
+
- Updated dependencies [0c4822d]
|
77
|
+
- @ai-sdk/provider@2.1.0-beta.1
|
78
|
+
- @ai-sdk/provider-utils@3.1.0-beta.2
|
79
|
+
|
80
|
+
## 2.1.0-beta.2
|
81
|
+
|
82
|
+
### Patch Changes
|
83
|
+
|
84
|
+
- 7dea60e: add promptFeedback outputs
|
85
|
+
|
3
86
|
## 2.1.0-beta.1
|
4
87
|
|
5
88
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { z } from 'zod/v4';
|
2
|
-
import {
|
2
|
+
import { ProviderV3, LanguageModelV3, ImageModelV3, EmbeddingModelV3 } from '@ai-sdk/provider';
|
3
3
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
4
4
|
import { FetchFunction } from '@ai-sdk/provider-utils';
|
5
5
|
|
@@ -12,7 +12,7 @@ declare const googleErrorDataSchema: z.ZodObject<{
|
|
12
12
|
}, z.core.$strip>;
|
13
13
|
type GoogleErrorData = z.infer<typeof googleErrorDataSchema>;
|
14
14
|
|
15
|
-
type GoogleGenerativeAIModelId = 'gemini-1.5-flash' | 'gemini-1.5-flash-latest' | 'gemini-1.5-flash-001' | 'gemini-1.5-flash-002' | 'gemini-1.5-flash-8b' | 'gemini-1.5-flash-8b-latest' | 'gemini-1.5-flash-8b-001' | 'gemini-1.5-pro' | 'gemini-1.5-pro-latest' | 'gemini-1.5-pro-001' | 'gemini-1.5-pro-002' | 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-2.0-flash-live-001' | 'gemini-2.0-flash-lite' | 'gemini-2.0-pro-exp-02-05' | 'gemini-2.0-flash-thinking-exp-01-21' | 'gemini-2.0-flash-exp' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-lite' | 'gemini-2.5-flash-
|
15
|
+
type GoogleGenerativeAIModelId = 'gemini-1.5-flash' | 'gemini-1.5-flash-latest' | 'gemini-1.5-flash-001' | 'gemini-1.5-flash-002' | 'gemini-1.5-flash-8b' | 'gemini-1.5-flash-8b-latest' | 'gemini-1.5-flash-8b-001' | 'gemini-1.5-pro' | 'gemini-1.5-pro-latest' | 'gemini-1.5-pro-001' | 'gemini-1.5-pro-002' | 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-2.0-flash-live-001' | 'gemini-2.0-flash-lite' | 'gemini-2.0-pro-exp-02-05' | 'gemini-2.0-flash-thinking-exp-01-21' | 'gemini-2.0-flash-exp' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-image-preview' | 'gemini-2.5-flash-lite' | 'gemini-2.5-flash-lite-preview-09-2025' | 'gemini-2.5-flash-preview-04-17' | 'gemini-2.5-flash-preview-09-2025' | 'gemini-pro-latest' | 'gemini-flash-latest' | 'gemini-flash-lite-latest' | 'gemini-2.5-pro-exp-03-25' | 'gemini-exp-1206' | 'gemma-3-12b-it' | 'gemma-3-27b-it' | (string & {});
|
16
16
|
declare const googleGenerativeAIProviderOptions: z.ZodObject<{
|
17
17
|
responseModalities: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
18
18
|
TEXT: "TEXT";
|
@@ -52,6 +52,12 @@ declare const googleGenerativeAIProviderOptions: z.ZodObject<{
|
|
52
52
|
}>>;
|
53
53
|
audioTimestamp: z.ZodOptional<z.ZodBoolean>;
|
54
54
|
labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
55
|
+
mediaResolution: z.ZodOptional<z.ZodEnum<{
|
56
|
+
MEDIA_RESOLUTION_UNSPECIFIED: "MEDIA_RESOLUTION_UNSPECIFIED";
|
57
|
+
MEDIA_RESOLUTION_LOW: "MEDIA_RESOLUTION_LOW";
|
58
|
+
MEDIA_RESOLUTION_MEDIUM: "MEDIA_RESOLUTION_MEDIUM";
|
59
|
+
MEDIA_RESOLUTION_HIGH: "MEDIA_RESOLUTION_HIGH";
|
60
|
+
}>>;
|
55
61
|
}, z.core.$strip>;
|
56
62
|
type GoogleGenerativeAIProviderOptions = z.infer<typeof googleGenerativeAIProviderOptions>;
|
57
63
|
|
@@ -186,24 +192,24 @@ declare const googleTools: {
|
|
186
192
|
}, {}>;
|
187
193
|
};
|
188
194
|
|
189
|
-
interface GoogleGenerativeAIProvider extends
|
190
|
-
(modelId: GoogleGenerativeAIModelId):
|
191
|
-
languageModel(modelId: GoogleGenerativeAIModelId):
|
192
|
-
chat(modelId: GoogleGenerativeAIModelId):
|
195
|
+
interface GoogleGenerativeAIProvider extends ProviderV3 {
|
196
|
+
(modelId: GoogleGenerativeAIModelId): LanguageModelV3;
|
197
|
+
languageModel(modelId: GoogleGenerativeAIModelId): LanguageModelV3;
|
198
|
+
chat(modelId: GoogleGenerativeAIModelId): LanguageModelV3;
|
193
199
|
/**
|
194
200
|
Creates a model for image generation.
|
195
201
|
*/
|
196
|
-
image(modelId: GoogleGenerativeAIImageModelId, settings?: GoogleGenerativeAIImageSettings):
|
202
|
+
image(modelId: GoogleGenerativeAIImageModelId, settings?: GoogleGenerativeAIImageSettings): ImageModelV3;
|
197
203
|
/**
|
198
204
|
* @deprecated Use `chat()` instead.
|
199
205
|
*/
|
200
|
-
generativeAI(modelId: GoogleGenerativeAIModelId):
|
206
|
+
generativeAI(modelId: GoogleGenerativeAIModelId): LanguageModelV3;
|
201
207
|
/**
|
202
208
|
@deprecated Use `textEmbedding()` instead.
|
203
209
|
*/
|
204
|
-
embedding(modelId: GoogleGenerativeAIEmbeddingModelId):
|
205
|
-
textEmbedding(modelId: GoogleGenerativeAIEmbeddingModelId):
|
206
|
-
textEmbeddingModel(modelId: GoogleGenerativeAIEmbeddingModelId):
|
210
|
+
embedding(modelId: GoogleGenerativeAIEmbeddingModelId): EmbeddingModelV3<string>;
|
211
|
+
textEmbedding(modelId: GoogleGenerativeAIEmbeddingModelId): EmbeddingModelV3<string>;
|
212
|
+
textEmbeddingModel(modelId: GoogleGenerativeAIEmbeddingModelId): EmbeddingModelV3<string>;
|
207
213
|
tools: typeof googleTools;
|
208
214
|
}
|
209
215
|
interface GoogleGenerativeAIProviderSettings {
|
@@ -240,4 +246,6 @@ Default Google Generative AI provider instance.
|
|
240
246
|
*/
|
241
247
|
declare const google: GoogleGenerativeAIProvider;
|
242
248
|
|
243
|
-
|
249
|
+
declare const VERSION: string;
|
250
|
+
|
251
|
+
export { type GoogleErrorData, type GoogleGenerativeAIEmbeddingProviderOptions, type GoogleGenerativeAIImageProviderOptions, type GoogleGenerativeAIProvider, type GoogleGenerativeAIProviderMetadata, type GoogleGenerativeAIProviderOptions, type GoogleGenerativeAIProviderSettings, VERSION, createGoogleGenerativeAI, google };
|
package/dist/index.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { z } from 'zod/v4';
|
2
|
-
import {
|
2
|
+
import { ProviderV3, LanguageModelV3, ImageModelV3, EmbeddingModelV3 } from '@ai-sdk/provider';
|
3
3
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
4
4
|
import { FetchFunction } from '@ai-sdk/provider-utils';
|
5
5
|
|
@@ -12,7 +12,7 @@ declare const googleErrorDataSchema: z.ZodObject<{
|
|
12
12
|
}, z.core.$strip>;
|
13
13
|
type GoogleErrorData = z.infer<typeof googleErrorDataSchema>;
|
14
14
|
|
15
|
-
type GoogleGenerativeAIModelId = 'gemini-1.5-flash' | 'gemini-1.5-flash-latest' | 'gemini-1.5-flash-001' | 'gemini-1.5-flash-002' | 'gemini-1.5-flash-8b' | 'gemini-1.5-flash-8b-latest' | 'gemini-1.5-flash-8b-001' | 'gemini-1.5-pro' | 'gemini-1.5-pro-latest' | 'gemini-1.5-pro-001' | 'gemini-1.5-pro-002' | 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-2.0-flash-live-001' | 'gemini-2.0-flash-lite' | 'gemini-2.0-pro-exp-02-05' | 'gemini-2.0-flash-thinking-exp-01-21' | 'gemini-2.0-flash-exp' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-lite' | 'gemini-2.5-flash-
|
15
|
+
type GoogleGenerativeAIModelId = 'gemini-1.5-flash' | 'gemini-1.5-flash-latest' | 'gemini-1.5-flash-001' | 'gemini-1.5-flash-002' | 'gemini-1.5-flash-8b' | 'gemini-1.5-flash-8b-latest' | 'gemini-1.5-flash-8b-001' | 'gemini-1.5-pro' | 'gemini-1.5-pro-latest' | 'gemini-1.5-pro-001' | 'gemini-1.5-pro-002' | 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-2.0-flash-live-001' | 'gemini-2.0-flash-lite' | 'gemini-2.0-pro-exp-02-05' | 'gemini-2.0-flash-thinking-exp-01-21' | 'gemini-2.0-flash-exp' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-image-preview' | 'gemini-2.5-flash-lite' | 'gemini-2.5-flash-lite-preview-09-2025' | 'gemini-2.5-flash-preview-04-17' | 'gemini-2.5-flash-preview-09-2025' | 'gemini-pro-latest' | 'gemini-flash-latest' | 'gemini-flash-lite-latest' | 'gemini-2.5-pro-exp-03-25' | 'gemini-exp-1206' | 'gemma-3-12b-it' | 'gemma-3-27b-it' | (string & {});
|
16
16
|
declare const googleGenerativeAIProviderOptions: z.ZodObject<{
|
17
17
|
responseModalities: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
18
18
|
TEXT: "TEXT";
|
@@ -52,6 +52,12 @@ declare const googleGenerativeAIProviderOptions: z.ZodObject<{
|
|
52
52
|
}>>;
|
53
53
|
audioTimestamp: z.ZodOptional<z.ZodBoolean>;
|
54
54
|
labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
55
|
+
mediaResolution: z.ZodOptional<z.ZodEnum<{
|
56
|
+
MEDIA_RESOLUTION_UNSPECIFIED: "MEDIA_RESOLUTION_UNSPECIFIED";
|
57
|
+
MEDIA_RESOLUTION_LOW: "MEDIA_RESOLUTION_LOW";
|
58
|
+
MEDIA_RESOLUTION_MEDIUM: "MEDIA_RESOLUTION_MEDIUM";
|
59
|
+
MEDIA_RESOLUTION_HIGH: "MEDIA_RESOLUTION_HIGH";
|
60
|
+
}>>;
|
55
61
|
}, z.core.$strip>;
|
56
62
|
type GoogleGenerativeAIProviderOptions = z.infer<typeof googleGenerativeAIProviderOptions>;
|
57
63
|
|
@@ -186,24 +192,24 @@ declare const googleTools: {
|
|
186
192
|
}, {}>;
|
187
193
|
};
|
188
194
|
|
189
|
-
interface GoogleGenerativeAIProvider extends
|
190
|
-
(modelId: GoogleGenerativeAIModelId):
|
191
|
-
languageModel(modelId: GoogleGenerativeAIModelId):
|
192
|
-
chat(modelId: GoogleGenerativeAIModelId):
|
195
|
+
interface GoogleGenerativeAIProvider extends ProviderV3 {
|
196
|
+
(modelId: GoogleGenerativeAIModelId): LanguageModelV3;
|
197
|
+
languageModel(modelId: GoogleGenerativeAIModelId): LanguageModelV3;
|
198
|
+
chat(modelId: GoogleGenerativeAIModelId): LanguageModelV3;
|
193
199
|
/**
|
194
200
|
Creates a model for image generation.
|
195
201
|
*/
|
196
|
-
image(modelId: GoogleGenerativeAIImageModelId, settings?: GoogleGenerativeAIImageSettings):
|
202
|
+
image(modelId: GoogleGenerativeAIImageModelId, settings?: GoogleGenerativeAIImageSettings): ImageModelV3;
|
197
203
|
/**
|
198
204
|
* @deprecated Use `chat()` instead.
|
199
205
|
*/
|
200
|
-
generativeAI(modelId: GoogleGenerativeAIModelId):
|
206
|
+
generativeAI(modelId: GoogleGenerativeAIModelId): LanguageModelV3;
|
201
207
|
/**
|
202
208
|
@deprecated Use `textEmbedding()` instead.
|
203
209
|
*/
|
204
|
-
embedding(modelId: GoogleGenerativeAIEmbeddingModelId):
|
205
|
-
textEmbedding(modelId: GoogleGenerativeAIEmbeddingModelId):
|
206
|
-
textEmbeddingModel(modelId: GoogleGenerativeAIEmbeddingModelId):
|
210
|
+
embedding(modelId: GoogleGenerativeAIEmbeddingModelId): EmbeddingModelV3<string>;
|
211
|
+
textEmbedding(modelId: GoogleGenerativeAIEmbeddingModelId): EmbeddingModelV3<string>;
|
212
|
+
textEmbeddingModel(modelId: GoogleGenerativeAIEmbeddingModelId): EmbeddingModelV3<string>;
|
207
213
|
tools: typeof googleTools;
|
208
214
|
}
|
209
215
|
interface GoogleGenerativeAIProviderSettings {
|
@@ -240,4 +246,6 @@ Default Google Generative AI provider instance.
|
|
240
246
|
*/
|
241
247
|
declare const google: GoogleGenerativeAIProvider;
|
242
248
|
|
243
|
-
|
249
|
+
declare const VERSION: string;
|
250
|
+
|
251
|
+
export { type GoogleErrorData, type GoogleGenerativeAIEmbeddingProviderOptions, type GoogleGenerativeAIImageProviderOptions, type GoogleGenerativeAIProvider, type GoogleGenerativeAIProviderMetadata, type GoogleGenerativeAIProviderOptions, type GoogleGenerativeAIProviderSettings, VERSION, createGoogleGenerativeAI, google };
|
package/dist/index.js
CHANGED
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
20
20
|
// src/index.ts
|
21
21
|
var src_exports = {};
|
22
22
|
__export(src_exports, {
|
23
|
+
VERSION: () => VERSION,
|
23
24
|
createGoogleGenerativeAI: () => createGoogleGenerativeAI,
|
24
25
|
google: () => google
|
25
26
|
});
|
@@ -28,6 +29,9 @@ module.exports = __toCommonJS(src_exports);
|
|
28
29
|
// src/google-provider.ts
|
29
30
|
var import_provider_utils9 = require("@ai-sdk/provider-utils");
|
30
31
|
|
32
|
+
// src/version.ts
|
33
|
+
var VERSION = true ? "2.1.0-beta.11" : "0.0.0-test";
|
34
|
+
|
31
35
|
// src/google-generative-ai-embedding-model.ts
|
32
36
|
var import_provider = require("@ai-sdk/provider");
|
33
37
|
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
@@ -83,7 +87,7 @@ var googleGenerativeAIEmbeddingProviderOptions = import_v42.z.object({
|
|
83
87
|
// src/google-generative-ai-embedding-model.ts
|
84
88
|
var GoogleGenerativeAIEmbeddingModel = class {
|
85
89
|
constructor(modelId, config) {
|
86
|
-
this.specificationVersion = "
|
90
|
+
this.specificationVersion = "v3";
|
87
91
|
this.maxEmbeddingsPerCall = 2048;
|
88
92
|
this.supportsParallelCalls = true;
|
89
93
|
this.modelId = modelId;
|
@@ -282,7 +286,7 @@ function isEmptyObjectSchema(jsonSchema) {
|
|
282
286
|
var import_provider2 = require("@ai-sdk/provider");
|
283
287
|
var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
284
288
|
function convertToGoogleGenerativeAIMessages(prompt, options) {
|
285
|
-
var _a;
|
289
|
+
var _a, _b;
|
286
290
|
const systemInstructionParts = [];
|
287
291
|
const contents = [];
|
288
292
|
let systemMessagesAllowed = true;
|
@@ -334,12 +338,12 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
334
338
|
contents.push({
|
335
339
|
role: "model",
|
336
340
|
parts: content.map((part) => {
|
337
|
-
var _a2,
|
341
|
+
var _a2, _b2, _c, _d, _e, _f;
|
338
342
|
switch (part.type) {
|
339
343
|
case "text": {
|
340
344
|
return part.text.length === 0 ? void 0 : {
|
341
345
|
text: part.text,
|
342
|
-
thoughtSignature: (
|
346
|
+
thoughtSignature: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2.google) == null ? void 0 : _b2.thoughtSignature
|
343
347
|
};
|
344
348
|
}
|
345
349
|
case "reasoning": {
|
@@ -424,7 +428,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
424
428
|
name: part.toolName,
|
425
429
|
response: {
|
426
430
|
name: part.toolName,
|
427
|
-
content: output.value
|
431
|
+
content: output.type === "execution-denied" ? (_b = output.reason) != null ? _b : "Tool execution denied." : output.value
|
428
432
|
}
|
429
433
|
}
|
430
434
|
});
|
@@ -518,7 +522,18 @@ var googleGenerativeAIProviderOptions = import_v44.z.object({
|
|
518
522
|
*
|
519
523
|
* https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/add-labels-to-api-calls
|
520
524
|
*/
|
521
|
-
labels: import_v44.z.record(import_v44.z.string(), import_v44.z.string()).optional()
|
525
|
+
labels: import_v44.z.record(import_v44.z.string(), import_v44.z.string()).optional(),
|
526
|
+
/**
|
527
|
+
* Optional. If specified, the media resolution specified will be used.
|
528
|
+
*
|
529
|
+
* https://ai.google.dev/api/generate-content#MediaResolution
|
530
|
+
*/
|
531
|
+
mediaResolution: import_v44.z.enum([
|
532
|
+
"MEDIA_RESOLUTION_UNSPECIFIED",
|
533
|
+
"MEDIA_RESOLUTION_LOW",
|
534
|
+
"MEDIA_RESOLUTION_MEDIUM",
|
535
|
+
"MEDIA_RESOLUTION_HIGH"
|
536
|
+
]).optional()
|
522
537
|
});
|
523
538
|
|
524
539
|
// src/google-prepare-tools.ts
|
@@ -531,7 +546,12 @@ function prepareTools({
|
|
531
546
|
var _a;
|
532
547
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
533
548
|
const toolWarnings = [];
|
534
|
-
const
|
549
|
+
const isLatest = [
|
550
|
+
"gemini-flash-latest",
|
551
|
+
"gemini-flash-lite-latest",
|
552
|
+
"gemini-pro-latest"
|
553
|
+
].some((id) => id === modelId);
|
554
|
+
const isGemini2 = modelId.includes("gemini-2") || isLatest;
|
535
555
|
const supportsDynamicRetrieval = modelId.includes("gemini-1.5-flash") && !modelId.includes("-8b");
|
536
556
|
if (tools == null) {
|
537
557
|
return { tools: void 0, toolConfig: void 0, toolWarnings };
|
@@ -751,7 +771,7 @@ var urlContext = (0, import_provider_utils5.createProviderDefinedToolFactory)({
|
|
751
771
|
// src/google-generative-ai-language-model.ts
|
752
772
|
var GoogleGenerativeAILanguageModel = class {
|
753
773
|
constructor(modelId, config) {
|
754
|
-
this.specificationVersion = "
|
774
|
+
this.specificationVersion = "v3";
|
755
775
|
var _a;
|
756
776
|
this.modelId = modelId;
|
757
777
|
this.config = config;
|
@@ -829,7 +849,10 @@ var GoogleGenerativeAILanguageModel = class {
|
|
829
849
|
},
|
830
850
|
// provider options:
|
831
851
|
responseModalities: googleOptions == null ? void 0 : googleOptions.responseModalities,
|
832
|
-
thinkingConfig: googleOptions == null ? void 0 : googleOptions.thinkingConfig
|
852
|
+
thinkingConfig: googleOptions == null ? void 0 : googleOptions.thinkingConfig,
|
853
|
+
...(googleOptions == null ? void 0 : googleOptions.mediaResolution) && {
|
854
|
+
mediaResolution: googleOptions.mediaResolution
|
855
|
+
}
|
833
856
|
},
|
834
857
|
contents,
|
835
858
|
systemInstruction: isGemmaModel ? void 0 : systemInstruction,
|
@@ -843,7 +866,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
843
866
|
};
|
844
867
|
}
|
845
868
|
async doGenerate(options) {
|
846
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
869
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
847
870
|
const { args, warnings } = await this.getArgs(options);
|
848
871
|
const body = JSON.stringify(args);
|
849
872
|
const mergedHeaders = (0, import_provider_utils6.combineHeaders)(
|
@@ -939,9 +962,10 @@ var GoogleGenerativeAILanguageModel = class {
|
|
939
962
|
warnings,
|
940
963
|
providerMetadata: {
|
941
964
|
google: {
|
942
|
-
|
943
|
-
|
944
|
-
|
965
|
+
promptFeedback: (_j = response.promptFeedback) != null ? _j : null,
|
966
|
+
groundingMetadata: (_k = candidate.groundingMetadata) != null ? _k : null,
|
967
|
+
urlContextMetadata: (_l = candidate.urlContextMetadata) != null ? _l : null,
|
968
|
+
safetyRatings: (_m = candidate.safetyRatings) != null ? _m : null,
|
945
969
|
usageMetadata: usageMetadata != null ? usageMetadata : null
|
946
970
|
}
|
947
971
|
},
|
@@ -992,7 +1016,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
992
1016
|
controller.enqueue({ type: "stream-start", warnings });
|
993
1017
|
},
|
994
1018
|
transform(chunk, controller) {
|
995
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
1019
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
996
1020
|
if (options.includeRawChunks) {
|
997
1021
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
998
1022
|
}
|
@@ -1166,9 +1190,10 @@ var GoogleGenerativeAILanguageModel = class {
|
|
1166
1190
|
});
|
1167
1191
|
providerMetadata = {
|
1168
1192
|
google: {
|
1169
|
-
|
1170
|
-
|
1171
|
-
|
1193
|
+
promptFeedback: (_i = value.promptFeedback) != null ? _i : null,
|
1194
|
+
groundingMetadata: (_j = candidate.groundingMetadata) != null ? _j : null,
|
1195
|
+
urlContextMetadata: (_k = candidate.urlContextMetadata) != null ? _k : null,
|
1196
|
+
safetyRatings: (_l = candidate.safetyRatings) != null ? _l : null
|
1172
1197
|
}
|
1173
1198
|
};
|
1174
1199
|
if (usageMetadata != null) {
|
@@ -1296,7 +1321,11 @@ var responseSchema = import_v47.z.object({
|
|
1296
1321
|
urlContextMetadata: urlContextMetadataSchema.nullish()
|
1297
1322
|
})
|
1298
1323
|
),
|
1299
|
-
usageMetadata: usageSchema.nullish()
|
1324
|
+
usageMetadata: usageSchema.nullish(),
|
1325
|
+
promptFeedback: import_v47.z.object({
|
1326
|
+
blockReason: import_v47.z.string().nullish(),
|
1327
|
+
safetyRatings: import_v47.z.array(safetyRatingSchema).nullish()
|
1328
|
+
}).nullish()
|
1300
1329
|
});
|
1301
1330
|
var chunkSchema = import_v47.z.object({
|
1302
1331
|
candidates: import_v47.z.array(
|
@@ -1308,7 +1337,11 @@ var chunkSchema = import_v47.z.object({
|
|
1308
1337
|
urlContextMetadata: urlContextMetadataSchema.nullish()
|
1309
1338
|
})
|
1310
1339
|
).nullish(),
|
1311
|
-
usageMetadata: usageSchema.nullish()
|
1340
|
+
usageMetadata: usageSchema.nullish(),
|
1341
|
+
promptFeedback: import_v47.z.object({
|
1342
|
+
blockReason: import_v47.z.string().nullish(),
|
1343
|
+
safetyRatings: import_v47.z.array(safetyRatingSchema).nullish()
|
1344
|
+
}).nullish()
|
1312
1345
|
});
|
1313
1346
|
|
1314
1347
|
// src/tool/code-execution.ts
|
@@ -1360,7 +1393,7 @@ var GoogleGenerativeAIImageModel = class {
|
|
1360
1393
|
this.modelId = modelId;
|
1361
1394
|
this.settings = settings;
|
1362
1395
|
this.config = config;
|
1363
|
-
this.specificationVersion = "
|
1396
|
+
this.specificationVersion = "v3";
|
1364
1397
|
}
|
1365
1398
|
get maxImagesPerCall() {
|
1366
1399
|
var _a;
|
@@ -1458,14 +1491,17 @@ var googleImageProviderOptionsSchema = import_v49.z.object({
|
|
1458
1491
|
function createGoogleGenerativeAI(options = {}) {
|
1459
1492
|
var _a;
|
1460
1493
|
const baseURL = (_a = (0, import_provider_utils9.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://generativelanguage.googleapis.com/v1beta";
|
1461
|
-
const getHeaders = () => (
|
1462
|
-
|
1463
|
-
|
1464
|
-
|
1465
|
-
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1494
|
+
const getHeaders = () => (0, import_provider_utils9.withUserAgentSuffix)(
|
1495
|
+
{
|
1496
|
+
"x-goog-api-key": (0, import_provider_utils9.loadApiKey)({
|
1497
|
+
apiKey: options.apiKey,
|
1498
|
+
environmentVariableName: "GOOGLE_GENERATIVE_AI_API_KEY",
|
1499
|
+
description: "Google Generative AI"
|
1500
|
+
}),
|
1501
|
+
...options.headers
|
1502
|
+
},
|
1503
|
+
`ai-sdk/google/${VERSION}`
|
1504
|
+
);
|
1469
1505
|
const createChatModel = (modelId) => {
|
1470
1506
|
var _a2;
|
1471
1507
|
return new GoogleGenerativeAILanguageModel(modelId, {
|
@@ -1522,6 +1558,7 @@ function createGoogleGenerativeAI(options = {}) {
|
|
1522
1558
|
var google = createGoogleGenerativeAI();
|
1523
1559
|
// Annotate the CommonJS export names for ESM import in node:
|
1524
1560
|
0 && (module.exports = {
|
1561
|
+
VERSION,
|
1525
1562
|
createGoogleGenerativeAI,
|
1526
1563
|
google
|
1527
1564
|
});
|