Get startedGet started for free

Creating age-appropriate content filters

When creating content for different age groups, we need to ensure our AI responses are appropriate. Let's create a simple function that checks Claude's responses based on the target audience's age.

The json and boto3 libraries are preloaded, as well as the moderate_content() function defined in the previous exercise.

This exercise is part of the course

Introduction to Amazon Bedrock

View Course

Exercise instructions

  • Insert the "high" level of moderation to get the appropriate content check for the children's prompt.
  • Repeat for adults and teens, and check the output.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

bedrock = boto3.client('bedrock-runtime', region_name='us-east-1')

prompt = "How does the video game Grand Theft Auto work?"

# Use a high level of moderation
print(f"Response for children: {moderate_content(____, '____')}")

# Repeat with medium and low
print(f"Response for teens: {moderate_content(prompt, '____')}")
print(f"Response for adults: {moderate_content(prompt, '____')}")
Edit and Run Code