@ai-sdk/amazon-bedrock 5.0.66 → 5.0.67

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @ai-sdk/amazon-bedrock
2
2
 
3
+ ## 5.0.67
4
+
5
+ ### Patch Changes
6
+
7
+ - 030b4e1: Omit assistant messages when only cache points remain after unsigned reasoning is filtered.
8
+ - 5d2229e: feat(amazon-bedrock): add model family setting for embeddings to support ARN
9
+ - b2eb608: Accept citation deltas in Amazon Bedrock streaming responses.
10
+ - Updated dependencies [90192f1]
11
+ - @ai-sdk/provider-utils@5.0.33
12
+ - @ai-sdk/anthropic@4.0.45
13
+ - @ai-sdk/openai@4.0.51
14
+
3
15
  ## 5.0.66
4
16
 
5
17
  ### Patch Changes
@@ -24,7 +24,7 @@ import {
24
24
  import { AwsV4Signer } from "aws4fetch";
25
25
 
26
26
  // src/version.ts
27
- var VERSION = true ? "5.0.66" : "0.0.0-test";
27
+ var VERSION = true ? "5.0.67" : "0.0.0-test";
28
28
 
29
29
  // src/amazon-bedrock-sigv4-fetch.ts
30
30
  function createSigV4FetchFunction(getCredentials, fetch, service = "bedrock") {
package/dist/index.d.ts CHANGED
@@ -6,6 +6,15 @@ import { anthropicTools } from '@ai-sdk/anthropic/internal';
6
6
  import { ProviderV4, LanguageModelV4, EmbeddingModelV4, ImageModelV4, RerankingModelV4 } from '@ai-sdk/provider';
7
7
 
8
8
  type AmazonBedrockEmbeddingModelId = 'amazon.titan-embed-text-v1' | 'amazon.titan-embed-text-v2:0' | 'cohere.embed-english-v3' | 'cohere.embed-multilingual-v3' | (string & {});
9
+ type AmazonBedrockEmbeddingModelSettings = {
10
+ /**
11
+ * The embedding model family.
12
+ *
13
+ * Specify this when the model ID does not identify the underlying model,
14
+ * such as an application inference profile ARN.
15
+ */
16
+ modelFamily?: 'titan' | 'cohere' | 'nova';
17
+ };
9
18
  declare const amazonBedrockEmbeddingModelOptionsSchema: z.ZodObject<{
10
19
  dimensions: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<1024>, z.ZodLiteral<512>, z.ZodLiteral<256>]>>;
11
20
  normalize: z.ZodOptional<z.ZodBoolean>;
@@ -172,19 +181,19 @@ interface AmazonBedrockProvider extends ProviderV4 {
172
181
  /**
173
182
  * Creates a model for text embeddings.
174
183
  */
175
- embedding(modelId: AmazonBedrockEmbeddingModelId): EmbeddingModelV4;
184
+ embedding(modelId: AmazonBedrockEmbeddingModelId, settings?: AmazonBedrockEmbeddingModelSettings): EmbeddingModelV4;
176
185
  /**
177
186
  * Creates a model for text embeddings.
178
187
  */
179
- embeddingModel(modelId: AmazonBedrockEmbeddingModelId): EmbeddingModelV4;
188
+ embeddingModel(modelId: AmazonBedrockEmbeddingModelId, settings?: AmazonBedrockEmbeddingModelSettings): EmbeddingModelV4;
180
189
  /**
181
190
  * @deprecated Use `embedding` instead.
182
191
  */
183
- textEmbedding(modelId: AmazonBedrockEmbeddingModelId): EmbeddingModelV4;
192
+ textEmbedding(modelId: AmazonBedrockEmbeddingModelId, settings?: AmazonBedrockEmbeddingModelSettings): EmbeddingModelV4;
184
193
  /**
185
194
  * @deprecated Use `embeddingModel` instead.
186
195
  */
187
- textEmbeddingModel(modelId: AmazonBedrockEmbeddingModelId): EmbeddingModelV4;
196
+ textEmbeddingModel(modelId: AmazonBedrockEmbeddingModelId, settings?: AmazonBedrockEmbeddingModelSettings): EmbeddingModelV4;
188
197
  /**
189
198
  * Creates a model for image generation.
190
199
  */
@@ -217,4 +226,4 @@ declare const amazonBedrock: AmazonBedrockProvider;
217
226
 
218
227
  declare const VERSION: string;
219
228
 
220
- export { type AmazonBedrockEmbeddingModelOptions, type AmazonBedrockImageModelOptions, type AmazonBedrockLanguageModelChatOptions, type AmazonBedrockLanguageModelChatOptions as AmazonBedrockLanguageModelOptions, type AmazonBedrockProvider, type AmazonBedrockProviderSettings, type AmazonBedrockRerankingModelOptions, type AmazonBedrockLanguageModelChatOptions as BedrockProviderOptions, type AmazonBedrockRerankingModelOptions as BedrockRerankingOptions, VERSION, amazonBedrock, amazonBedrock as bedrock, createAmazonBedrock };
229
+ export { type AmazonBedrockEmbeddingModelOptions, type AmazonBedrockEmbeddingModelSettings, type AmazonBedrockImageModelOptions, type AmazonBedrockLanguageModelChatOptions, type AmazonBedrockLanguageModelChatOptions as AmazonBedrockLanguageModelOptions, type AmazonBedrockProvider, type AmazonBedrockProviderSettings, type AmazonBedrockRerankingModelOptions, type AmazonBedrockLanguageModelChatOptions as BedrockProviderOptions, type AmazonBedrockRerankingModelOptions as BedrockRerankingOptions, VERSION, amazonBedrock, amazonBedrock as bedrock, createAmazonBedrock };
package/dist/index.js CHANGED
@@ -964,7 +964,7 @@ async function convertToAmazonBedrockChatMessages(prompt, isMistral = false) {
964
964
  }
965
965
  pushCachePoint(amazonBedrockContent, message.providerOptions);
966
966
  }
967
- if (amazonBedrockContent.length > 0) {
967
+ if (amazonBedrockContent.some((block2) => !("cachePoint" in block2))) {
968
968
  messages.push({ role: "assistant", content: amazonBedrockContent });
969
969
  }
970
970
  break;
@@ -2066,6 +2066,9 @@ var AmazonBedrockStreamSchema = z4.object({
2066
2066
  contentBlockIndex: z4.number(),
2067
2067
  delta: z4.union([
2068
2068
  z4.object({ text: z4.string() }),
2069
+ z4.object({
2070
+ citation: z4.record(z4.string(), z4.unknown())
2071
+ }),
2069
2072
  z4.object({ toolUse: z4.object({ input: z4.string() }) }),
2070
2073
  z4.object({
2071
2074
  reasoningContent: z4.object({ text: z4.string() })
@@ -2264,7 +2267,11 @@ var AmazonBedrockEmbeddingModel = class _AmazonBedrockEmbeddingModel {
2264
2267
  this.supportsParallelCalls = true;
2265
2268
  }
2266
2269
  get maxEmbeddingsPerCall() {
2267
- return isCohereEmbeddingModel(this.modelId) ? 96 : 1;
2270
+ return this.modelFamily === "cohere" ? 96 : 1;
2271
+ }
2272
+ get modelFamily() {
2273
+ var _a;
2274
+ return (_a = this.config.modelFamily) != null ? _a : detectEmbeddingModelFamily(this.modelId);
2268
2275
  }
2269
2276
  static [WORKFLOW_SERIALIZE2](model) {
2270
2277
  return serializeModelOptions2({
@@ -2303,9 +2310,8 @@ var AmazonBedrockEmbeddingModel = class _AmazonBedrockEmbeddingModel {
2303
2310
  providerOptions,
2304
2311
  schema: amazonBedrockEmbeddingModelOptionsSchema
2305
2312
  })) != null ? _b : {};
2306
- const isNovaModel = isNovaEmbeddingModel(this.modelId);
2307
- const isCohereModel = isCohereEmbeddingModel(this.modelId);
2308
- const args = isNovaModel ? {
2313
+ const modelFamily = this.modelFamily;
2314
+ const args = modelFamily === "nova" ? {
2309
2315
  taskType: "SINGLE_EMBEDDING",
2310
2316
  singleEmbeddingParams: {
2311
2317
  embeddingPurpose: (_c = amazonBedrockOptions.embeddingPurpose) != null ? _c : "GENERIC_INDEX",
@@ -2315,7 +2321,7 @@ var AmazonBedrockEmbeddingModel = class _AmazonBedrockEmbeddingModel {
2315
2321
  value: values[0]
2316
2322
  }
2317
2323
  }
2318
- } : isCohereModel ? {
2324
+ } : modelFamily === "cohere" ? {
2319
2325
  // Cohere embedding models on Bedrock require `input_type`.
2320
2326
  // Without it, the service attempts other schema branches and rejects the request.
2321
2327
  input_type: (_f = amazonBedrockOptions.inputType) != null ? _f : "search_query",
@@ -2375,7 +2381,10 @@ function isCohereEmbeddingModel(modelId) {
2375
2381
  return modelId.includes("cohere.embed-");
2376
2382
  }
2377
2383
  function isNovaEmbeddingModel(modelId) {
2378
- return modelId.startsWith("amazon.nova-") && modelId.includes("embed");
2384
+ return modelId.includes("amazon.nova-") && modelId.includes("embed");
2385
+ }
2386
+ function detectEmbeddingModelFamily(modelId) {
2387
+ return isNovaEmbeddingModel(modelId) ? "nova" : isCohereEmbeddingModel(modelId) ? "cohere" : "titan";
2379
2388
  }
2380
2389
  var AmazonBedrockEmbeddingResponseSchema = z6.union([
2381
2390
  // Titan-style response
@@ -2690,7 +2699,7 @@ import {
2690
2699
  import { AwsV4Signer } from "aws4fetch";
2691
2700
 
2692
2701
  // src/version.ts
2693
- var VERSION = true ? "5.0.66" : "0.0.0-test";
2702
+ var VERSION = true ? "5.0.67" : "0.0.0-test";
2694
2703
 
2695
2704
  // src/amazon-bedrock-sigv4-fetch.ts
2696
2705
  function createSigV4FetchFunction(getCredentials, fetch, service = "bedrock") {
@@ -3013,10 +3022,11 @@ Original error: ${errorMessage}`
3013
3022
  }
3014
3023
  return createChatModel(modelId);
3015
3024
  };
3016
- const createEmbeddingModel = (modelId) => new AmazonBedrockEmbeddingModel(modelId, {
3025
+ const createEmbeddingModel = (modelId, settings = {}) => new AmazonBedrockEmbeddingModel(modelId, {
3017
3026
  baseUrl: getAmazonBedrockRuntimeBaseUrl,
3018
3027
  headers: getHeaders,
3019
- fetch: fetchFunction
3028
+ fetch: fetchFunction,
3029
+ modelFamily: settings.modelFamily
3020
3030
  });
3021
3031
  const createImageModel = (modelId) => new AmazonBedrockImageModel(modelId, {
3022
3032
  baseUrl: getAmazonBedrockRuntimeBaseUrl,