เริ่มต้นใช้งานเริ่มต้นใช้งานได้ฟรี

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.

แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร

Introduction to Amazon Bedrock

ดูคอร์ส

คำแนะนำการฝึกหัด

  • 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.

แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ

ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์

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, '____')}")
แก้ไขและรันโค้ด