@ai-sdk/google 2.1.0-beta.1 → 2.1.0-beta.10
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 +77 -0
- package/dist/index.d.mts +20 -12
- package/dist/index.d.ts +20 -12
- package/dist/index.js +59 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +60 -28
- 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 +41 -17
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +41 -17
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,82 @@
|
|
1
1
|
# @ai-sdk/google
|
2
2
|
|
3
|
+
## 2.1.0-beta.10
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- e8109d3: feat: tool execution approval
|
8
|
+
- Updated dependencies [046aa3b]
|
9
|
+
- Updated dependencies [e8109d3]
|
10
|
+
- @ai-sdk/provider@2.1.0-beta.5
|
11
|
+
- @ai-sdk/provider-utils@3.1.0-beta.7
|
12
|
+
|
13
|
+
## 2.1.0-beta.9
|
14
|
+
|
15
|
+
### Patch Changes
|
16
|
+
|
17
|
+
- 0adc679: feat(provider): shared spec v3
|
18
|
+
- Updated dependencies [0adc679]
|
19
|
+
- Updated dependencies [2b0caef]
|
20
|
+
- @ai-sdk/provider-utils@3.1.0-beta.6
|
21
|
+
- @ai-sdk/provider@2.1.0-beta.4
|
22
|
+
|
23
|
+
## 2.1.0-beta.8
|
24
|
+
|
25
|
+
### Patch Changes
|
26
|
+
|
27
|
+
- 7728ac5: The mediaResolution option has been added and is now passed to the Google API.
|
28
|
+
|
29
|
+
## 2.1.0-beta.7
|
30
|
+
|
31
|
+
### Patch Changes
|
32
|
+
|
33
|
+
- 8dac895: feat: `LanguageModelV3`
|
34
|
+
- 10c1322: fix: moved dependency `@ai-sdk/test-server` to devDependencies
|
35
|
+
- Updated dependencies [8dac895]
|
36
|
+
- @ai-sdk/provider-utils@3.1.0-beta.5
|
37
|
+
- @ai-sdk/provider@2.1.0-beta.3
|
38
|
+
|
39
|
+
## 2.1.0-beta.6
|
40
|
+
|
41
|
+
### Patch Changes
|
42
|
+
|
43
|
+
- e833473: chore (provider/google): Add preview modelIds for gemini 2.5 flash and lite
|
44
|
+
|
45
|
+
## 2.1.0-beta.5
|
46
|
+
|
47
|
+
### Patch Changes
|
48
|
+
|
49
|
+
- 4616b86: chore: update zod peer depenedency version
|
50
|
+
- Updated dependencies [4616b86]
|
51
|
+
- @ai-sdk/provider-utils@3.1.0-beta.4
|
52
|
+
|
53
|
+
## 2.1.0-beta.4
|
54
|
+
|
55
|
+
### Patch Changes
|
56
|
+
|
57
|
+
- ed329cb: feat: `Provider-V3`
|
58
|
+
- 522f6b8: feat: `ImageModelV3`
|
59
|
+
- Updated dependencies [ed329cb]
|
60
|
+
- Updated dependencies [522f6b8]
|
61
|
+
- @ai-sdk/provider@2.1.0-beta.2
|
62
|
+
- @ai-sdk/provider-utils@3.1.0-beta.3
|
63
|
+
|
64
|
+
## 2.1.0-beta.3
|
65
|
+
|
66
|
+
### Patch Changes
|
67
|
+
|
68
|
+
- 0c4822d: feat: `EmbeddingModelV3`
|
69
|
+
- 1cad0ab: feat: add provider version to user-agent header
|
70
|
+
- Updated dependencies [0c4822d]
|
71
|
+
- @ai-sdk/provider@2.1.0-beta.1
|
72
|
+
- @ai-sdk/provider-utils@3.1.0-beta.2
|
73
|
+
|
74
|
+
## 2.1.0-beta.2
|
75
|
+
|
76
|
+
### Patch Changes
|
77
|
+
|
78
|
+
- 7dea60e: add promptFeedback outputs
|
79
|
+
|
3
80
|
## 2.1.0-beta.1
|
4
81
|
|
5
82
|
### 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-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-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.10" : "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
|
@@ -751,7 +766,7 @@ var urlContext = (0, import_provider_utils5.createProviderDefinedToolFactory)({
|
|
751
766
|
// src/google-generative-ai-language-model.ts
|
752
767
|
var GoogleGenerativeAILanguageModel = class {
|
753
768
|
constructor(modelId, config) {
|
754
|
-
this.specificationVersion = "
|
769
|
+
this.specificationVersion = "v3";
|
755
770
|
var _a;
|
756
771
|
this.modelId = modelId;
|
757
772
|
this.config = config;
|
@@ -829,7 +844,10 @@ var GoogleGenerativeAILanguageModel = class {
|
|
829
844
|
},
|
830
845
|
// provider options:
|
831
846
|
responseModalities: googleOptions == null ? void 0 : googleOptions.responseModalities,
|
832
|
-
thinkingConfig: googleOptions == null ? void 0 : googleOptions.thinkingConfig
|
847
|
+
thinkingConfig: googleOptions == null ? void 0 : googleOptions.thinkingConfig,
|
848
|
+
...(googleOptions == null ? void 0 : googleOptions.mediaResolution) && {
|
849
|
+
mediaResolution: googleOptions.mediaResolution
|
850
|
+
}
|
833
851
|
},
|
834
852
|
contents,
|
835
853
|
systemInstruction: isGemmaModel ? void 0 : systemInstruction,
|
@@ -843,7 +861,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
843
861
|
};
|
844
862
|
}
|
845
863
|
async doGenerate(options) {
|
846
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
864
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
847
865
|
const { args, warnings } = await this.getArgs(options);
|
848
866
|
const body = JSON.stringify(args);
|
849
867
|
const mergedHeaders = (0, import_provider_utils6.combineHeaders)(
|
@@ -939,9 +957,10 @@ var GoogleGenerativeAILanguageModel = class {
|
|
939
957
|
warnings,
|
940
958
|
providerMetadata: {
|
941
959
|
google: {
|
942
|
-
|
943
|
-
|
944
|
-
|
960
|
+
promptFeedback: (_j = response.promptFeedback) != null ? _j : null,
|
961
|
+
groundingMetadata: (_k = candidate.groundingMetadata) != null ? _k : null,
|
962
|
+
urlContextMetadata: (_l = candidate.urlContextMetadata) != null ? _l : null,
|
963
|
+
safetyRatings: (_m = candidate.safetyRatings) != null ? _m : null,
|
945
964
|
usageMetadata: usageMetadata != null ? usageMetadata : null
|
946
965
|
}
|
947
966
|
},
|
@@ -992,7 +1011,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
992
1011
|
controller.enqueue({ type: "stream-start", warnings });
|
993
1012
|
},
|
994
1013
|
transform(chunk, controller) {
|
995
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
1014
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
996
1015
|
if (options.includeRawChunks) {
|
997
1016
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
998
1017
|
}
|
@@ -1166,9 +1185,10 @@ var GoogleGenerativeAILanguageModel = class {
|
|
1166
1185
|
});
|
1167
1186
|
providerMetadata = {
|
1168
1187
|
google: {
|
1169
|
-
|
1170
|
-
|
1171
|
-
|
1188
|
+
promptFeedback: (_i = value.promptFeedback) != null ? _i : null,
|
1189
|
+
groundingMetadata: (_j = candidate.groundingMetadata) != null ? _j : null,
|
1190
|
+
urlContextMetadata: (_k = candidate.urlContextMetadata) != null ? _k : null,
|
1191
|
+
safetyRatings: (_l = candidate.safetyRatings) != null ? _l : null
|
1172
1192
|
}
|
1173
1193
|
};
|
1174
1194
|
if (usageMetadata != null) {
|
@@ -1296,7 +1316,11 @@ var responseSchema = import_v47.z.object({
|
|
1296
1316
|
urlContextMetadata: urlContextMetadataSchema.nullish()
|
1297
1317
|
})
|
1298
1318
|
),
|
1299
|
-
usageMetadata: usageSchema.nullish()
|
1319
|
+
usageMetadata: usageSchema.nullish(),
|
1320
|
+
promptFeedback: import_v47.z.object({
|
1321
|
+
blockReason: import_v47.z.string().nullish(),
|
1322
|
+
safetyRatings: import_v47.z.array(safetyRatingSchema).nullish()
|
1323
|
+
}).nullish()
|
1300
1324
|
});
|
1301
1325
|
var chunkSchema = import_v47.z.object({
|
1302
1326
|
candidates: import_v47.z.array(
|
@@ -1308,7 +1332,11 @@ var chunkSchema = import_v47.z.object({
|
|
1308
1332
|
urlContextMetadata: urlContextMetadataSchema.nullish()
|
1309
1333
|
})
|
1310
1334
|
).nullish(),
|
1311
|
-
usageMetadata: usageSchema.nullish()
|
1335
|
+
usageMetadata: usageSchema.nullish(),
|
1336
|
+
promptFeedback: import_v47.z.object({
|
1337
|
+
blockReason: import_v47.z.string().nullish(),
|
1338
|
+
safetyRatings: import_v47.z.array(safetyRatingSchema).nullish()
|
1339
|
+
}).nullish()
|
1312
1340
|
});
|
1313
1341
|
|
1314
1342
|
// src/tool/code-execution.ts
|
@@ -1360,7 +1388,7 @@ var GoogleGenerativeAIImageModel = class {
|
|
1360
1388
|
this.modelId = modelId;
|
1361
1389
|
this.settings = settings;
|
1362
1390
|
this.config = config;
|
1363
|
-
this.specificationVersion = "
|
1391
|
+
this.specificationVersion = "v3";
|
1364
1392
|
}
|
1365
1393
|
get maxImagesPerCall() {
|
1366
1394
|
var _a;
|
@@ -1458,14 +1486,17 @@ var googleImageProviderOptionsSchema = import_v49.z.object({
|
|
1458
1486
|
function createGoogleGenerativeAI(options = {}) {
|
1459
1487
|
var _a;
|
1460
1488
|
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
|
-
|
1489
|
+
const getHeaders = () => (0, import_provider_utils9.withUserAgentSuffix)(
|
1490
|
+
{
|
1491
|
+
"x-goog-api-key": (0, import_provider_utils9.loadApiKey)({
|
1492
|
+
apiKey: options.apiKey,
|
1493
|
+
environmentVariableName: "GOOGLE_GENERATIVE_AI_API_KEY",
|
1494
|
+
description: "Google Generative AI"
|
1495
|
+
}),
|
1496
|
+
...options.headers
|
1497
|
+
},
|
1498
|
+
`ai-sdk/google/${VERSION}`
|
1499
|
+
);
|
1469
1500
|
const createChatModel = (modelId) => {
|
1470
1501
|
var _a2;
|
1471
1502
|
return new GoogleGenerativeAILanguageModel(modelId, {
|
@@ -1522,6 +1553,7 @@ function createGoogleGenerativeAI(options = {}) {
|
|
1522
1553
|
var google = createGoogleGenerativeAI();
|
1523
1554
|
// Annotate the CommonJS export names for ESM import in node:
|
1524
1555
|
0 && (module.exports = {
|
1556
|
+
VERSION,
|
1525
1557
|
createGoogleGenerativeAI,
|
1526
1558
|
google
|
1527
1559
|
});
|