Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Amazon Bedrock (Claude Sonnet 3.5) #153

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ANTHROPIC_API_KEY="YOUR API KEY"
ANTHROPIC_API_KEY="YOUR API KEY" # Remove this line to use with Amazon Bedrock (AWS)
TAVILY_API_KEY="YOUR API KEY"
16 changes: 9 additions & 7 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from PIL import Image
import io
import re
from anthropic import Anthropic, APIStatusError, APIError
from anthropic import Anthropic, AnthropicBedrock, APIStatusError, APIError
import difflib
import time
from rich.console import Console
Expand Down Expand Up @@ -57,10 +57,12 @@ def setup_virtual_environment() -> Tuple[str, str]:
load_dotenv()

# Initialize the Anthropic client
client = None
anthropic_api_key = os.getenv("ANTHROPIC_API_KEY")
if not anthropic_api_key:
raise ValueError("ANTHROPIC_API_KEY not found in environment variables")
client = Anthropic(api_key=anthropic_api_key)
client = AnthropicBedrock()
else:
client = Anthropic(api_key=anthropic_api_key)

# Initialize the Tavily client
tavily_api_key = os.getenv("TAVILY_API_KEY")
Expand Down Expand Up @@ -105,12 +107,12 @@ def setup_virtual_environment() -> Tuple[str, str]:

# Models
# Models that maintain context memory across interactions
MAINMODEL = "claude-3-5-sonnet-20240620" # Maintains conversation history and file contents
MAINMODEL = "claude-3-5-sonnet-20240620" if anthropic_api_key else "anthropic.claude-3-5-sonnet-20240620-v1:0" # Maintains conversation history and file contents

# Models that don't maintain context (memory is reset after each call)
TOOLCHECKERMODEL = "claude-3-5-sonnet-20240620"
CODEEDITORMODEL = "claude-3-5-sonnet-20240620"
CODEEXECUTIONMODEL = "claude-3-5-sonnet-20240620"
TOOLCHECKERMODEL = "claude-3-5-sonnet-20240620" if anthropic_api_key else "anthropic.claude-3-5-sonnet-20240620-v1:0"
CODEEDITORMODEL = "claude-3-5-sonnet-20240620" if anthropic_api_key else "anthropic.claude-3-5-sonnet-20240620-v1:0"
CODEEXECUTIONMODEL = "claude-3-5-sonnet-20240620" if anthropic_api_key else "anthropic.claude-3-5-sonnet-20240620-v1:0"

# System prompts
BASE_SYSTEM_PROMPT = """
Expand Down
22 changes: 22 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Claude Engineer is an advanced interactive command-line interface (CLI) that har
- 🔒 Enhanced code execution capabilities with isolated virtual environment
- 🔄 Process management for long-running code executions
- 📚 Multi-file reading capability for efficient handling of multiple files simultaneously
- 🪨 Use your company's AWS account and leverage Claude Sonnet 3.5 via Amazon Bedrock

## 🛠️ Installation

Expand Down Expand Up @@ -340,6 +341,27 @@ graph TD

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

## 🪨 Amazon Bedrock support with Claude Sonnet 3.5 is here

You can now use Claude Engineer with Amazon Bedrock. To use with Amazon Bedrock, make sure your local machine is [authenticated with AWS via the AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-quickstart.html). This allows you to use Claude

If your AWS account is configured with IAM Identity Center (AWS SSO), then run the following command to authenticate the AWS CLI:
```bash
aws sso login
```

Make sure to **remove** the `ANTHROPIC_API_KEY` from your `.env` file. If an `ANTHROPIC_API_KEY`, it'll always default to using the API Key first.

You can customize the model that Amazon Bedrock uses by editing the following lines in the `main.py` file. Claude models used by Amazon Bedrock will start with `anthropic.`:
```
MAINMODEL = "claude-3-5-sonnet-20240620" if anthropic_api_key else "anthropic.claude-3-5-sonnet-20240620-v1:0" # Maintains conversation history and file contents

# Models that don't maintain context (memory is reset after each call)
TOOLCHECKERMODEL = "claude-3-5-sonnet-20240620" if anthropic_api_key else "anthropic.claude-3-5-sonnet-20240620-v1:0"
CODEEDITORMODEL = "claude-3-5-sonnet-20240620" if anthropic_api_key else "anthropic.claude-3-5-sonnet-20240620-v1:0"
CODEEXECUTIONMODEL = "claude-3-5-sonnet-20240620" if anthropic_api_key else "anthropic.claude-3-5-sonnet-20240620-v1:0"
```

## 🦙 Ollama eng is here

You can now have the power of this script, completely locally using Ollama and any of the supported function calling models:
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ Pillow
rich
aiohttp
prompt_toolkit
boto3