@wmaurer/effect-ai-amazon-bedrock 0.2.0 → 0.4.0
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 +21 -0
- package/README.md +98 -9
- package/dist/AmazonBedrockClient.d.ts +2 -2
- package/dist/AmazonBedrockClient.d.ts.map +1 -1
- package/dist/AmazonBedrockLanguageModel.d.ts +188 -25
- package/dist/AmazonBedrockLanguageModel.d.ts.map +1 -1
- package/dist/AmazonBedrockLanguageModel.js +203 -37
- package/dist/AmazonBedrockLanguageModel.js.map +1 -1
- package/dist/AmazonBedrockSchema.d.ts +240 -7
- package/dist/AmazonBedrockSchema.d.ts.map +1 -1
- package/dist/AmazonBedrockSchema.js +189 -10
- package/dist/AmazonBedrockSchema.js.map +1 -1
- package/dist/internal/errors.d.ts.map +1 -1
- package/dist/internal/errors.js +8 -0
- package/dist/internal/errors.js.map +1 -1
- package/dist/internal/guardrails.d.ts +15 -0
- package/dist/internal/guardrails.d.ts.map +1 -0
- package/dist/internal/guardrails.js +77 -0
- package/dist/internal/guardrails.js.map +1 -0
- package/dist/internal/utilities.d.ts +1 -1
- package/dist/internal/utilities.d.ts.map +1 -1
- package/dist/internal/utilities.js +4 -5
- package/dist/internal/utilities.js.map +1 -1
- package/package.json +1 -1
- package/src/AmazonBedrockClient.ts +2 -2
- package/src/AmazonBedrockLanguageModel.ts +422 -74
- package/src/AmazonBedrockSchema.ts +219 -12
- package/src/internal/errors.ts +14 -0
- package/src/internal/guardrails.ts +91 -0
- package/src/internal/utilities.ts +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @wmaurer/effect-ai-amazon-bedrock
|
|
2
2
|
|
|
3
|
+
## 0.4.0
|
|
4
|
+
|
|
5
|
+
Amazon Bedrock guardrails are supported. Every finish part now carries `metadata.amazonBedrock`, also without a guardrail.
|
|
6
|
+
|
|
7
|
+
- Add `guardrailConfig` to the request config. `generateText` and `generateObject` send it to Converse without `streamProcessingMode`, which only ConverseStream has, and `streamText` sends it as given. An override replaces the whole object, and `guardrailConfig: undefined` turns a layer's guardrail off for one request.
|
|
8
|
+
- Put `metadata.amazonBedrock` on every finish part, on `generateText` and on `streamText`. `stopReason` is the Converse stop reason as Bedrock sent it, so `guardrail_intervened` and `content_filtered` can be told apart, though both still finish with `"content-filter"`. `guardrail` says whether a guardrail blocked or masked the input and the output, read from the trace, and `trace` is the trace as Bedrock sent it. Both are `null` unless the guardrail config enables the trace.
|
|
9
|
+
- Fail `generateObject` with an `AiError` whose reason is `ContentPolicyError` when a guardrail intervened and the response holds no JSON. In 0.3.0 the blocked message reached the JSON decoder, which failed with a retryable `StructuredOutputError`. A guardrail that the account or organization enforces can cause this without any `guardrailConfig` in the request.
|
|
10
|
+
- Add the `guardContent` option to user text parts, system messages, and user PNG and JPEG file parts. Once a part has it, the guardrail evaluates only the parts that have it. On text, `qualifiers` names the role of the text in a contextual grounding check. Any other part with the option fails with `InvalidUserInputError`.
|
|
11
|
+
- `AmazonBedrockClient.Service.converseStream` takes the new `ConverseStreamRequest`, and `Config` is derived from it. The new schemas `GuardrailConfiguration`, `GuardrailStreamConfiguration`, and `GuardrailConverseContentBlock` follow the Smithy shapes, and `ConverseResponse` and `ConverseStreamMetadataEvent` decode `trace`.
|
|
12
|
+
- Name the account data retention setting in the `InvalidRequestError` when Bedrock rejects a model with `data retention mode '<mode>' is not available for this model`. Claude Fable 5 and 5.1 need the mode `aws_review`, and the Converse API has no request field for it, so the AWS message alone did not say how to make the model callable. The README section "Choose a model" explains the setting.
|
|
13
|
+
|
|
14
|
+
## 0.3.0
|
|
15
|
+
|
|
16
|
+
`generateObject` asks models outside Anthropic for the object through a tool. In 0.2.0 it sent them `outputConfig.textFormat`, which Nova, Mistral Large 2402, Pixtral Large, Llama, and Palmyra answered with a 400 in probes in `eu-west-1` and `us-east-1`, so `generateObject` on these models failed unless you set `structuredOutputs: false`.
|
|
17
|
+
|
|
18
|
+
- Choose how `generateObject` asks for the object from the provider that the model ID names. Claude models keep the 0.2.0 behavior. Meta and Writer models get the object tool unforced, with a system prompt line that tells the model to call it, because Llama and Palmyra reject a forced `toolChoice`. Models of every other provider get the forced object tool. An ARN that does not name its model, such as an application inference profile, keeps the 0.2.0 behavior. `Config.structuredOutputs` and `Config.forcedToolChoice` still override the choice.
|
|
19
|
+
- Models of other providers that accepted `outputConfig.textFormat` in the probes, such as gpt-5.x, Grok, Qwen, GLM, MiniMax, DeepSeek V3.2, and Mistral Large 3, also get the object tool now. The object tool replaces the tools that you pass to `generateObject`, and in 0.2.0 these models kept them. Set `structuredOutputs: true` to keep the 0.2.0 behavior.
|
|
20
|
+
- Force the object tool with `toolChoice` `{ any: {} }` in place of `{ tool: { name } }`. The object tool is the only tool in its request, so both force it, and Mistral Large 2402 and Pixtral Large accept only `any`. A `toolChoice` that you pass with your own tools goes to Bedrock as before.
|
|
21
|
+
- Fail `streamText` with an `AiError` whose reason is `InvalidOutputError` when Bedrock streams tool input that is not valid JSON. In 0.2.0 the stream died with a defect. Bedrock streamed such input for Qwen3 32B in each probe run.
|
|
22
|
+
- Decode a stop reason outside the nine that the Converse API names, and give it the finish reason `"other"`. In 0.2.0 such a reason failed `generateText` and `streamText` with an `InvalidOutputError`, and the text before it was lost. The `StopReason` type now admits any string, so a `switch` over it that was exhaustive needs a `default` case, and a `Record` keyed by it no longer compiles. The new `KnownStopReason` schema holds the nine.
|
|
23
|
+
|
|
3
24
|
## 0.2.0
|
|
4
25
|
|
|
5
26
|
`AmazonBedrockClient.layer`, `layerConfig`, and `make` take one of three ways to authenticate: the fixed keys of 0.1.0, a `credentialProvider`, or a Bedrock `apiKey`. Options that mix two ways, or give none, do not compile. Every 0.1.0 call compiles and runs unchanged.
|
package/README.md
CHANGED
|
@@ -231,11 +231,13 @@ The other options are these:
|
|
|
231
231
|
|
|
232
232
|
Give a Bedrock model ID or an inference profile ID as the first argument of `AmazonBedrockLanguageModel.model`, or as the `model` option of `AmazonBedrockLanguageModel.layer`. Some models accept only an inference profile ID. The live suites call Claude Sonnet 4.5 through `eu.anthropic.claude-sonnet-4-5-20250929-v1:0`, and their setup notes that Bedrock rejects its bare foundation-model ID. The model must be enabled for your account in the region of the client.
|
|
233
233
|
|
|
234
|
+
Claude Fable 5 and 5.1 also need the account's data retention mode in that region to be `aws_review`, or the older `provider_data_share`. Under that mode AWS keeps the prompts and outputs of these models for up to 30 days and may review them, and AWS's [data retention guide](https://docs.aws.amazon.com/bedrock/latest/userguide/data-retention.html) says it does not share them with Anthropic. The Converse API has no request field for the mode. You set it once for each region through the Bedrock control plane's `PutAccountDataRetention` operation, as that guide shows. Until then Bedrock rejects every request to these models with `data retention mode 'default' is not available for this model`, and the provider adds a pointer to the setting to the `InvalidRequestError`.
|
|
235
|
+
|
|
234
236
|
To set request defaults, give them as the second argument of `model` or as the `config` option of `layer`. The defaults take these fields:
|
|
235
237
|
|
|
236
238
|
- `inferenceConfig`, `additionalModelRequestFields`, and `toolConfig`. The provider sends each one as the Converse request field of the same name.
|
|
237
239
|
- `outputConfig`, which takes only `effort`. The provider sets `outputConfig.textFormat` itself. `effort` is `low`, `medium`, `high`, `xhigh`, or `max`, and a higher level lets the model reason longer before it answers. The Bedrock Runtime API model documents that the level is capped at `high` when extended thinking is off. Not every model takes `effort`. On 2026-10-17 Bedrock rejected it for Claude Sonnet 4.5 and Haiku 4.5 with `This model doesn't support the effort field`.
|
|
238
|
-
- `structuredOutputs` and `forcedToolChoice`, which
|
|
240
|
+
- `structuredOutputs` and `forcedToolChoice`, which override how `generateObject` asks for the object on the model you chose. The provider does not send them to Bedrock. [Get structured output](#get-structured-output) explains them.
|
|
239
241
|
|
|
240
242
|
When `generateObject` asks for the object through a tool, that tool replaces your `toolConfig`. Any other request with tools replaces it with a `toolConfig` built from those tools, unless `toolChoice` is `"none"`. With no tools, or with `toolChoice` set to `"none"`, the provider sends your `toolConfig` unchanged.
|
|
241
243
|
|
|
@@ -284,22 +286,35 @@ export const adaptiveAnswer = LanguageModel.generateText({
|
|
|
284
286
|
|
|
285
287
|
## Get structured output
|
|
286
288
|
|
|
287
|
-
`LanguageModel.generateText`, `LanguageModel.streamText`, and `LanguageModel.generateObject` all work with this provider.
|
|
289
|
+
`LanguageModel.generateText`, `LanguageModel.streamText`, and `LanguageModel.generateObject` all work with this provider. `generateObject` asks for the object in one of three ways, and the provider that the model ID names decides which:
|
|
290
|
+
|
|
291
|
+
- A Claude model gets the schema in the Converse `outputConfig.textFormat` field, and the tools you pass go with it.
|
|
292
|
+
- A Meta or Writer model gets the schema as a tool that it is not forced to call, and the provider adds a system prompt line that tells the model to call it.
|
|
293
|
+
- A model of any other provider, such as Amazon Nova, Mistral, OpenAI, or Qwen, gets the schema as a tool that `toolChoice` `{ any: {} }` forces it to call.
|
|
294
|
+
|
|
295
|
+
The provider is the first part of the model ID, or the second part after a geo prefix: `anthropic` in `eu.anthropic.claude-opus-4-8`, `amazon` in `amazon.nova-pro-v1:0`. A foundation model ARN or an inference profile ARN names its model at the end. The tool replaces the tools you pass, and the tool's input becomes the object. If the model calls the tool more than once, the first call is the object. If the model answers in text instead of calling the tool, `effect/ai` decodes the text as the object. On every path, the provider converts the schema with the rules for Anthropic models.
|
|
288
296
|
|
|
289
|
-
|
|
297
|
+
Probes on 2026-10-17 sent one Converse request per model and path through the `eu-west-1` and `us-east-1` endpoints. Of the models outside Anthropic:
|
|
290
298
|
|
|
291
|
-
The
|
|
299
|
+
- The models that answered `outputConfig` with a 400 include Nova, Mistral Large 2402, Pixtral Large, Llama, and Palmyra. gpt-oss-120b accepted it, but wrote text before the JSON in 3 of 4 runs.
|
|
300
|
+
- The tool forced with `any` returned the object on 13 of the 14 models in `eu-west-1`, and on every one of the 17 models in `us-east-1` that accept a forced tool. Mistral Large 2402 and Pixtral Large answer a named tool in `toolChoice` with a 400, and Gemma 3 27B ignores it, but all three accept `any`.
|
|
301
|
+
- Llama 3.1, 3.3, and 4 and Palmyra X4 and X5 answered `any` with a 400. The unforced tool returned the object on Llama 3.1 8B, Llama 4 Scout, Llama 4 Maverick, and Palmyra X5, and a wrong object on Llama 3.1 70B and Llama 3.3 70B.
|
|
302
|
+
- No path returned the object on Magistral Small. Llama 3 70B, Mistral 7B, Mixtral 8x7B, and DeepSeek R1 reject tool use and `outputConfig`, so `generateObject` does not work on them.
|
|
292
303
|
|
|
293
|
-
|
|
304
|
+
A probe on the same day sent one request per path to 17 Claude inference profiles through the `eu-west-1` endpoint. Every profile that served the probe's requests, 12 of the 17, accepted `outputConfig.textFormat`: Claude Haiku 4.5 and 5.5, Opus 4.5, 4.6, 4.7, 4.8, 5, and 5.5, and Sonnet 4.5, 4.6, 5, and 5.5. On Opus 4.8, Opus 5.5, and Sonnet 5.5 it also accepted `outputConfig.textFormat` together with `effort`, with adaptive thinking, and next to a strict tool. Fable 5 and 5.1 rejected every request, with or without `outputConfig.textFormat`, with `data retention mode 'default' is not available for this model`, because the probe account's data retention mode was not `aws_review`. The other three profiles have reached end of life.
|
|
305
|
+
|
|
306
|
+
The provider keeps a list of Claude models that get the forced tool instead: the Claude 3 models and Claude Sonnet 4 and Opus 4. The list comes from Anthropic's table of models with structured output. The probe could not check it on Bedrock. Claude 3 Haiku, Claude 3 Sonnet, and Sonnet 4 have reached end of life in `eu-west-1`, and the probe did not try the other models on the list.
|
|
307
|
+
|
|
308
|
+
In the probe, Claude Opus 5.5 and Sonnet 5.5 rejected a forced `toolChoice` with `tool_choice: type "tool" and "any" are not supported for this model`. The provider also treats Fable 5.1 and Mythos 5.1 as rejecting it, which nobody has checked on Bedrock. For these four models the provider leaves the tool unforced and adds the system prompt line. They take the tool path only when `structuredOutputs` is `false`, or when the prompt holds tool calls and no tools go out.
|
|
294
309
|
|
|
295
310
|
When the prompt holds tool calls or tool results and the request offers no tools, `generateObject` uses the tool on every model, even with `structuredOutputs: true`. Converse rejects such a request unless it carries a `toolConfig`, and the object tool is one.
|
|
296
311
|
|
|
297
|
-
|
|
312
|
+
Two config fields override what the model ID decides, and the provider sends neither to Bedrock:
|
|
298
313
|
|
|
299
314
|
- `structuredOutputs` set to `true` sends `outputConfig.textFormat` to any model, except when the prompt holds tool calls and no tools go out. Set to `false`, it sends the tool.
|
|
300
315
|
- `forcedToolChoice` set to `true` forces the tool, and set to `false` leaves it unforced. It has an effect only on the tool path. It does not change a `toolChoice` you pass with your own tools: `"required"` and a named tool go to Bedrock as `any` and `tool`, and the probe's error from Opus 5.5 and Sonnet 5.5 names both as unsupported.
|
|
301
316
|
|
|
302
|
-
A model ID that does not name the model, such as an application inference profile ARN, gets `outputConfig.textFormat`, or a forced tool when `structuredOutputs` is `false`. With tool history and no tools it also gets a forced tool by default. Behind an ARN that wraps Opus 5.5 or Sonnet 5.5, set `forcedToolChoice: false` for that case. To send the unforced tool through such an ARN in every case, set both fields:
|
|
317
|
+
A model ID that does not name the model, such as an application inference profile ARN, gets what a Claude model gets: `outputConfig.textFormat`, or a forced tool when `structuredOutputs` is `false`. With tool history and no tools it also gets a forced tool by default. Behind an ARN that wraps Opus 5.5 or Sonnet 5.5, set `forcedToolChoice: false` for that case. Behind an ARN that wraps a model of another provider, set `structuredOutputs: false`, and also `forcedToolChoice: false` for a Meta or Writer model. To send the unforced tool through such an ARN in every case, set both fields:
|
|
303
318
|
|
|
304
319
|
```ts
|
|
305
320
|
import { AmazonBedrockLanguageModel } from "@wmaurer/effect-ai-amazon-bedrock"
|
|
@@ -310,6 +325,79 @@ export const Opus = AmazonBedrockLanguageModel.model(
|
|
|
310
325
|
)
|
|
311
326
|
```
|
|
312
327
|
|
|
328
|
+
## Apply a guardrail
|
|
329
|
+
|
|
330
|
+
Create the guardrail in Amazon Bedrock first, in the region of your requests. This package does not create one. Then name it in `guardrailConfig`:
|
|
331
|
+
|
|
332
|
+
```ts
|
|
333
|
+
import { AmazonBedrockLanguageModel } from "@wmaurer/effect-ai-amazon-bedrock"
|
|
334
|
+
|
|
335
|
+
export const Guarded = AmazonBedrockLanguageModel.model("eu.anthropic.claude-sonnet-4-5-20250929-v1:0", {
|
|
336
|
+
guardrailConfig: {
|
|
337
|
+
guardrailIdentifier: "abc123xyz",
|
|
338
|
+
guardrailVersion: "1",
|
|
339
|
+
trace: "enabled"
|
|
340
|
+
}
|
|
341
|
+
})
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
`guardrailVersion` is a version number or `"DRAFT"`. `streamProcessingMode`, `"sync"` or `"async"`, applies to `streamText` only, and `generateText` does not send it. In `"async"` mode the text arrives before the guardrail has evaluated it. A live run on 2026-10-18 streamed the blocked word before the finish part reported the block. In `"sync"` mode, the default, the same request streamed only the blocked message. An override replaces the whole `guardrailConfig`, and `AmazonBedrockLanguageModel.withConfigOverride({ guardrailConfig: undefined })` turns the guardrail off for one request.
|
|
345
|
+
|
|
346
|
+
When the guardrail blocks, Bedrock answers with the blocked message that the guardrail configures as the response text, and the finish reason is `"content-filter"`. A blocked input costs no model tokens. Every finish part, on `generateText` and on `streamText`, holds `metadata.amazonBedrock`:
|
|
347
|
+
|
|
348
|
+
- `stopReason` is the Converse stop reason as Bedrock sent it. It tells `guardrail_intervened` from `content_filtered`, which both give `"content-filter"`. AWS does not define `content_filtered`. Reports from other projects say Converse sends it when the model's own classifier refuses, with no guardrail involved.
|
|
349
|
+
- `guardrail` is `{ input, output, policies }` when the response holds a guardrail trace, and `null` otherwise. `input` and `output` are `"blocked"`, `"masked"`, or `"none"`. A masked answer is usable, with the sensitive values replaced, and it also has the stop reason `guardrail_intervened`. `policies` names the policies that acted, such as `"wordPolicy"`.
|
|
350
|
+
- `trace` is the Converse trace as Bedrock sent it, or `null`.
|
|
351
|
+
|
|
352
|
+
Bedrock returns the trace only when `trace` is `"enabled"` or `"enabled_full"`. The trace holds the text that a policy matched, unmasked, so it reaches anything that logs or stores the response parts.
|
|
353
|
+
|
|
354
|
+
```ts
|
|
355
|
+
import { Effect } from "effect"
|
|
356
|
+
import { LanguageModel } from "effect/ai"
|
|
357
|
+
|
|
358
|
+
export const answer = Effect.gen(function*() {
|
|
359
|
+
const response = yield* LanguageModel.generateText({ prompt: "What is the capital of Australia?" })
|
|
360
|
+
const bedrock = response.content.find((part) => part.type === "finish")?.metadata.amazonBedrock
|
|
361
|
+
if (bedrock?.guardrail?.output === "blocked") {
|
|
362
|
+
return "The guardrail blocked the answer."
|
|
363
|
+
}
|
|
364
|
+
return response.text
|
|
365
|
+
})
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
`generateObject` fails with an `AiError` whose reason is `ContentPolicyError` when the guardrail intervened and the response holds no JSON. Its `metadata.amazonBedrock` is that of the finish part. The error is not retryable, because a retry meets the same block. A masked object is still JSON, and `generateObject` decodes it as usual.
|
|
369
|
+
|
|
370
|
+
### Choose what the guardrail evaluates
|
|
371
|
+
|
|
372
|
+
Without `guardContent`, the guardrail evaluates every message but not the system prompt. Once any part of a request has `guardContent`, the guardrail evaluates only the parts that have it. The model still reads every part. `guardContent` goes on a user text part, a system message, or a user file part with a PNG or JPEG image given as base64 or a `Uint8Array`. Any other part with it fails with `InvalidUserInputError`. On text, `qualifiers` names the role of the text in a contextual grounding check:
|
|
373
|
+
|
|
374
|
+
```ts
|
|
375
|
+
import { Prompt } from "effect/ai"
|
|
376
|
+
|
|
377
|
+
declare const policyText: string
|
|
378
|
+
|
|
379
|
+
export const prompt = Prompt.fromMessages([
|
|
380
|
+
Prompt.makeMessage("system", {
|
|
381
|
+
content: "Answer from the policy only.",
|
|
382
|
+
options: { amazonBedrock: { guardContent: true } }
|
|
383
|
+
}),
|
|
384
|
+
Prompt.makeMessage("user", {
|
|
385
|
+
content: [
|
|
386
|
+
Prompt.makePart("text", {
|
|
387
|
+
text: policyText,
|
|
388
|
+
options: { amazonBedrock: { guardContent: { qualifiers: ["grounding_source"] } } }
|
|
389
|
+
}),
|
|
390
|
+
Prompt.makePart("text", {
|
|
391
|
+
text: "Can I get a refund after 45 days?",
|
|
392
|
+
options: { amazonBedrock: { guardContent: { qualifiers: ["query"] } } }
|
|
393
|
+
})
|
|
394
|
+
]
|
|
395
|
+
})
|
|
396
|
+
])
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
The option stays on the part, so in a `Chat` a guarded turn is evaluated again on every later turn.
|
|
400
|
+
|
|
313
401
|
## Set Bedrock options on a prompt
|
|
314
402
|
|
|
315
403
|
The provider reads its options from the `amazonBedrock` key of the `options` field on prompt messages and parts.
|
|
@@ -387,10 +475,11 @@ Converse has features that this provider does not model yet:
|
|
|
387
475
|
- Video blocks. A `video/*` file part fails with `InvalidUserInputError`.
|
|
388
476
|
- Documents given as pre-chunked `content`.
|
|
389
477
|
- The `error` field of an image block.
|
|
390
|
-
- The `audio`, `
|
|
478
|
+
- The `audio`, `searchResult`, `toolAddition`, and `toolRemoval` content blocks, which the provider decodes and ignores.
|
|
391
479
|
- Citations with a `web` or `searchResultLocation` location, which the provider drops.
|
|
392
480
|
- System tools, which run on Bedrock.
|
|
393
|
-
- The Converse request fields `
|
|
481
|
+
- The Converse request fields `promptVariables`, `requestMetadata`, `performanceConfig`, and `serviceTier`. The request config has no key for them.
|
|
482
|
+
- The `ApplyGuardrail` operation, which evaluates content without a model call.
|
|
394
483
|
|
|
395
484
|
`LanguageModel.streamText` always asks for text, so streamed structured output is not available. That limit is in `effect/ai`, not in this provider.
|
|
396
485
|
|
|
@@ -23,7 +23,7 @@ import * as HttpClient from "effect/http/HttpClient";
|
|
|
23
23
|
import * as Layer from "effect/Layer";
|
|
24
24
|
import type * as Redacted from "effect/Redacted";
|
|
25
25
|
import * as Stream from "effect/Stream";
|
|
26
|
-
import type { ConverseRequest } from "./AmazonBedrockSchema.ts";
|
|
26
|
+
import type { ConverseRequest, ConverseStreamRequest } from "./AmazonBedrockSchema.ts";
|
|
27
27
|
import { ConverseResponse, ConverseResponseStreamEvent } from "./AmazonBedrockSchema.ts";
|
|
28
28
|
/**
|
|
29
29
|
* Represents the Amazon Bedrock client service with methods for the Converse
|
|
@@ -46,7 +46,7 @@ export interface Service {
|
|
|
46
46
|
* all errors to the unified `AiError` type.
|
|
47
47
|
*/
|
|
48
48
|
readonly converseStream: (options: {
|
|
49
|
-
readonly payload: typeof
|
|
49
|
+
readonly payload: typeof ConverseStreamRequest.Encoded;
|
|
50
50
|
}) => Stream.Stream<ConverseResponseStreamEvent, AiError.AiError>;
|
|
51
51
|
}
|
|
52
52
|
declare const AmazonBedrockClient_base: Context.ServiceClass<AmazonBedrockClient, "@wmaurer/effect-ai-amazon-bedrock/AmazonBedrockClient", Service>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AmazonBedrockClient.d.ts","sourceRoot":"","sources":["../src/AmazonBedrockClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,KAAK,OAAO,MAAM,mBAAmB,CAAA;AAEjD,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAA;AAC5C,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAIvC,OAAO,KAAK,UAAU,MAAM,wBAAwB,CAAA;AAGpD,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,KAAK,QAAQ,MAAM,iBAAiB,CAAA;AAChD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAGvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"AmazonBedrockClient.d.ts","sourceRoot":"","sources":["../src/AmazonBedrockClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,KAAK,OAAO,MAAM,mBAAmB,CAAA;AAEjD,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAA;AAC5C,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAIvC,OAAO,KAAK,UAAU,MAAM,wBAAwB,CAAA;AAGpD,OAAO,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AAM,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAA;IACzD,QAAQ,CAAC,WAAW,CAAC,EAAE,KAAK,CAAA;IAC5B,QAAQ,CAAC,eAAe,CAAC,EAAE,KAAK,CAAA;IAChC,QAAQ,CAAC,YAAY,CAAC,EAAE,KAAK,CAAA;IAC7B,QAAQ,CAAC,kBAAkB,CAAC,EAAE,KAAK,CAAA;CACpC,CACF,CAAA;AAcH;;;;;;GAMG;AACH,eAAO,MAAM,IAAI,GAAI,CAAC,GAAG,KAAK,WAAW,OAAO,CAAC,CAAC,CAAC,KAAG,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,EAAE,UAAU,CAAC,UAAU,GAAG,CAAC,CACxF,CAAA;AA8FrB;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,GAAI,CAAC,GAAG,KAAK,WACpB,OAAO,CAAC,CAAC,CAAC,KAClB,KAAK,CAAC,KAAK,CAAC,mBAAmB,EAAE,KAAK,EAAE,UAAU,CAAC,UAAU,GAAG,CAAC,CAClB,CAAA;AAElD;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,GAAG,KAAK,WAC1B,aAAa,CAAC,CAAC,CAAC,KACxB,KAAK,CAAC,KAAK,CAAC,mBAAmB,EAAE,MAAM,CAAC,WAAW,EAAE,UAAU,CAAC,UAAU,GAAG,CAAC,CAe9E,CAAA"}
|
|
@@ -3,8 +3,9 @@ import * as AiModel from "effect/ai/Model";
|
|
|
3
3
|
import * as Context from "effect/Context";
|
|
4
4
|
import * as Effect from "effect/Effect";
|
|
5
5
|
import * as Layer from "effect/Layer";
|
|
6
|
+
import type * as Schema from "effect/Schema";
|
|
6
7
|
import { AmazonBedrockClient } from "./AmazonBedrockClient.ts";
|
|
7
|
-
import type { CachePointBlock, CitationsConfig } from "./AmazonBedrockSchema.ts";
|
|
8
|
+
import type { CachePointBlock, CitationsConfig, GuardrailConverseContentQualifier, GuardrailStreamConfiguration } from "./AmazonBedrockSchema.ts";
|
|
8
9
|
/**
|
|
9
10
|
* A Bedrock model identifier or cross-region inference profile id (e.g.
|
|
10
11
|
* `us.anthropic.claude-sonnet-4-5-20250929-v1:0`).
|
|
@@ -74,15 +75,6 @@ interface CachePointOptions {
|
|
|
74
75
|
} | null;
|
|
75
76
|
}
|
|
76
77
|
declare module "effect/ai/Prompt" {
|
|
77
|
-
/**
|
|
78
|
-
* Amazon Bedrock options for system messages.
|
|
79
|
-
*
|
|
80
|
-
* @stability unstable
|
|
81
|
-
* @category models
|
|
82
|
-
* @since 0.1.0
|
|
83
|
-
*/
|
|
84
|
-
interface SystemMessageOptions extends CachePointOptions {
|
|
85
|
-
}
|
|
86
78
|
/**
|
|
87
79
|
* Amazon Bedrock options for user messages.
|
|
88
80
|
*
|
|
@@ -110,15 +102,6 @@ declare module "effect/ai/Prompt" {
|
|
|
110
102
|
*/
|
|
111
103
|
interface ToolMessageOptions extends CachePointOptions {
|
|
112
104
|
}
|
|
113
|
-
/**
|
|
114
|
-
* Amazon Bedrock options for text prompt parts.
|
|
115
|
-
*
|
|
116
|
-
* @stability unstable
|
|
117
|
-
* @category models
|
|
118
|
-
* @since 0.1.0
|
|
119
|
-
*/
|
|
120
|
-
interface TextPartOptions extends CachePointOptions {
|
|
121
|
-
}
|
|
122
105
|
/**
|
|
123
106
|
* Amazon Bedrock options for tool call prompt parts.
|
|
124
107
|
*
|
|
@@ -174,6 +157,13 @@ interface FileOptions {
|
|
|
174
157
|
* Converse cannot cite.
|
|
175
158
|
*/
|
|
176
159
|
readonly citations?: Citations | null;
|
|
160
|
+
/**
|
|
161
|
+
* Sends the image as a `guardContent` image block, for the guardrail to
|
|
162
|
+
* evaluate. Only an `image/png` or `image/jpeg` part whose data is bytes
|
|
163
|
+
* or base64 can be guarded. Any other file part with this option fails
|
|
164
|
+
* the request with `InvalidUserInputError`.
|
|
165
|
+
*/
|
|
166
|
+
readonly guardContent?: true | null;
|
|
177
167
|
} | null;
|
|
178
168
|
}
|
|
179
169
|
declare module "effect/ai/Prompt" {
|
|
@@ -292,6 +282,168 @@ declare module "effect/ai/Response" {
|
|
|
292
282
|
} | null;
|
|
293
283
|
}
|
|
294
284
|
}
|
|
285
|
+
/**
|
|
286
|
+
* A guardrail to apply to every request, set as `Config.guardrailConfig`.
|
|
287
|
+
*
|
|
288
|
+
* **Details**
|
|
289
|
+
*
|
|
290
|
+
* `generateText` and `generateObject` send it to Converse without
|
|
291
|
+
* `streamProcessingMode`, which Converse does not have. `streamText` sends it
|
|
292
|
+
* to ConverseStream as given.
|
|
293
|
+
*
|
|
294
|
+
* Without `guardContent` on any part, the guardrail evaluates every message
|
|
295
|
+
* and not the system prompt. Set `trace` to `"enabled"` to learn from the
|
|
296
|
+
* finish part whether the guardrail blocked or masked. The trace holds the
|
|
297
|
+
* matched text unmasked.
|
|
298
|
+
*
|
|
299
|
+
* @stability unstable
|
|
300
|
+
* @category models
|
|
301
|
+
* @since 0.4.0
|
|
302
|
+
*/
|
|
303
|
+
export type GuardrailConfig = typeof GuardrailStreamConfiguration.Encoded;
|
|
304
|
+
/**
|
|
305
|
+
* The role a guarded text part plays in a contextual grounding check.
|
|
306
|
+
*
|
|
307
|
+
* @stability unstable
|
|
308
|
+
* @category models
|
|
309
|
+
* @since 0.4.0
|
|
310
|
+
*/
|
|
311
|
+
export type GuardContentQualifier = typeof GuardrailConverseContentQualifier.Type;
|
|
312
|
+
/**
|
|
313
|
+
* Marks a text part or a system message for the guardrail to evaluate.
|
|
314
|
+
*
|
|
315
|
+
* **Details**
|
|
316
|
+
*
|
|
317
|
+
* `true` guards the text. `qualifiers` names its role in a contextual
|
|
318
|
+
* grounding check: the source documents are `grounding_source`, and the
|
|
319
|
+
* question is `query`. Once any part of a request is guarded, the guardrail
|
|
320
|
+
* evaluates only the guarded parts. The model still reads every part.
|
|
321
|
+
*
|
|
322
|
+
* The option stays on the part, so in a chat a guarded turn is evaluated
|
|
323
|
+
* again on every later turn.
|
|
324
|
+
*
|
|
325
|
+
* @stability unstable
|
|
326
|
+
* @category models
|
|
327
|
+
* @since 0.4.0
|
|
328
|
+
*/
|
|
329
|
+
export type GuardContent = true | {
|
|
330
|
+
readonly qualifiers: ReadonlyArray<GuardContentQualifier>;
|
|
331
|
+
};
|
|
332
|
+
interface GuardableOptions {
|
|
333
|
+
readonly amazonBedrock?: {
|
|
334
|
+
/**
|
|
335
|
+
* Marks the end of the reusable prefix of the request. The cache point is
|
|
336
|
+
* emitted after the content this is attached to.
|
|
337
|
+
*/
|
|
338
|
+
readonly cachePoint?: CachePoint | null;
|
|
339
|
+
/**
|
|
340
|
+
* Sends the text as a `guardContent` block, for the guardrail to evaluate.
|
|
341
|
+
* Honoured on user text parts and system messages. On an assistant text
|
|
342
|
+
* part it fails the request with `InvalidUserInputError`.
|
|
343
|
+
*/
|
|
344
|
+
readonly guardContent?: GuardContent | null;
|
|
345
|
+
} | null;
|
|
346
|
+
}
|
|
347
|
+
declare module "effect/ai/Prompt" {
|
|
348
|
+
/**
|
|
349
|
+
* Amazon Bedrock options for system messages.
|
|
350
|
+
*
|
|
351
|
+
* @stability unstable
|
|
352
|
+
* @category models
|
|
353
|
+
* @since 0.1.0
|
|
354
|
+
*/
|
|
355
|
+
interface SystemMessageOptions extends GuardableOptions {
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Amazon Bedrock options for text prompt parts.
|
|
359
|
+
*
|
|
360
|
+
* @stability unstable
|
|
361
|
+
* @category models
|
|
362
|
+
* @since 0.1.0
|
|
363
|
+
*/
|
|
364
|
+
interface TextPartOptions extends GuardableOptions {
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* What a guardrail did to one side of the exchange.
|
|
369
|
+
*
|
|
370
|
+
* @stability unstable
|
|
371
|
+
* @category models
|
|
372
|
+
* @since 0.4.0
|
|
373
|
+
*/
|
|
374
|
+
export type GuardrailAction = "blocked" | "masked" | "none";
|
|
375
|
+
/**
|
|
376
|
+
* What the guardrails did, read from the trace.
|
|
377
|
+
*
|
|
378
|
+
* **Details**
|
|
379
|
+
*
|
|
380
|
+
* `input` and `output` are the strongest action that any guardrail took on
|
|
381
|
+
* that side, `blocked` over `masked` over `none`, across every guardrail in
|
|
382
|
+
* the trace, enforced guardrails included. `policies` lists the trace keys of
|
|
383
|
+
* the policies that blocked or masked, such as `wordPolicy` or
|
|
384
|
+
* `sensitiveInformationPolicy`, each once, in the order the trace names them.
|
|
385
|
+
*
|
|
386
|
+
* @stability unstable
|
|
387
|
+
* @category models
|
|
388
|
+
* @since 0.4.0
|
|
389
|
+
*/
|
|
390
|
+
export type GuardrailOutcome = {
|
|
391
|
+
readonly input: GuardrailAction;
|
|
392
|
+
readonly output: GuardrailAction;
|
|
393
|
+
readonly policies: Array<string>;
|
|
394
|
+
};
|
|
395
|
+
/**
|
|
396
|
+
* The Amazon Bedrock metadata on every finish part.
|
|
397
|
+
*
|
|
398
|
+
* **Details**
|
|
399
|
+
*
|
|
400
|
+
* `stopReason` is the raw Converse stop reason. It tells
|
|
401
|
+
* `guardrail_intervened` from `content_filtered`, which both finish with
|
|
402
|
+
* `"content-filter"`, and `max_tokens` from `model_context_window_exceeded`,
|
|
403
|
+
* which both finish with `"length"`. It is `null` only when a stream ended
|
|
404
|
+
* without a `messageStop` event.
|
|
405
|
+
*
|
|
406
|
+
* `guardrail` is `null` when the response carried no guardrail trace, which
|
|
407
|
+
* is the case unless `trace` is enabled in the guardrail config. A trace in
|
|
408
|
+
* which nothing acted gives `{ input: "none", output: "none", policies: [] }`.
|
|
409
|
+
* `trace` is the Converse trace as Bedrock sent it, or `null`. It holds the
|
|
410
|
+
* text that a policy matched, unmasked.
|
|
411
|
+
*
|
|
412
|
+
* @stability unstable
|
|
413
|
+
* @category models
|
|
414
|
+
* @since 0.4.0
|
|
415
|
+
*/
|
|
416
|
+
export type FinishMetadata = {
|
|
417
|
+
readonly stopReason: string | null;
|
|
418
|
+
readonly guardrail: GuardrailOutcome | null;
|
|
419
|
+
readonly trace: Schema.MutableJson | null;
|
|
420
|
+
};
|
|
421
|
+
declare module "effect/ai/AiError" {
|
|
422
|
+
/**
|
|
423
|
+
* Amazon Bedrock metadata on the `ContentPolicyError` that `generateObject`
|
|
424
|
+
* fails with when a guardrail blocked the exchange. It is the metadata of
|
|
425
|
+
* the response's finish part.
|
|
426
|
+
*
|
|
427
|
+
* @stability unstable
|
|
428
|
+
* @category models
|
|
429
|
+
* @since 0.4.0
|
|
430
|
+
*/
|
|
431
|
+
interface ContentPolicyErrorMetadata extends ProviderMetadata {
|
|
432
|
+
readonly amazonBedrock?: FinishMetadata | null;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
declare module "effect/ai/Response" {
|
|
436
|
+
/**
|
|
437
|
+
* Amazon Bedrock metadata on the finish part.
|
|
438
|
+
*
|
|
439
|
+
* @stability unstable
|
|
440
|
+
* @category models
|
|
441
|
+
* @since 0.4.0
|
|
442
|
+
*/
|
|
443
|
+
interface FinishPartMetadata extends ProviderMetadata {
|
|
444
|
+
readonly amazonBedrock?: FinishMetadata | null;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
295
447
|
declare const Config_base: Context.ServiceClass<Config, "@wmaurer/effect-ai-amazon-bedrock/AmazonBedrockLanguageModel/Config", {
|
|
296
448
|
readonly modelId?: string;
|
|
297
449
|
readonly toolConfig?: {
|
|
@@ -329,6 +481,12 @@ declare const Config_base: Context.ServiceClass<Config, "@wmaurer/effect-ai-amaz
|
|
|
329
481
|
readonly additionalModelRequestFields?: {
|
|
330
482
|
readonly [x: string]: unknown;
|
|
331
483
|
} | undefined;
|
|
484
|
+
readonly guardrailConfig?: {
|
|
485
|
+
readonly guardrailIdentifier: string;
|
|
486
|
+
readonly guardrailVersion: string;
|
|
487
|
+
readonly trace?: "disabled" | "enabled" | "enabled_full";
|
|
488
|
+
readonly streamProcessingMode?: "async" | "sync";
|
|
489
|
+
} | undefined;
|
|
332
490
|
readonly outputConfig?: {
|
|
333
491
|
readonly effort?: string | undefined;
|
|
334
492
|
} | undefined;
|
|
@@ -340,12 +498,17 @@ declare const Config_base: Context.ServiceClass<Config, "@wmaurer/effect-ai-amaz
|
|
|
340
498
|
*
|
|
341
499
|
* **Details**
|
|
342
500
|
*
|
|
343
|
-
* Derived from `
|
|
344
|
-
* every Converse request parameter is settable per request. That
|
|
345
|
-
* `additionalModelRequestFields`, which carries inference parameters
|
|
346
|
-
* to the target model — among them extended thinking on Anthropic
|
|
347
|
-
* thinking budget is drawn from the same ceiling as the visible
|
|
348
|
-
* `inferenceConfig.maxTokens` must exceed `budget_tokens`.
|
|
501
|
+
* Derived from `ConverseStreamRequest`, minus the fields built from the
|
|
502
|
+
* prompt, so every Converse request parameter is settable per request. That
|
|
503
|
+
* includes `additionalModelRequestFields`, which carries inference parameters
|
|
504
|
+
* specific to the target model — among them extended thinking on Anthropic
|
|
505
|
+
* models. The thinking budget is drawn from the same ceiling as the visible
|
|
506
|
+
* answer, so `inferenceConfig.maxTokens` must exceed `budget_tokens`.
|
|
507
|
+
*
|
|
508
|
+
* It also includes `guardrailConfig` (see {@link GuardrailConfig}). An
|
|
509
|
+
* override replaces the whole object, and `guardrailConfig: undefined` turns
|
|
510
|
+
* off a layer's guardrail for one request. `generateText` does not send
|
|
511
|
+
* `streamProcessingMode`.
|
|
349
512
|
*
|
|
350
513
|
* **Example** (Enabling extended thinking for one request)
|
|
351
514
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AmazonBedrockLanguageModel.d.ts","sourceRoot":"","sources":["../src/AmazonBedrockLanguageModel.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AmazonBedrockLanguageModel.d.ts","sourceRoot":"","sources":["../src/AmazonBedrockLanguageModel.ts"],"names":[],"mappings":"AAkCA,OAAO,KAAK,aAAa,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAA;AAI1C,OAAO,KAAK,OAA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