@ai-sdk/google 3.0.90 → 3.0.91
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 -0
- package/dist/index.js +29 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -14
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +18 -4
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +18 -4
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/convert-to-google-generative-ai-messages.ts +8 -1
- package/src/google-generative-ai-language-model.ts +18 -1
- package/src/google-generative-ai-video-model.ts +11 -10
package/dist/internal/index.js
CHANGED
|
@@ -295,6 +295,8 @@ function appendLegacyToolResultParts(parts, toolName, outputValue, toolCallId) {
|
|
|
295
295
|
});
|
|
296
296
|
break;
|
|
297
297
|
case "image-data":
|
|
298
|
+
case "file-data": {
|
|
299
|
+
const topLevelMediaType = String(contentPart.mediaType).split("/")[0];
|
|
298
300
|
parts.push(
|
|
299
301
|
{
|
|
300
302
|
inlineData: {
|
|
@@ -303,10 +305,11 @@ function appendLegacyToolResultParts(parts, toolName, outputValue, toolCallId) {
|
|
|
303
305
|
}
|
|
304
306
|
},
|
|
305
307
|
{
|
|
306
|
-
text:
|
|
308
|
+
text: `Tool executed successfully and returned this ${topLevelMediaType === "image" ? "image" : "file"} as a response`
|
|
307
309
|
}
|
|
308
310
|
);
|
|
309
311
|
break;
|
|
312
|
+
}
|
|
310
313
|
default:
|
|
311
314
|
parts.push({ text: JSON.stringify(contentPart) });
|
|
312
315
|
break;
|
|
@@ -1237,6 +1240,12 @@ function mapGoogleGenerativeAIFinishReason({
|
|
|
1237
1240
|
}
|
|
1238
1241
|
|
|
1239
1242
|
// src/google-generative-ai-language-model.ts
|
|
1243
|
+
var configurableSafetySettingCategories = [
|
|
1244
|
+
"HARM_CATEGORY_HATE_SPEECH",
|
|
1245
|
+
"HARM_CATEGORY_DANGEROUS_CONTENT",
|
|
1246
|
+
"HARM_CATEGORY_HARASSMENT",
|
|
1247
|
+
"HARM_CATEGORY_SEXUALLY_EXPLICIT"
|
|
1248
|
+
];
|
|
1240
1249
|
var GoogleGenerativeAILanguageModel = class {
|
|
1241
1250
|
constructor(modelId, config) {
|
|
1242
1251
|
this.specificationVersion = "v3";
|
|
@@ -1267,7 +1276,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1267
1276
|
toolChoice,
|
|
1268
1277
|
providerOptions
|
|
1269
1278
|
}, { isStreaming = false } = {}) {
|
|
1270
|
-
var _a, _b;
|
|
1279
|
+
var _a, _b, _c;
|
|
1271
1280
|
const warnings = [];
|
|
1272
1281
|
const providerOptionsName = this.config.provider.includes("vertex") ? "vertex" : "google";
|
|
1273
1282
|
let googleOptions = await (0, import_provider_utils4.parseProviderOptions)({
|
|
@@ -1342,6 +1351,11 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1342
1351
|
isVertexProvider
|
|
1343
1352
|
});
|
|
1344
1353
|
const streamFunctionCallArguments = isStreaming && isVertexProvider ? (_a = googleOptions == null ? void 0 : googleOptions.streamFunctionCallArguments) != null ? _a : false : void 0;
|
|
1354
|
+
const safetyThreshold = googleOptions == null ? void 0 : googleOptions.threshold;
|
|
1355
|
+
const safetySettings = (_b = googleOptions == null ? void 0 : googleOptions.safetySettings) != null ? _b : safetyThreshold != null ? configurableSafetySettingCategories.map((category) => ({
|
|
1356
|
+
category,
|
|
1357
|
+
threshold: safetyThreshold
|
|
1358
|
+
})) : void 0;
|
|
1345
1359
|
const toolConfig = googleToolConfig || streamFunctionCallArguments || (googleOptions == null ? void 0 : googleOptions.retrievalConfig) ? {
|
|
1346
1360
|
...googleToolConfig,
|
|
1347
1361
|
...streamFunctionCallArguments && {
|
|
@@ -1371,7 +1385,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1371
1385
|
responseSchema: (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && // Google GenAI does not support all OpenAPI Schema features,
|
|
1372
1386
|
// so this is needed as an escape hatch:
|
|
1373
1387
|
// TODO convert into provider option
|
|
1374
|
-
((
|
|
1388
|
+
((_c = googleOptions == null ? void 0 : googleOptions.structuredOutputs) != null ? _c : true) ? convertJSONSchemaToOpenAPISchema(responseFormat.schema) : void 0,
|
|
1375
1389
|
...(googleOptions == null ? void 0 : googleOptions.audioTimestamp) && {
|
|
1376
1390
|
audioTimestamp: googleOptions.audioTimestamp
|
|
1377
1391
|
},
|
|
@@ -1387,7 +1401,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1387
1401
|
},
|
|
1388
1402
|
contents,
|
|
1389
1403
|
systemInstruction: isGemmaModel ? void 0 : systemInstruction,
|
|
1390
|
-
safetySettings
|
|
1404
|
+
safetySettings,
|
|
1391
1405
|
tools: googleTools2,
|
|
1392
1406
|
toolConfig,
|
|
1393
1407
|
cachedContent: googleOptions == null ? void 0 : googleOptions.cachedContent,
|