@ai-sdk/google 4.0.0-beta.37 → 4.0.0-beta.38
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 +18 -0
- package/dist/index.js +69 -21
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +11 -3
- package/dist/internal/index.js +30 -16
- package/dist/internal/index.js.map +1 -1
- package/package.json +3 -3
- package/src/convert-to-google-generative-ai-messages.ts +15 -13
- package/src/google-generative-ai-embedding-model.ts +22 -2
- package/src/google-generative-ai-image-model.ts +25 -1
- package/src/google-generative-ai-language-model.ts +20 -3
package/dist/internal/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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
6
|
type GoogleGenerativeAIModelId = '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-lite-preview-09-2025' | '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-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 & {});
|
|
@@ -8,7 +8,7 @@ type GoogleGenerativeAIModelId = 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | '
|
|
|
8
8
|
type GoogleGenerativeAIConfig = {
|
|
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
|
/**
|
|
@@ -21,6 +21,14 @@ declare class GoogleGenerativeAILanguageModel implements LanguageModelV4 {
|
|
|
21
21
|
readonly modelId: GoogleGenerativeAIModelId;
|
|
22
22
|
private readonly config;
|
|
23
23
|
private readonly generateId;
|
|
24
|
+
static [WORKFLOW_SERIALIZE](model: GoogleGenerativeAILanguageModel): {
|
|
25
|
+
modelId: string;
|
|
26
|
+
config: JSONObject;
|
|
27
|
+
};
|
|
28
|
+
static [WORKFLOW_DESERIALIZE](options: {
|
|
29
|
+
modelId: string;
|
|
30
|
+
config: GoogleGenerativeAIConfig;
|
|
31
|
+
}): GoogleGenerativeAILanguageModel;
|
|
24
32
|
constructor(modelId: GoogleGenerativeAIModelId, config: GoogleGenerativeAIConfig);
|
|
25
33
|
get provider(): string;
|
|
26
34
|
get supportedUrls(): Record<string, RegExp[]> | PromiseLike<Record<string, RegExp[]>>;
|
package/dist/internal/index.js
CHANGED
|
@@ -11,6 +11,9 @@ import {
|
|
|
11
11
|
parseProviderOptions,
|
|
12
12
|
postJsonToApi,
|
|
13
13
|
resolve,
|
|
14
|
+
serializeModelOptions,
|
|
15
|
+
WORKFLOW_SERIALIZE,
|
|
16
|
+
WORKFLOW_DESERIALIZE,
|
|
14
17
|
zodSchema as zodSchema3
|
|
15
18
|
} from "@ai-sdk/provider-utils";
|
|
16
19
|
import { z as z3 } from "zod/v4";
|
|
@@ -211,7 +214,6 @@ function appendToolResultParts(parts, toolName, outputValue) {
|
|
|
211
214
|
responseTextParts.push(contentPart.text);
|
|
212
215
|
break;
|
|
213
216
|
}
|
|
214
|
-
case "image-data":
|
|
215
217
|
case "file-data": {
|
|
216
218
|
functionResponseParts.push({
|
|
217
219
|
inlineData: {
|
|
@@ -221,7 +223,6 @@ function appendToolResultParts(parts, toolName, outputValue) {
|
|
|
221
223
|
});
|
|
222
224
|
break;
|
|
223
225
|
}
|
|
224
|
-
case "image-url":
|
|
225
226
|
case "file-url": {
|
|
226
227
|
const functionResponsePart = convertUrlToolResultPart(
|
|
227
228
|
contentPart.url
|
|
@@ -264,18 +265,22 @@ function appendLegacyToolResultParts(parts, toolName, outputValue) {
|
|
|
264
265
|
}
|
|
265
266
|
});
|
|
266
267
|
break;
|
|
267
|
-
case "
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
268
|
+
case "file-data":
|
|
269
|
+
if (contentPart.mediaType.startsWith("image/")) {
|
|
270
|
+
parts.push(
|
|
271
|
+
{
|
|
272
|
+
inlineData: {
|
|
273
|
+
mimeType: contentPart.mediaType,
|
|
274
|
+
data: contentPart.data
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
text: "Tool executed successfully and returned this image as a response"
|
|
273
279
|
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
);
|
|
280
|
+
);
|
|
281
|
+
} else {
|
|
282
|
+
parts.push({ text: JSON.stringify(contentPart) });
|
|
283
|
+
}
|
|
279
284
|
break;
|
|
280
285
|
default:
|
|
281
286
|
parts.push({ text: JSON.stringify(contentPart) });
|
|
@@ -1197,7 +1202,7 @@ function mapGoogleGenerativeAIFinishReason({
|
|
|
1197
1202
|
}
|
|
1198
1203
|
|
|
1199
1204
|
// src/google-generative-ai-language-model.ts
|
|
1200
|
-
var GoogleGenerativeAILanguageModel = class {
|
|
1205
|
+
var GoogleGenerativeAILanguageModel = class _GoogleGenerativeAILanguageModel {
|
|
1201
1206
|
constructor(modelId, config) {
|
|
1202
1207
|
this.specificationVersion = "v4";
|
|
1203
1208
|
var _a;
|
|
@@ -1205,6 +1210,15 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1205
1210
|
this.config = config;
|
|
1206
1211
|
this.generateId = (_a = config.generateId) != null ? _a : generateId;
|
|
1207
1212
|
}
|
|
1213
|
+
static [WORKFLOW_SERIALIZE](model) {
|
|
1214
|
+
return serializeModelOptions({
|
|
1215
|
+
modelId: model.modelId,
|
|
1216
|
+
config: model.config
|
|
1217
|
+
});
|
|
1218
|
+
}
|
|
1219
|
+
static [WORKFLOW_DESERIALIZE](options) {
|
|
1220
|
+
return new _GoogleGenerativeAILanguageModel(options.modelId, options.config);
|
|
1221
|
+
}
|
|
1208
1222
|
get provider() {
|
|
1209
1223
|
return this.config.provider;
|
|
1210
1224
|
}
|
|
@@ -1348,7 +1362,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1348
1362
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
1349
1363
|
const { args, warnings, providerOptionsName } = await this.getArgs(options);
|
|
1350
1364
|
const mergedHeaders = combineHeaders(
|
|
1351
|
-
await resolve(this.config.headers),
|
|
1365
|
+
this.config.headers ? await resolve(this.config.headers) : void 0,
|
|
1352
1366
|
options.headers
|
|
1353
1367
|
);
|
|
1354
1368
|
const {
|
|
@@ -1530,7 +1544,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1530
1544
|
{ isStreaming: true }
|
|
1531
1545
|
);
|
|
1532
1546
|
const headers = combineHeaders(
|
|
1533
|
-
await resolve(this.config.headers),
|
|
1547
|
+
this.config.headers ? await resolve(this.config.headers) : void 0,
|
|
1534
1548
|
options.headers
|
|
1535
1549
|
);
|
|
1536
1550
|
const { responseHeaders, value: response } = await postJsonToApi({
|