@ai-sdk/google 4.0.10 → 4.0.11
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 +30 -15
- package/dist/index.js.map +1 -1
- package/dist/internal/index.js +17 -5
- package/dist/internal/index.js.map +1 -1
- package/docs/15-google.mdx +30 -44
- package/package.json +3 -3
- package/src/convert-to-google-messages.ts +7 -5
- package/src/google-language-model.ts +18 -1
- package/src/google-video-model.ts +12 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @ai-sdk/google
|
|
2
2
|
|
|
3
|
+
## 4.0.11
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 17d66c5: Fix Google tool result conversion to send file data as inline data instead of JSON text on the legacy tool-result path.
|
|
8
|
+
- 96d40bc: Expand standalone Google `threshold` provider options into safety settings.
|
|
9
|
+
- 0f93c57: feat (video): support video (not just image) reference inputs in `inputReferences` for reference-to-video generation
|
|
10
|
+
- Updated dependencies [0f93c57]
|
|
11
|
+
- @ai-sdk/provider@4.0.3
|
|
12
|
+
- @ai-sdk/provider-utils@5.0.7
|
|
13
|
+
|
|
3
14
|
## 4.0.10
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "@ai-sdk/provider-utils";
|
|
8
8
|
|
|
9
9
|
// src/version.ts
|
|
10
|
-
var VERSION = true ? "4.0.
|
|
10
|
+
var VERSION = true ? "4.0.11" : "0.0.0-test";
|
|
11
11
|
|
|
12
12
|
// src/google-embedding-model.ts
|
|
13
13
|
import {
|
|
@@ -526,7 +526,8 @@ function appendLegacyToolResultParts(parts, toolName, outputValue, toolCallId) {
|
|
|
526
526
|
});
|
|
527
527
|
break;
|
|
528
528
|
case "file": {
|
|
529
|
-
if (contentPart.data.type === "data"
|
|
529
|
+
if (contentPart.data.type === "data") {
|
|
530
|
+
const topLevelMediaType = getTopLevelMediaType(contentPart.mediaType);
|
|
530
531
|
parts.push(
|
|
531
532
|
{
|
|
532
533
|
inlineData: {
|
|
@@ -535,7 +536,7 @@ function appendLegacyToolResultParts(parts, toolName, outputValue, toolCallId) {
|
|
|
535
536
|
}
|
|
536
537
|
},
|
|
537
538
|
{
|
|
538
|
-
text:
|
|
539
|
+
text: `Tool executed successfully and returned this ${topLevelMediaType === "image" ? "image" : "file"} as a response`
|
|
539
540
|
}
|
|
540
541
|
);
|
|
541
542
|
} else {
|
|
@@ -1558,6 +1559,12 @@ function mapGoogleFinishReason({
|
|
|
1558
1559
|
}
|
|
1559
1560
|
|
|
1560
1561
|
// src/google-language-model.ts
|
|
1562
|
+
var configurableSafetySettingCategories = [
|
|
1563
|
+
"HARM_CATEGORY_HATE_SPEECH",
|
|
1564
|
+
"HARM_CATEGORY_DANGEROUS_CONTENT",
|
|
1565
|
+
"HARM_CATEGORY_HARASSMENT",
|
|
1566
|
+
"HARM_CATEGORY_SEXUALLY_EXPLICIT"
|
|
1567
|
+
];
|
|
1561
1568
|
var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
1562
1569
|
constructor(modelId, config) {
|
|
1563
1570
|
this.specificationVersion = "v4";
|
|
@@ -1598,7 +1605,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1598
1605
|
reasoning,
|
|
1599
1606
|
providerOptions
|
|
1600
1607
|
}, { isStreaming = false } = {}) {
|
|
1601
|
-
var _a, _b;
|
|
1608
|
+
var _a, _b, _c;
|
|
1602
1609
|
const warnings = [];
|
|
1603
1610
|
const providerOptionsNames = this.config.provider.includes("vertex") ? ["googleVertex", "vertex"] : ["google"];
|
|
1604
1611
|
let googleOptions;
|
|
@@ -1680,6 +1687,11 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1680
1687
|
});
|
|
1681
1688
|
const thinkingConfig = (googleOptions == null ? void 0 : googleOptions.thinkingConfig) || resolvedThinking ? { ...resolvedThinking, ...googleOptions == null ? void 0 : googleOptions.thinkingConfig } : void 0;
|
|
1682
1689
|
const streamFunctionCallArguments = isStreaming && isVertexProvider ? (_a = googleOptions == null ? void 0 : googleOptions.streamFunctionCallArguments) != null ? _a : false : void 0;
|
|
1690
|
+
const safetyThreshold = googleOptions == null ? void 0 : googleOptions.threshold;
|
|
1691
|
+
const safetySettings = (_b = googleOptions == null ? void 0 : googleOptions.safetySettings) != null ? _b : safetyThreshold != null ? configurableSafetySettingCategories.map((category) => ({
|
|
1692
|
+
category,
|
|
1693
|
+
threshold: safetyThreshold
|
|
1694
|
+
})) : void 0;
|
|
1683
1695
|
const toolConfig = googleToolConfig || streamFunctionCallArguments || (googleOptions == null ? void 0 : googleOptions.retrievalConfig) ? {
|
|
1684
1696
|
...googleToolConfig,
|
|
1685
1697
|
...streamFunctionCallArguments && {
|
|
@@ -1709,7 +1721,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1709
1721
|
responseSchema: (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && // Google GenAI does not support all OpenAPI Schema features,
|
|
1710
1722
|
// so this is needed as an escape hatch:
|
|
1711
1723
|
// TODO convert into provider option
|
|
1712
|
-
((
|
|
1724
|
+
((_c = googleOptions == null ? void 0 : googleOptions.structuredOutputs) != null ? _c : true) ? convertJSONSchemaToOpenAPISchema(responseFormat.schema) : void 0,
|
|
1713
1725
|
...(googleOptions == null ? void 0 : googleOptions.audioTimestamp) && {
|
|
1714
1726
|
audioTimestamp: googleOptions.audioTimestamp
|
|
1715
1727
|
},
|
|
@@ -1725,7 +1737,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1725
1737
|
},
|
|
1726
1738
|
contents,
|
|
1727
1739
|
systemInstruction: isGemmaModel ? void 0 : systemInstruction,
|
|
1728
|
-
safetySettings
|
|
1740
|
+
safetySettings,
|
|
1729
1741
|
tools: googleTools2,
|
|
1730
1742
|
toolConfig,
|
|
1731
1743
|
cachedContent: googleOptions == null ? void 0 : googleOptions.cachedContent,
|
|
@@ -3396,24 +3408,27 @@ function convertFileToGoogleImage(file, warnings) {
|
|
|
3396
3408
|
}
|
|
3397
3409
|
const base64Data = typeof file.data === "string" ? file.data : convertUint8ArrayToBase64(file.data);
|
|
3398
3410
|
return {
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
data: base64Data
|
|
3402
|
-
}
|
|
3411
|
+
bytesBase64Encoded: base64Data,
|
|
3412
|
+
mimeType: file.mediaType || "image/png"
|
|
3403
3413
|
};
|
|
3404
3414
|
}
|
|
3405
3415
|
function convertProviderReferenceImage(refImg) {
|
|
3406
3416
|
if (refImg.bytesBase64Encoded) {
|
|
3407
3417
|
return {
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
}
|
|
3418
|
+
image: {
|
|
3419
|
+
bytesBase64Encoded: refImg.bytesBase64Encoded,
|
|
3420
|
+
mimeType: "image/png"
|
|
3421
|
+
},
|
|
3422
|
+
referenceType: "asset"
|
|
3412
3423
|
};
|
|
3413
3424
|
}
|
|
3414
3425
|
if (refImg.gcsUri) {
|
|
3415
3426
|
return {
|
|
3416
|
-
|
|
3427
|
+
image: {
|
|
3428
|
+
gcsUri: refImg.gcsUri,
|
|
3429
|
+
mimeType: "image/png"
|
|
3430
|
+
},
|
|
3431
|
+
referenceType: "asset"
|
|
3417
3432
|
};
|
|
3418
3433
|
}
|
|
3419
3434
|
return refImg;
|