開始使用免費開始

實作 chain-of-thought 提示

StellarStack 即將發佈其旗艦雲端平台。行銷團隊想要一封電子郵件,說明為什麼開發者應該遷移。為了引導 Claude 的推理,你要在提示中加入「思考步驟」核對清單。

已經匯入 json 函式庫。

本練習屬於課程

Amazon Bedrock 入門

檢視課程

練習說明

  • 以編號清單(1., 2., 3.)列出模型在準備回應時應採取的三個步驟。
  • 使用作為 chain of thought 的 steps 清單,將它們接在 "\nSteps: " 之後,填入 text_data"text" 欄位。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

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))
編輯並執行程式碼