logo
Menu
Keeping Your Chatbot Knowledge Base Aligned with New Content.

Keeping Your Chatbot Knowledge Base Aligned with New Content.

Keeping a knowledge base (KB) in sync with new content is crucial for maintaining the accuracy and relevance of your chatbot's responses. Here’s a comprehensive approach to managing and synchronizing your knowledge base effectively

Published Aug 5, 2024
Each time you add, modify or remove files from the S3 bucket for a data source, you must sync the data source so that it is re-indexed to the knowledge base. Syncing is incremental, so Amazon Bedrock only processes the objects in your S3 bucket that have been added, modified, or deleted since the last sync.
Some limits to keep in mind:
  • Only 5 Knowledge bases per account
  • Only 5 concurrent data syncs per account
  • Only 1 concurrent data sync per knowledge base
Create a permissions policy that allows Lambda to get objects from an Amazon S3 bucket and to write to Amazon CloudWatch Logs.
To create the policy
  1. Open the Policies of the IAM console.
  2. Choose Create Policy.
  3. Choose the JSON tab, and then paste the following custom policy into the JSON editor.
  1. {
  2. "Version": "2012-10-17",
  3. "Statement": [
  4. {
  5. "Effect": "Allow",
  6. "Action": [
  7. "logs:PutLogEvents",
  8. "logs:CreateLogGroup",
  9. "logs:CreateLogStream"
  10. ],
  11. "Resource": "arn:aws:logs:*:*:*"
  12. },
  13. {
  14. "Effect": "Allow",
  15. "Action": [
  16. "s3:GetObject"
  17. ],
  18. "Resource": "arn:aws:s3:::*/*"
  19. }
  20. ]
  21. }
  22. Choose Next: Tags.
  23. Choose Next: Review.
  24. Under Review policy, for the policy Name, enter s3-trigger-demo.
  25. Choose Create policy.
To create the Amazon S3 trigger
  1. In the Function overview pane, choose Add trigger.
  2. Select S3.
  3. Under Bucket, select the bucket you created earlier in the tutorial.
  4. Under Event types, be sure that all object-created events are selected.
  5. Under Recursive invocation, select the check box to acknowledge that using the same Amazon S3 bucket for input and output is not recommended.
  6. Choose Add.
An execution role is an AWS Identity and Access Management (IAM) role that grants a Lambda function permission to access AWS services and resources. In this step, create an execution role using the permissions policy that you created in the previous step.
To create an execution role and attach your custom permissions policy
  1. Open the Roles page of the IAM console.
  2. Choose Create role.
  3. For the type of trusted entity, choose AWS service, then for the use case, choose Lambda.
  4. Choose Next.
  5. In the policy search box, enter s3-trigger-demo.
  6. In the search results, select the policy that you created (s3-trigger-demo), and then choose Next.
  7. Under Role details, for the Role name, enter lambda-s3-trigger-role, then choose Create role.
Create a Lambda function in the console using the Python 3.12 runtime.
To create the Lambda function
  1. Open the Functions of the Lambda console.
  2. Choose the Create function.
  3. Choose Author from scratch
  4. Under Basic information, do the following:
    1. For Function name, enter s3-trigger-demo
    2. For Runtime, choose Python 3.12.
    3. For Architecture, choose x86_64.
  5. In the Change default execution role tab:
    1. Expand the tab, then choose Use an existing role.
    2. Select the lambda-s3-trigger-role one the you created earlier.
  6. Choose the Create function.
     

Comments