@ai-sdk/google 3.0.90 → 3.0.92
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 +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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @ai-sdk/google
|
|
2
2
|
|
|
3
|
+
## 3.0.92
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [06fb54c]
|
|
8
|
+
- @ai-sdk/provider-utils@4.0.39
|
|
9
|
+
|
|
10
|
+
## 3.0.91
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- bbac4da: Fix Google tool result conversion to send file data as inline data instead of JSON text on the legacy tool-result path.
|
|
15
|
+
- 3fda3bc: Expand standalone Google `threshold` provider options into safety settings.
|
|
16
|
+
- e1af05f: feat (video): support video (not just image) reference inputs in `inputReferences` for reference-to-video generation
|
|
17
|
+
- Updated dependencies [e1af05f]
|
|
18
|
+
- @ai-sdk/provider@3.0.14
|
|
19
|
+
- @ai-sdk/provider-utils@4.0.38
|
|
20
|
+
|
|
3
21
|
## 3.0.90
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -30,7 +30,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
30
30
|
var import_provider_utils23 = require("@ai-sdk/provider-utils");
|
|
31
31
|
|
|
32
32
|
// src/version.ts
|
|
33
|
-
var VERSION = true ? "3.0.
|
|
33
|
+
var VERSION = true ? "3.0.92" : "0.0.0-test";
|
|
34
34
|
|
|
35
35
|
// src/google-generative-ai-embedding-model.ts
|
|
36
36
|
var import_provider = require("@ai-sdk/provider");
|
|
@@ -511,6 +511,8 @@ function appendLegacyToolResultParts(parts, toolName, outputValue, toolCallId) {
|
|
|
511
511
|
});
|
|
512
512
|
break;
|
|
513
513
|
case "image-data":
|
|
514
|
+
case "file-data": {
|
|
515
|
+
const topLevelMediaType = String(contentPart.mediaType).split("/")[0];
|
|
514
516
|
parts.push(
|
|
515
517
|
{
|
|
516
518
|
inlineData: {
|
|
@@ -519,10 +521,11 @@ function appendLegacyToolResultParts(parts, toolName, outputValue, toolCallId) {
|
|
|
519
521
|
}
|
|
520
522
|
},
|
|
521
523
|
{
|
|
522
|
-
text:
|
|
524
|
+
text: `Tool executed successfully and returned this ${topLevelMediaType === "image" ? "image" : "file"} as a response`
|
|
523
525
|
}
|
|
524
526
|
);
|
|
525
527
|
break;
|
|
528
|
+
}
|
|
526
529
|
default:
|
|
527
530
|
parts.push({ text: JSON.stringify(contentPart) });
|
|
528
531
|
break;
|
|
@@ -1434,6 +1437,12 @@ function mapGoogleGenerativeAIFinishReason({
|
|
|
1434
1437
|
}
|
|
1435
1438
|
|
|
1436
1439
|
// src/google-generative-ai-language-model.ts
|
|
1440
|
+
var configurableSafetySettingCategories = [
|
|
1441
|
+
"HARM_CATEGORY_HATE_SPEECH",
|
|
1442
|
+
"HARM_CATEGORY_DANGEROUS_CONTENT",
|
|
1443
|
+
"HARM_CATEGORY_HARASSMENT",
|
|
1444
|
+
"HARM_CATEGORY_SEXUALLY_EXPLICIT"
|
|
1445
|
+
];
|
|
1437
1446
|
var GoogleGenerativeAILanguageModel = class {
|
|
1438
1447
|
constructor(modelId, config) {
|
|
1439
1448
|
this.specificationVersion = "v3";
|
|
@@ -1464,7 +1473,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1464
1473
|
toolChoice,
|
|
1465
1474
|
providerOptions
|
|
1466
1475
|
}, { isStreaming = false } = {}) {
|
|
1467
|
-
var _a, _b;
|
|
1476
|
+
var _a, _b, _c;
|
|
1468
1477
|
const warnings = [];
|
|
1469
1478
|
const providerOptionsName = this.config.provider.includes("vertex") ? "vertex" : "google";
|
|
1470
1479
|
let googleOptions = await (0, import_provider_utils6.parseProviderOptions)({
|
|
@@ -1539,6 +1548,11 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1539
1548
|
isVertexProvider
|
|
1540
1549
|
});
|
|
1541
1550
|
const streamFunctionCallArguments = isStreaming && isVertexProvider ? (_a = googleOptions == null ? void 0 : googleOptions.streamFunctionCallArguments) != null ? _a : false : void 0;
|
|
1551
|
+
const safetyThreshold = googleOptions == null ? void 0 : googleOptions.threshold;
|
|
1552
|
+
const safetySettings = (_b = googleOptions == null ? void 0 : googleOptions.safetySettings) != null ? _b : safetyThreshold != null ? configurableSafetySettingCategories.map((category) => ({
|
|
1553
|
+
category,
|
|
1554
|
+
threshold: safetyThreshold
|
|
1555
|
+
})) : void 0;
|
|
1542
1556
|
const toolConfig = googleToolConfig || streamFunctionCallArguments || (googleOptions == null ? void 0 : googleOptions.retrievalConfig) ? {
|
|
1543
1557
|
...googleToolConfig,
|
|
1544
1558
|
...streamFunctionCallArguments && {
|
|
@@ -1568,7 +1582,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1568
1582
|
responseSchema: (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && // Google GenAI does not support all OpenAPI Schema features,
|
|
1569
1583
|
// so this is needed as an escape hatch:
|
|
1570
1584
|
// TODO convert into provider option
|
|
1571
|
-
((
|
|
1585
|
+
((_c = googleOptions == null ? void 0 : googleOptions.structuredOutputs) != null ? _c : true) ? convertJSONSchemaToOpenAPISchema(responseFormat.schema) : void 0,
|
|
1572
1586
|
...(googleOptions == null ? void 0 : googleOptions.audioTimestamp) && {
|
|
1573
1587
|
audioTimestamp: googleOptions.audioTimestamp
|
|
1574
1588
|
},
|
|
@@ -1584,7 +1598,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1584
1598
|
},
|
|
1585
1599
|
contents,
|
|
1586
1600
|
systemInstruction: isGemmaModel ? void 0 : systemInstruction,
|
|
1587
|
-
safetySettings
|
|
1601
|
+
safetySettings,
|
|
1588
1602
|
tools: googleTools2,
|
|
1589
1603
|
toolConfig,
|
|
1590
1604
|
cachedContent: googleOptions == null ? void 0 : googleOptions.cachedContent,
|
|
@@ -2957,31 +2971,32 @@ function convertFileToGoogleImage(file, warnings) {
|
|
|
2957
2971
|
}
|
|
2958
2972
|
const base64Data = typeof file.data === "string" ? file.data : (0, import_provider_utils15.convertUint8ArrayToBase64)(file.data);
|
|
2959
2973
|
return {
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
data: base64Data
|
|
2963
|
-
}
|
|
2974
|
+
bytesBase64Encoded: base64Data,
|
|
2975
|
+
mimeType: file.mediaType || "image/png"
|
|
2964
2976
|
};
|
|
2965
2977
|
}
|
|
2966
2978
|
function convertProviderReferenceImage(refImg) {
|
|
2967
2979
|
if (refImg.bytesBase64Encoded) {
|
|
2968
2980
|
return {
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2981
|
+
image: {
|
|
2982
|
+
bytesBase64Encoded: refImg.bytesBase64Encoded,
|
|
2983
|
+
mimeType: "image/png"
|
|
2972
2984
|
}
|
|
2973
2985
|
};
|
|
2974
2986
|
}
|
|
2975
2987
|
if (refImg.gcsUri) {
|
|
2976
2988
|
return {
|
|
2977
|
-
|
|
2989
|
+
image: {
|
|
2990
|
+
gcsUri: refImg.gcsUri,
|
|
2991
|
+
mimeType: "image/png"
|
|
2992
|
+
}
|
|
2978
2993
|
};
|
|
2979
2994
|
}
|
|
2980
2995
|
return refImg;
|
|
2981
2996
|
}
|
|
2982
2997
|
function convertInputReferenceImage(file, warnings) {
|
|
2983
2998
|
const image = convertFileToGoogleImage(file, warnings);
|
|
2984
|
-
return image != null ? { image
|
|
2999
|
+
return image != null ? { image } : void 0;
|
|
2985
3000
|
}
|
|
2986
3001
|
var GoogleGenerativeAIVideoModel = class {
|
|
2987
3002
|
constructor(modelId, config) {
|