Closed brnaba-aws closed 2 months ago
@3coins This is the PR for guardrails with the new structure. Can you please have a look? Thanks.
@brnaba-aws Thanks for making this update. This looks like a breaking change, does Bedrock have a version that works with the previous format or all clients need to move to this new API? Also, can you add some unit tests for this, or paste your test results here.
Looking forward to get this fix merged for the GA version of Guardrails for Amazon Bedrock.
This looks like a breaking change, does Bedrock have a version that works with the previous format or all clients need to move to this new API?
Is backward compatibility needed for the "Preview" version of Guardrails?
langchain-aws version used: 0.1.4
Have tried all the below scenarios:
guardrails={ "trace": False, "accept": "application/json", "contentType": "application/json", "modelId": model_id, "guardrailIdentifier": "identifier", --> "id" of the Guardrail I created using Bedrock Console. "guardrailVersion": "5"}
guardrail_kwargs={"guardrailIdentifier": "identifier", "guardrailVersion": "5"}
guardrails={ "trace": False, "guardrailIdentifier": "xxxx" --> the ARN of the guardrail I created using Bedrock Console. "guardrailVersion": "5"}
guardrails={ "trace": False, "guardrailIdentifier": "identifier", --> "id" of the Guardrail I created using Bedrock Console. "guardrailVersion": "5"}
Adding the exception below:
Tried the alternative as below: guardrails={ "trace": False, "id": "identifier", --> "id" of the Guardrail I created using Bedrock Console. "version": "5"}
Got the exception as below:
Error Occured: Guardrails must be a dictionary with 'guardrailIdentifier' and 'guardrailVersion' keys.
The below option doesn't give any error but eventually has no relevance as the identifier value is None:
guardrails={ "trace": False, "guardrailIdentifier": None "guardrailVersion": "5"}
Please suggest the correct way of passing the guardrail parameter for it to work.
PS: I have tested the Guardrail from Bedrock Console and it works like a charm.
Followed your example, getting the same error
@MaverickScientist Which version of boto3 do you use? It seems like the version you have is not the latest. If you use a lambda, verify the boto3 version and if it is not a version that supports guardrails attributes, package your lambda with the latest version of boto3.
Moving to boto 1.34.108 fixed it.
Fixed bedrock attributes when using guardrails. See example of usage: