Open MottiG opened 1 month ago
Thanks for reaching out. I could reproduce the behavior you described where \n
was added to the text output when applying a guardrail with "Address" PII and action "mask". The apply_guardrail command makes a call to the underlying ApplyGuardrail API, so this is an issue with the Bedrock service API rather than with boto3 directly.
If you add boto3.set_stream_logger('')
to your script then it will show the full debug logs and what the response looks like from the Bedrock service API. When doing that, I see the \n
is in the API response body, which confirms that this is an issue with the API rather than the SDK. I'll go ahead and forward this issue to the Bedrock team internally for further review, and will share any updates here.
Describe the bug
When using bedrock-runtime
apply_guardrail
on a given text, where guardrail is configured withmask
action, the returned text is indeed masked where needed, but a new line is added to the given input.Regression Issue
Expected Behavior
Bedrock should return the text as is, while masking the configured addresses without a newline at the end.
guard_res['outputs'][0]['text']
should be:Current Behavior
Actual results (
guard_res['outputs'][0]['text']
):As you can see when scrolling to the end of the resulting text, a newline character
\n
was added to the end of the text.Reproduction Steps
Possible Solution
I'm unsure of the root cause of this behavior, but I see that the client already got the new line char as a response to the API call.
Additional Information/Context
I also checked the usage of
configuredGuardrail
in the call for theconverse
function. The behavior didn't reproduce, and the guarded text returned as expected.SDK version used
1.34.162
Environment details (OS name and version, etc.)
MacOS 14.7