A minimal Python-based chatbot implementation that supports both Amazon Nova and Anthropic Claude models through Amazon Bedrock.
- Supports multiple foundation models:
- Amazon Nova models (Micro, Lite, Pro)
- Anthropic Claude models (3.7 Sonnet, 3.5 Haiku)
- Simple command-line interface
- Maintains conversation history
- Automatic AWS credential detection
- An AWS account with access to Amazon Bedrock
- Model access enabled for Nova and Claude models
- Python 3.9+
- Boto3 library
-
Clone the repository
git clone https://github.com/yourusername/bedrock-chatbot.git cd bedrock-chatbot -
Create and activate a virtual environment
# Create virtual environment python -m venv venv # Activate on macOS/Linux source venv/bin/activate # Activate on Windows venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
Before using the chatbot, request access to the models:
- Sign in to the AWS Management Console
- Navigate to Amazon Bedrock
- Select "Model access" in the left navigation
- Request access to:
- Amazon Nova models (Micro, Lite, Pro)
- Anthropic Claude models (3.7 Sonnet, 3.5 Haiku)
The chatbot uses the AWS SDK's default credential provider chain:
- Environment variables
- Shared credential file (~/.aws/credentials)
- AWS config file (~/.aws/config)
- IAM role for EC2/ECS
Make the script executable and run it:
chmod +x bedrock-chatbot.py
./bedrock-chatbot.pyFollow the prompts to:
- Select a model
- Type your messages
- Type 'quit' to exit or 'clear' to start a new conversation
- Nova Micro: Text-only model with lowest latency
- Nova Lite: Balanced multimodal model (images, text)
- Nova Pro: Most capable multimodal model
- Claude 3.7 Sonnet: Advanced reasoning with standard and extended thinking modes
- Claude 3.5 Haiku: Fast, efficient model for everyday tasks
If you encounter errors:
- Authentication errors: Verify AWS credentials are correctly configured
- Access errors: Confirm model access has been granted in the Bedrock console
- Region issues: The chatbot defaults to us-east-1; ensure your chosen models are available in this region
This project is licensed under the MIT License - see the LICENSE file for details.