1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to Amazon Bedrock

Connected

Exercise

Making a conversation memory-aware

Continuing work on ChargeBot at ChargeNet, you’ll store each turn of the dialogue and send only the most recent messages to Claude, to maintain conversation context with Amazon Bedrock's Claude model. The bot will manage message history and format the conversation in a way Claude can understand, using only the most recent context.

The boto3 and json libraries, and the ConversationManager class you defined in the previous exercise, have been preloaded.

Instructions

100 XP
  • Use the add_message() method to store the user's input.
  • Send only the last two messages from the history to Claude using the correct message format.