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

Using the correct model in Bedrock

You work for BeanBliss, a specialty-coffee company that helps independent cafés keep their menus fresh with locally roasted beans. As the team gears up to introduce AI-driven demand-planning tools, they’ve asked you to demonstrate how the Claude model in Amazon Bedrock could help forecasting customer demand more effectively.

The boto3 and json libraries have been pre-imported.

Bu egzersiz

Introduction to Amazon Bedrock

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Initialize the Bedrock client for inference.
  • Invoke the model using the bedrock client.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Initialize the client for inference
bedrock = boto3.client('____', region_name='us-east-1')

messages = [{"role": "user", "content": "What are some ways to forecast customer demand?"}]

request_body=json.dumps({"anthropic_version": "bedrock-2023-05-31", "max_tokens": 20,
                 "messages": messages})  

# Invoke the model
response = bedrock.____(body=request_body, modelId='anthropic.claude-3-5-sonnet-20240620-v1:0')
response_body = json.loads(response.get('body').read())

print(response_body)
Kodu Düzenle ve Çalıştır