Aan de slagGa gratis aan de slag

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.

Deze oefening maakt deel uit van de cursus

Introduction to Amazon Bedrock

Cursus bekijken

Oefeninstructies

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

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

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, '____')}")
Code bewerken en uitvoeren