-
Notifications
You must be signed in to change notification settings - Fork 599
Description
I'm not sure how to fix the call to create the KB so the name isn't too long. The name passed is <32 chars but somehow on Step 3 it doubles the name.
print(KB_NAME_1)
print(KB_DESC_1)
aws-overview-kb
Use this KB to retrieve information about AWS services that the user is asking about.
%%time
try:
generic_aws_kb_id, generic_aws_ds_id = kb.create_or_retrieve_knowledge_base(
KB_NAME_1,
KB_DESC_1,
FOUNDATIONAL_S3_INPUT_BUCKET,
)
logger.info(f"Knowledge Base ID: {generic_aws_kb_id}")
logger.info(f"Data Source ID: {generic_aws_ds_id}")
except Exception as e:
logger.error(f"An error occurred while creating the KB: {e}")
Creating KB aws-overview-kb
Step 1 - Creating or retrieving 'my-bucket' S3 bucket for Knowledge Base documents
Bucket 'my-bucket' already exists - retrieving it!
Step 2 - Creating Knowledge Base Execution Role (AmazonBedrockExecutionRoleForKnowledgeBase_aws-overview-kb) and Policies
AmazonBedrockFoundationModelPolicyForKnowledgeBase_aws-overview-kb already exists, retrieving it!
AmazonBedrockS3PolicyForKnowledgeBase_aws-overview-kb already exists, retrieving it!
AmazonBedrockExecutionRoleForKnowledgeBase_aws-overview-kb already exists, retrieving it!
Step 3 - Creating OSS encryption, network and data access policies
[2025-05-14 19:19:21,807] p2079 {:10} ERROR - An error occurred while creating the KB: An error occurred (ValidationException) when calling the CreateSecurityPolicy operation: 1 validation error detected: Value 'aws-overview-kb-sp-aws-overview-kb' at 'name' failed to satisfy constraint: Member must have length less than or equal to 32
CPU times: user 66.7 ms, sys: 1.29 ms, total: 67.9 ms
Wall time: 1.67 s