davsclaus opened a new pull request, #31034:
URL: https://github.com/apache/camel/pull/31034

   JIRA: https://issues.apache.org/jira/browse/CAMEL-27694
   
   ## What was wrong
   
   For the `converseStream` operation, when the guardrail comes from the 
endpoint options (`guardrailIdentifier`),
   `BedrockProducer.converseStream()` built the `GuardrailStreamConfiguration` 
with
   `streamProcessingMode = guardrailTrace ? ASYNC : SYNC`. So 
`guardrailTrace=true`, which should only ask for the trace,
   also switched the guardrail on the stream to asynchronous processing.
   
   The [AWS 
docs](https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-streaming.html)
 describe the two modes.
   In the default sync mode, Bedrock buffers the chunks and checks them with 
the guardrail before sending them. In async
   mode, Bedrock sends the chunks at once and checks them in the background, so 
chunks the guardrail would block can be
   sent before it blocks the rest of the stream, and masking of sensitive 
information is not supported.
   
   ## What changed
   
   - New endpoint (and component) option `guardrailStreamProcessingMode` 
(`sync` / `async`, the values of the SDK
     `GuardrailStreamProcessingMode`), default `sync`. `converseStream` uses it 
for the guardrail of the
     `guardrailIdentifier` option.
   - `guardrailTrace` now only sets the trace.
   - If the value is unknown, the producer fails at startup with `Unknown 
guardrailStreamProcessingMode: <value>. Use sync or async.`
   - The `CamelAwsBedrockGuardrailConfig` header path does not change. A 
`GuardrailStreamConfiguration` header is used as
     given. A `GuardrailConfiguration` header is converted without a processing 
mode, so Bedrock uses sync.
   
   ## Tests
   
   `BedrockProducerRequestTest` (mocked async client, captures the 
`ConverseStreamRequest`). Five new tests:
   - `guardrailTrace=true` gives `SYNC` (with trace enabled)
   - no options give `SYNC`
   - `guardrailStreamProcessingMode=async` gives `ASYNC`, with and without the 
trace
   - an unknown value fails at producer start
   
   The existing header test now also asserts that no processing mode is set. 
Without the fix, 4 of the 5 new tests fail:
   with the trace on, the mode is `async` instead of `sync`, and the new option 
is unknown. The default test passes with
   and without the fix. The module has 201 tests and all of them pass.
   
   ## Docs
   
   - Component doc: the new option, plus a "Guardrails with converseStream" 
section that explains the two modes.
   - Upgrade guide 4.24: routes with `guardrailTrace=true` now get `sync`. To 
keep the old behavior, they set
     `guardrailStreamProcessingMode=async`.
   - Regenerated: the component JSON and its catalog copy, the catalog doc 
copy, the endpoint DSL and the component DSL.
   
   _Claude Code on behalf of Claus Ibsen_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to