boto / botocore

The low-level, core functionality of boto3 and the AWS CLI.
Apache License 2.0
1.45k stars 1.06k forks source link

Arguments of Bedrock's client.create_guardrail not working as expected #3212

Closed pd2871 closed 3 days ago

pd2871 commented 4 days ago

Describe the bug

According to AWS documentation, some of the fields are not required compulsorily in client.create_guardrail wordPolicyConfig topicPolicyConfig ... ...

So, the main problem I am facing is when creating a guardrail using boto3, these fields are needed compulsorily.

ParamValidationError: Parameter validation failed:
Invalid length for parameter wordPolicyConfig.wordsConfig[0].text, value: 0, valid min length: 1

I do not want LLM to restrict on any specific word after creating guardrails using boto3 but boto3 keeps on throwing error to add atleast 1 word?

So, I hope boto3 team makes these fields Optional instead of COMPULSORY.

Expected Behavior

I expected that if I pass wordPolicyConfig=None while using client.create_guardrail, it should work fine.

client.create_guardrail(wordPolicyConfig=None)

It is expected to not throw any error

Current Behavior

If wordPolicyConfig=None is passed with client.create_guardrail, it throws error.

ParamValidationError: Parameter validation failed:
Invalid length for parameter wordPolicyConfig.wordsConfig[0].text, value: 0, valid min length: 1

Reproduction Steps

Some of those fields should be made Optional instead of Compulsory based on AWS Guardrails API documentation.

Possible Solution

Some of those fields should be made Optional instead of Compulsory based on AWS Guardrails API documentation.

Additional Information/Context

No response

SDK version used

1.34.105

Environment details (OS name and version, etc.)

Windows 10

tim-finnigan commented 3 days ago

Thanks for reaching out. If a parameter is optional and you do not want to use it, then you should just not include it in your command. Otherwise it is expected that the command would fail with a ParamValidationError here, because you are passing a None type. When I try that I get the error:

botocore.exceptions.ParamValidationError: Parameter validation failed:
Invalid type for parameter wordPolicyConfig, value: None, type: <class 'NoneType'>, valid types: <class 'dict'>

What you're actually doing is probably:

 'wordPolicyConfig':{
        'wordsConfig': [
            {
                'text': ''
            },
        ],
    },

I get the error you referenced when attempting to use that configuration. The API is expecting a value for text here.

Also the Boto3 create_guardail command involves a call to the underlying Amazon Bedrock CreateGuardrail API. Therefore the Boto3 team here cannot modify the underlying behavior here. If you'd like someone to reach out to the Bedrock team on your behalf, please create an issue in our cross-SDK repository (https://github.com/aws/aws-sdk/issues) outlining your request.

github-actions[bot] commented 3 days ago

This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.