BaşlayınÜcretsiz başlayın

Generating text in Bedrock

Building on your success with Claude, the specialty-coffee company now wants to roll out AI-assisted writing to their marketing department. They're launching a New Year campaign and need compelling subject lines: it's time to generate some catchy options with Bedrock!

The boto3 and json libraries have been pre-imported. The prompt is already provided as: "Write an engaging email subject line for a coffee company's New Year marketing campaign".

Bu egzersiz, kursun bir parçasıdır

Introduction to Amazon Bedrock

Kursa Göz Atın

Egzersiz talimatları

  • Set the keys in the dictionary to complete the "messages" list for the Nova model.

Uygulamalı etkileşimli egzersiz

Bu egzersizi bu örnek kodu tamamlayarak deneyin.

bedrock = boto3.client('bedrock-runtime', region_name='us-east-1')

# Set the dictionary keys
message = {"____": "user",
           "____": [{"text": prompt}]}

nova_response = bedrock.invoke_model(modelId='us.amazon.nova-2-lite-v1:0', body=json.dumps({"messages": [message]}))

print(json.loads(nova_response.get("body").read().decode())["output"]["message"]["content"][0]["text"])
Kodu Düzenle ve Çalıştır