@ai-sdk/amazon-bedrock 4.0.127 → 4.0.129
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 +13 -0
- package/dist/anthropic/index.js +1 -1
- package/dist/anthropic/index.mjs +1 -1
- package/dist/index.js +19 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -11
- package/dist/index.mjs.map +1 -1
- package/dist/mantle/index.js +1 -1
- package/dist/mantle/index.mjs +1 -1
- package/package.json +3 -3
- package/src/bedrock-embedding-model.ts +24 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @ai-sdk/amazon-bedrock
|
|
2
2
|
|
|
3
|
+
## 4.0.129
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [4241b49]
|
|
8
|
+
- @ai-sdk/anthropic@3.0.93
|
|
9
|
+
|
|
10
|
+
## 4.0.128
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 3f9bc0f: feat(amazon-bedrock): increase limit of embeddings in a request for cohere models
|
|
15
|
+
|
|
3
16
|
## 4.0.127
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/anthropic/index.js
CHANGED
|
@@ -35,7 +35,7 @@ var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
|
35
35
|
var import_aws4fetch = require("aws4fetch");
|
|
36
36
|
|
|
37
37
|
// src/version.ts
|
|
38
|
-
var VERSION = true ? "4.0.
|
|
38
|
+
var VERSION = true ? "4.0.129" : "0.0.0-test";
|
|
39
39
|
|
|
40
40
|
// src/bedrock-sigv4-fetch.ts
|
|
41
41
|
function createSigV4FetchFunction(getCredentials, fetch, service = "bedrock") {
|
package/dist/anthropic/index.mjs
CHANGED
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
import { AwsV4Signer } from "aws4fetch";
|
|
25
25
|
|
|
26
26
|
// src/version.ts
|
|
27
|
-
var VERSION = true ? "4.0.
|
|
27
|
+
var VERSION = true ? "4.0.129" : "0.0.0-test";
|
|
28
28
|
|
|
29
29
|
// src/bedrock-sigv4-fetch.ts
|
|
30
30
|
function createSigV4FetchFunction(getCredentials, fetch, service = "bedrock") {
|
package/dist/index.js
CHANGED
|
@@ -1683,9 +1683,11 @@ var BedrockEmbeddingModel = class {
|
|
|
1683
1683
|
this.config = config;
|
|
1684
1684
|
this.specificationVersion = "v3";
|
|
1685
1685
|
this.provider = "amazon-bedrock";
|
|
1686
|
-
this.maxEmbeddingsPerCall = 1;
|
|
1687
1686
|
this.supportsParallelCalls = true;
|
|
1688
1687
|
}
|
|
1688
|
+
get maxEmbeddingsPerCall() {
|
|
1689
|
+
return isCohereEmbeddingModel(this.modelId) ? 96 : 1;
|
|
1690
|
+
}
|
|
1689
1691
|
getUrl(modelId) {
|
|
1690
1692
|
const encodedModelId = encodeURIComponent(modelId);
|
|
1691
1693
|
return `${this.config.baseUrl()}/model/${encodedModelId}/invoke`;
|
|
@@ -1710,8 +1712,8 @@ var BedrockEmbeddingModel = class {
|
|
|
1710
1712
|
providerOptions,
|
|
1711
1713
|
schema: amazonBedrockEmbeddingModelOptionsSchema
|
|
1712
1714
|
})) != null ? _a : {};
|
|
1713
|
-
const isNovaModel =
|
|
1714
|
-
const isCohereModel = this.modelId
|
|
1715
|
+
const isNovaModel = isNovaEmbeddingModel(this.modelId);
|
|
1716
|
+
const isCohereModel = isCohereEmbeddingModel(this.modelId);
|
|
1715
1717
|
const args = isNovaModel ? {
|
|
1716
1718
|
taskType: "SINGLE_EMBEDDING",
|
|
1717
1719
|
singleEmbeddingParams: {
|
|
@@ -1726,7 +1728,7 @@ var BedrockEmbeddingModel = class {
|
|
|
1726
1728
|
// Cohere embedding models on Bedrock require `input_type`.
|
|
1727
1729
|
// Without it, the service attempts other schema branches and rejects the request.
|
|
1728
1730
|
input_type: (_e = bedrockOptions.inputType) != null ? _e : "search_query",
|
|
1729
|
-
texts:
|
|
1731
|
+
texts: values,
|
|
1730
1732
|
truncate: bedrockOptions.truncate,
|
|
1731
1733
|
output_dimension: bedrockOptions.outputDimension
|
|
1732
1734
|
} : {
|
|
@@ -1751,30 +1753,36 @@ var BedrockEmbeddingModel = class {
|
|
|
1751
1753
|
fetch: this.config.fetch,
|
|
1752
1754
|
abortSignal
|
|
1753
1755
|
});
|
|
1754
|
-
let
|
|
1756
|
+
let embeddings;
|
|
1755
1757
|
if ("embedding" in response) {
|
|
1756
|
-
|
|
1758
|
+
embeddings = [response.embedding];
|
|
1757
1759
|
} else if (Array.isArray(response.embeddings)) {
|
|
1758
1760
|
const firstEmbedding = response.embeddings[0];
|
|
1759
1761
|
if (typeof firstEmbedding === "object" && firstEmbedding !== null && "embeddingType" in firstEmbedding) {
|
|
1760
|
-
|
|
1762
|
+
embeddings = [firstEmbedding.embedding];
|
|
1761
1763
|
} else {
|
|
1762
|
-
|
|
1764
|
+
embeddings = response.embeddings;
|
|
1763
1765
|
}
|
|
1764
1766
|
} else {
|
|
1765
|
-
|
|
1767
|
+
embeddings = response.embeddings.float;
|
|
1766
1768
|
}
|
|
1767
1769
|
const headerTokenCount = Number(
|
|
1768
1770
|
responseHeaders == null ? void 0 : responseHeaders["x-amzn-bedrock-input-token-count"]
|
|
1769
1771
|
);
|
|
1770
1772
|
const tokens = "inputTextTokenCount" in response ? response.inputTextTokenCount : "inputTokenCount" in response ? (_f = response.inputTokenCount) != null ? _f : 0 : headerTokenCount;
|
|
1771
1773
|
return {
|
|
1772
|
-
embeddings
|
|
1774
|
+
embeddings,
|
|
1773
1775
|
usage: { tokens },
|
|
1774
1776
|
warnings: []
|
|
1775
1777
|
};
|
|
1776
1778
|
}
|
|
1777
1779
|
};
|
|
1780
|
+
function isCohereEmbeddingModel(modelId) {
|
|
1781
|
+
return modelId.includes("cohere.embed-");
|
|
1782
|
+
}
|
|
1783
|
+
function isNovaEmbeddingModel(modelId) {
|
|
1784
|
+
return modelId.startsWith("amazon.nova-") && modelId.includes("embed");
|
|
1785
|
+
}
|
|
1778
1786
|
var BedrockEmbeddingResponseSchema = import_v46.z.union([
|
|
1779
1787
|
// Titan-style response
|
|
1780
1788
|
import_v46.z.object({
|
|
@@ -2015,7 +2023,7 @@ var import_provider_utils7 = require("@ai-sdk/provider-utils");
|
|
|
2015
2023
|
var import_aws4fetch = require("aws4fetch");
|
|
2016
2024
|
|
|
2017
2025
|
// src/version.ts
|
|
2018
|
-
var VERSION = true ? "4.0.
|
|
2026
|
+
var VERSION = true ? "4.0.129" : "0.0.0-test";
|
|
2019
2027
|
|
|
2020
2028
|
// src/bedrock-sigv4-fetch.ts
|
|
2021
2029
|
function createSigV4FetchFunction(getCredentials, fetch, service = "bedrock") {
|