Creating age-appropriate content filters
Expanding your work with the healthcare platform, they're developing content for different age groups in their family wellness program. When creating content for the different age groups, they need to ensure their AI responses are appropriate. You'll create a 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
Exercise instructions
- Insert the
"high"
level of moderation to get the appropriate content check for the children'sprompt
. - Repeat for adults and teens, with gradually lower levels of moderations, 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 = "I have a bad headache: how much ibuprofen can I take, and how often?"
# 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, '____')}")