1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to Amazon Bedrock

Connected

Exercise

Product review moderation

You're consulting for a healthcare platform that allows users to share wellness experiences and reviews. The Head of User Safety explains:

"Safety is our top priority, but we also want to preserve authentic voices. We need a content moderation system that can adapt its strictness based on different community sections - some need higher protection than others."

Help them build a flexible and safe moderation system. The boto3 and json libraries, bedrock client and model_id have been preloaded.

Instructions

100 XP
  • Define a moderate_content() function that accepts a text and a strictness level with "medium" as the default.

  • Use a dictionary to set the instruction based on strictness: "high", "medium", and "low".

  • Add a temperature of 0.2 to keep the response consistent.