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

Implementing chain of thought prompting

StellarStack is about to launch its flagship cloud platform. Marketing wants an email that explains why developers should migrate. To guide Claude’s reasoning, you’ll add a “think-step” checklist to the prompt.

The json library has been imported.

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

Introduction to Amazon Bedrock

ดูคอร์ส

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

  • Outline three steps the model should take in preparing the response, using a numbered list (1., 2., 3.).
  • Using the steps list for the chain of thought, populate the "text" field of text_data by appending them after "\nSteps: ".

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

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

def generate_message_content(text_data):
    steps = [
        # Outline the steps
        "____",
        "____",
        "____"
    ]
    # Append the steps to the prompt text
    text_data["text"] += "\nSteps: " + ____
    return text_data

text_data = {"text": "Create a promotional email for the StellarStack cloud platform."}
  
print(generate_message_content(text_data))
แก้ไขและรันโค้ด