@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.mjs
CHANGED
|
@@ -277,6 +277,8 @@ function appendLegacyToolResultParts(parts, toolName, outputValue, toolCallId) {
|
|
|
277
277
|
});
|
|
278
278
|
break;
|
|
279
279
|
case "image-data":
|
|
280
|
+
case "file-data": {
|
|
281
|
+
const topLevelMediaType = String(contentPart.mediaType).split("/")[0];
|
|
280
282
|
parts.push(
|
|
281
283
|
{
|
|
282
284
|
inlineData: {
|
|
@@ -285,10 +287,11 @@ function appendLegacyToolResultParts(parts, toolName, outputValue, toolCallId) {
|
|
|
285
287
|
}
|
|
286
288
|
},
|
|
287
289
|
{
|
|
288
|
-
text:
|
|
290
|
+
text: `Tool executed successfully and returned this ${topLevelMediaType === "image" ? "image" : "file"} as a response`
|
|
289
291
|
}
|
|
290
292
|
);
|
|
291
293
|
break;
|
|
294
|
+
}
|
|
292
295
|
default:
|
|
293
296
|
parts.push({ text: JSON.stringify(contentPart) });
|
|
294
297
|
break;
|
|
@@ -1228,6 +1231,12 @@ function mapGoogleGenerativeAIFinishReason({
|
|
|
1228
1231
|
}
|
|
1229
1232
|
|
|
1230
1233
|
// src/google-generative-ai-language-model.ts
|
|
1234
|
+
var configurableSafetySettingCategories = [
|
|
1235
|
+
"HARM_CATEGORY_HATE_SPEECH",
|
|
1236
|
+
"HARM_CATEGORY_DANGEROUS_CONTENT",
|
|
1237
|
+
"HARM_CATEGORY_HARASSMENT",
|
|
1238
|
+
"HARM_CATEGORY_SEXUALLY_EXPLICIT"
|
|
1239
|
+
];
|
|
1231
1240
|
var GoogleGenerativeAILanguageModel = class {
|
|
1232
1241
|
constructor(modelId, config) {
|
|
1233
1242
|
this.specificationVersion = "v3";
|
|
@@ -1258,7 +1267,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1258
1267
|
toolChoice,
|
|
1259
1268
|
providerOptions
|
|
1260
1269
|
}, { isStreaming = false } = {}) {
|
|
1261
|
-
var _a, _b;
|
|
1270
|
+
var _a, _b, _c;
|
|
1262
1271
|
const warnings = [];
|
|
1263
1272
|
const providerOptionsName = this.config.provider.includes("vertex") ? "vertex" : "google";
|
|
1264
1273
|
let googleOptions = await parseProviderOptions({
|
|
@@ -1333,6 +1342,11 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1333
1342
|
isVertexProvider
|
|
1334
1343
|
});
|
|
1335
1344
|
const streamFunctionCallArguments = isStreaming && isVertexProvider ? (_a = googleOptions == null ? void 0 : googleOptions.streamFunctionCallArguments) != null ? _a : false : void 0;
|
|
1345
|
+
const safetyThreshold = googleOptions == null ? void 0 : googleOptions.threshold;
|
|
1346
|
+
const safetySettings = (_b = googleOptions == null ? void 0 : googleOptions.safetySettings) != null ? _b : safetyThreshold != null ? configurableSafetySettingCategories.map((category) => ({
|
|
1347
|
+
category,
|
|
1348
|
+
threshold: safetyThreshold
|
|
1349
|
+
})) : void 0;
|
|
1336
1350
|
const toolConfig = googleToolConfig || streamFunctionCallArguments || (googleOptions == null ? void 0 : googleOptions.retrievalConfig) ? {
|
|
1337
1351
|
...googleToolConfig,
|
|
1338
1352
|
...streamFunctionCallArguments && {
|
|
@@ -1362,7 +1376,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1362
1376
|
responseSchema: (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && // Google GenAI does not support all OpenAPI Schema features,
|
|
1363
1377
|
// so this is needed as an escape hatch:
|
|
1364
1378
|
// TODO convert into provider option
|
|
1365
|
-
((
|
|
1379
|
+
((_c = googleOptions == null ? void 0 : googleOptions.structuredOutputs) != null ? _c : true) ? convertJSONSchemaToOpenAPISchema(responseFormat.schema) : void 0,
|
|
1366
1380
|
...(googleOptions == null ? void 0 : googleOptions.audioTimestamp) && {
|
|
1367
1381
|
audioTimestamp: googleOptions.audioTimestamp
|
|
1368
1382
|
},
|
|
@@ -1378,7 +1392,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1378
1392
|
},
|
|
1379
1393
|
contents,
|
|
1380
1394
|
systemInstruction: isGemmaModel ? void 0 : systemInstruction,
|
|
1381
|
-
safetySettings
|
|
1395
|
+
safetySettings,
|
|
1382
1396
|
tools: googleTools2,
|
|
1383
1397
|
toolConfig,
|
|
1384
1398
|
cachedContent: googleOptions == null ? void 0 : googleOptions.cachedContent,
|