@ai-sdk/google 2.1.0-beta.0 → 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 +86 -0
- package/dist/index.d.mts +20 -12
- package/dist/index.d.ts +20 -12
- package/dist/index.js +62 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +63 -34
- 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 +44 -23
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +44 -23
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +5 -4
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,91 @@
|
|
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
|
+
|
80
|
+
## 2.1.0-beta.1
|
81
|
+
|
82
|
+
### Patch Changes
|
83
|
+
|
84
|
+
- Updated dependencies [953d0f2]
|
85
|
+
- Updated dependencies [cbb1d35]
|
86
|
+
- @ai-sdk/test-server@1.0.0-beta.0
|
87
|
+
- @ai-sdk/provider-utils@3.1.0-beta.1
|
88
|
+
|
3
89
|
## 2.1.0-beta.0
|
4
90
|
|
5
91
|
### Minor 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;
|
@@ -207,12 +211,9 @@ function convertJSONSchemaToOpenAPISchema(jsonSchema) {
|
|
207
211
|
enum: enumValues
|
208
212
|
} = jsonSchema;
|
209
213
|
const result = {};
|
210
|
-
if (description)
|
211
|
-
|
212
|
-
if (
|
213
|
-
result.required = required;
|
214
|
-
if (format)
|
215
|
-
result.format = format;
|
214
|
+
if (description) result.description = description;
|
215
|
+
if (required) result.required = required;
|
216
|
+
if (format) result.format = format;
|
216
217
|
if (constValue !== void 0) {
|
217
218
|
result.enum = [constValue];
|
218
219
|
}
|
@@ -285,7 +286,7 @@ function isEmptyObjectSchema(jsonSchema) {
|
|
285
286
|
var import_provider2 = require("@ai-sdk/provider");
|
286
287
|
var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
287
288
|
function convertToGoogleGenerativeAIMessages(prompt, options) {
|
288
|
-
var _a;
|
289
|
+
var _a, _b;
|
289
290
|
const systemInstructionParts = [];
|
290
291
|
const contents = [];
|
291
292
|
let systemMessagesAllowed = true;
|
@@ -337,12 +338,12 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
337
338
|
contents.push({
|
338
339
|
role: "model",
|
339
340
|
parts: content.map((part) => {
|
340
|
-
var _a2,
|
341
|
+
var _a2, _b2, _c, _d, _e, _f;
|
341
342
|
switch (part.type) {
|
342
343
|
case "text": {
|
343
344
|
return part.text.length === 0 ? void 0 : {
|
344
345
|
text: part.text,
|
345
|
-
thoughtSignature: (
|
346
|
+
thoughtSignature: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2.google) == null ? void 0 : _b2.thoughtSignature
|
346
347
|
};
|
347
348
|
}
|
348
349
|
case "reasoning": {
|
@@ -427,7 +428,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
427
428
|
name: part.toolName,
|
428
429
|
response: {
|
429
430
|
name: part.toolName,
|
430
|
-
content: output.value
|
431
|
+
content: output.type === "execution-denied" ? (_b = output.reason) != null ? _b : "Tool execution denied." : output.value
|
431
432
|
}
|
432
433
|
}
|
433
434
|
});
|
@@ -521,7 +522,18 @@ var googleGenerativeAIProviderOptions = import_v44.z.object({
|
|
521
522
|
*
|
522
523
|
* https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/add-labels-to-api-calls
|
523
524
|
*/
|
524
|
-
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()
|
525
537
|
});
|
526
538
|
|
527
539
|
// src/google-prepare-tools.ts
|
@@ -754,7 +766,7 @@ var urlContext = (0, import_provider_utils5.createProviderDefinedToolFactory)({
|
|
754
766
|
// src/google-generative-ai-language-model.ts
|
755
767
|
var GoogleGenerativeAILanguageModel = class {
|
756
768
|
constructor(modelId, config) {
|
757
|
-
this.specificationVersion = "
|
769
|
+
this.specificationVersion = "v3";
|
758
770
|
var _a;
|
759
771
|
this.modelId = modelId;
|
760
772
|
this.config = config;
|
@@ -832,7 +844,10 @@ var GoogleGenerativeAILanguageModel = class {
|
|
832
844
|
},
|
833
845
|
// provider options:
|
834
846
|
responseModalities: googleOptions == null ? void 0 : googleOptions.responseModalities,
|
835
|
-
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
|
+
}
|
836
851
|
},
|
837
852
|
contents,
|
838
853
|
systemInstruction: isGemmaModel ? void 0 : systemInstruction,
|
@@ -846,7 +861,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
846
861
|
};
|
847
862
|
}
|
848
863
|
async doGenerate(options) {
|
849
|
-
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;
|
850
865
|
const { args, warnings } = await this.getArgs(options);
|
851
866
|
const body = JSON.stringify(args);
|
852
867
|
const mergedHeaders = (0, import_provider_utils6.combineHeaders)(
|
@@ -942,9 +957,10 @@ var GoogleGenerativeAILanguageModel = class {
|
|
942
957
|
warnings,
|
943
958
|
providerMetadata: {
|
944
959
|
google: {
|
945
|
-
|
946
|
-
|
947
|
-
|
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,
|
948
964
|
usageMetadata: usageMetadata != null ? usageMetadata : null
|
949
965
|
}
|
950
966
|
},
|
@@ -995,7 +1011,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
995
1011
|
controller.enqueue({ type: "stream-start", warnings });
|
996
1012
|
},
|
997
1013
|
transform(chunk, controller) {
|
998
|
-
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;
|
999
1015
|
if (options.includeRawChunks) {
|
1000
1016
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
1001
1017
|
}
|
@@ -1169,9 +1185,10 @@ var GoogleGenerativeAILanguageModel = class {
|
|
1169
1185
|
});
|
1170
1186
|
providerMetadata = {
|
1171
1187
|
google: {
|
1172
|
-
|
1173
|
-
|
1174
|
-
|
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
|
1175
1192
|
}
|
1176
1193
|
};
|
1177
1194
|
if (usageMetadata != null) {
|
@@ -1299,7 +1316,11 @@ var responseSchema = import_v47.z.object({
|
|
1299
1316
|
urlContextMetadata: urlContextMetadataSchema.nullish()
|
1300
1317
|
})
|
1301
1318
|
),
|
1302
|
-
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()
|
1303
1324
|
});
|
1304
1325
|
var chunkSchema = import_v47.z.object({
|
1305
1326
|
candidates: import_v47.z.array(
|
@@ -1311,7 +1332,11 @@ var chunkSchema = import_v47.z.object({
|
|
1311
1332
|
urlContextMetadata: urlContextMetadataSchema.nullish()
|
1312
1333
|
})
|
1313
1334
|
).nullish(),
|
1314
|
-
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()
|
1315
1340
|
});
|
1316
1341
|
|
1317
1342
|
// src/tool/code-execution.ts
|
@@ -1363,7 +1388,7 @@ var GoogleGenerativeAIImageModel = class {
|
|
1363
1388
|
this.modelId = modelId;
|
1364
1389
|
this.settings = settings;
|
1365
1390
|
this.config = config;
|
1366
|
-
this.specificationVersion = "
|
1391
|
+
this.specificationVersion = "v3";
|
1367
1392
|
}
|
1368
1393
|
get maxImagesPerCall() {
|
1369
1394
|
var _a;
|
@@ -1461,14 +1486,17 @@ var googleImageProviderOptionsSchema = import_v49.z.object({
|
|
1461
1486
|
function createGoogleGenerativeAI(options = {}) {
|
1462
1487
|
var _a;
|
1463
1488
|
const baseURL = (_a = (0, import_provider_utils9.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://generativelanguage.googleapis.com/v1beta";
|
1464
|
-
const getHeaders = () => (
|
1465
|
-
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1471
|
-
|
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
|
+
);
|
1472
1500
|
const createChatModel = (modelId) => {
|
1473
1501
|
var _a2;
|
1474
1502
|
return new GoogleGenerativeAILanguageModel(modelId, {
|
@@ -1525,6 +1553,7 @@ function createGoogleGenerativeAI(options = {}) {
|
|
1525
1553
|
var google = createGoogleGenerativeAI();
|
1526
1554
|
// Annotate the CommonJS export names for ESM import in node:
|
1527
1555
|
0 && (module.exports = {
|
1556
|
+
VERSION,
|
1528
1557
|
createGoogleGenerativeAI,
|
1529
1558
|
google
|
1530
1559
|
});
|