Aan de slagGa gratis aan de slag

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.

Deze oefening maakt deel uit van de cursus

Introduction to Amazon Bedrock

Cursus bekijken

Oefeninstructies

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

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# 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)
Code bewerken en uitvoeren