@ai-sdk/google 2.0.17 → 2.1.0-beta.1
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 +11 -11
- package/dist/index.d.mts +2 -4
- package/dist/index.d.ts +2 -4
- package/dist/index.js +21 -42
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -43
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +1 -1
- package/dist/internal/index.d.ts +1 -1
- package/dist/internal/index.js +13 -26
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +13 -26
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +5 -4
package/dist/index.mjs
CHANGED
@@ -2,13 +2,9 @@
|
|
2
2
|
import {
|
3
3
|
generateId as generateId2,
|
4
4
|
loadApiKey,
|
5
|
-
withoutTrailingSlash
|
6
|
-
withUserAgentSuffix
|
5
|
+
withoutTrailingSlash
|
7
6
|
} from "@ai-sdk/provider-utils";
|
8
7
|
|
9
|
-
// src/version.ts
|
10
|
-
var VERSION = true ? "2.0.17" : "0.0.0-test";
|
11
|
-
|
12
8
|
// src/google-generative-ai-embedding-model.ts
|
13
9
|
import {
|
14
10
|
TooManyEmbeddingValuesForCallError
|
@@ -204,12 +200,9 @@ function convertJSONSchemaToOpenAPISchema(jsonSchema) {
|
|
204
200
|
enum: enumValues
|
205
201
|
} = jsonSchema;
|
206
202
|
const result = {};
|
207
|
-
if (description)
|
208
|
-
|
209
|
-
if (
|
210
|
-
result.required = required;
|
211
|
-
if (format)
|
212
|
-
result.format = format;
|
203
|
+
if (description) result.description = description;
|
204
|
+
if (required) result.required = required;
|
205
|
+
if (format) result.format = format;
|
213
206
|
if (constValue !== void 0) {
|
214
207
|
result.enum = [constValue];
|
215
208
|
}
|
@@ -847,7 +840,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
847
840
|
};
|
848
841
|
}
|
849
842
|
async doGenerate(options) {
|
850
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l
|
843
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
851
844
|
const { args, warnings } = await this.getArgs(options);
|
852
845
|
const body = JSON.stringify(args);
|
853
846
|
const mergedHeaders = combineHeaders2(
|
@@ -943,10 +936,9 @@ var GoogleGenerativeAILanguageModel = class {
|
|
943
936
|
warnings,
|
944
937
|
providerMetadata: {
|
945
938
|
google: {
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
safetyRatings: (_m = candidate.safetyRatings) != null ? _m : null,
|
939
|
+
groundingMetadata: (_j = candidate.groundingMetadata) != null ? _j : null,
|
940
|
+
urlContextMetadata: (_k = candidate.urlContextMetadata) != null ? _k : null,
|
941
|
+
safetyRatings: (_l = candidate.safetyRatings) != null ? _l : null,
|
950
942
|
usageMetadata: usageMetadata != null ? usageMetadata : null
|
951
943
|
}
|
952
944
|
},
|
@@ -997,7 +989,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
997
989
|
controller.enqueue({ type: "stream-start", warnings });
|
998
990
|
},
|
999
991
|
transform(chunk, controller) {
|
1000
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k
|
992
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
1001
993
|
if (options.includeRawChunks) {
|
1002
994
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
1003
995
|
}
|
@@ -1171,10 +1163,9 @@ var GoogleGenerativeAILanguageModel = class {
|
|
1171
1163
|
});
|
1172
1164
|
providerMetadata = {
|
1173
1165
|
google: {
|
1174
|
-
|
1175
|
-
|
1176
|
-
|
1177
|
-
safetyRatings: (_l = candidate.safetyRatings) != null ? _l : null
|
1166
|
+
groundingMetadata: (_i = candidate.groundingMetadata) != null ? _i : null,
|
1167
|
+
urlContextMetadata: (_j = candidate.urlContextMetadata) != null ? _j : null,
|
1168
|
+
safetyRatings: (_k = candidate.safetyRatings) != null ? _k : null
|
1178
1169
|
}
|
1179
1170
|
};
|
1180
1171
|
if (usageMetadata != null) {
|
@@ -1302,11 +1293,7 @@ var responseSchema = z7.object({
|
|
1302
1293
|
urlContextMetadata: urlContextMetadataSchema.nullish()
|
1303
1294
|
})
|
1304
1295
|
),
|
1305
|
-
usageMetadata: usageSchema.nullish()
|
1306
|
-
promptFeedback: z7.object({
|
1307
|
-
blockReason: z7.string().nullish(),
|
1308
|
-
safetyRatings: z7.array(safetyRatingSchema).nullish()
|
1309
|
-
}).nullish()
|
1296
|
+
usageMetadata: usageSchema.nullish()
|
1310
1297
|
});
|
1311
1298
|
var chunkSchema = z7.object({
|
1312
1299
|
candidates: z7.array(
|
@@ -1318,11 +1305,7 @@ var chunkSchema = z7.object({
|
|
1318
1305
|
urlContextMetadata: urlContextMetadataSchema.nullish()
|
1319
1306
|
})
|
1320
1307
|
).nullish(),
|
1321
|
-
usageMetadata: usageSchema.nullish()
|
1322
|
-
promptFeedback: z7.object({
|
1323
|
-
blockReason: z7.string().nullish(),
|
1324
|
-
safetyRatings: z7.array(safetyRatingSchema).nullish()
|
1325
|
-
}).nullish()
|
1308
|
+
usageMetadata: usageSchema.nullish()
|
1326
1309
|
});
|
1327
1310
|
|
1328
1311
|
// src/tool/code-execution.ts
|
@@ -1478,17 +1461,14 @@ var googleImageProviderOptionsSchema = z9.object({
|
|
1478
1461
|
function createGoogleGenerativeAI(options = {}) {
|
1479
1462
|
var _a;
|
1480
1463
|
const baseURL = (_a = withoutTrailingSlash(options.baseURL)) != null ? _a : "https://generativelanguage.googleapis.com/v1beta";
|
1481
|
-
const getHeaders = () =>
|
1482
|
-
{
|
1483
|
-
|
1484
|
-
|
1485
|
-
|
1486
|
-
|
1487
|
-
|
1488
|
-
|
1489
|
-
},
|
1490
|
-
`ai-sdk/google/${VERSION}`
|
1491
|
-
);
|
1464
|
+
const getHeaders = () => ({
|
1465
|
+
"x-goog-api-key": loadApiKey({
|
1466
|
+
apiKey: options.apiKey,
|
1467
|
+
environmentVariableName: "GOOGLE_GENERATIVE_AI_API_KEY",
|
1468
|
+
description: "Google Generative AI"
|
1469
|
+
}),
|
1470
|
+
...options.headers
|
1471
|
+
});
|
1492
1472
|
const createChatModel = (modelId) => {
|
1493
1473
|
var _a2;
|
1494
1474
|
return new GoogleGenerativeAILanguageModel(modelId, {
|
@@ -1544,7 +1524,6 @@ function createGoogleGenerativeAI(options = {}) {
|
|
1544
1524
|
}
|
1545
1525
|
var google = createGoogleGenerativeAI();
|
1546
1526
|
export {
|
1547
|
-
VERSION,
|
1548
1527
|
createGoogleGenerativeAI,
|
1549
1528
|
google
|
1550
1529
|
};
|