diff --git a/.env.example b/.env.example index 83052419..f27ef63a 100644 --- a/.env.example +++ b/.env.example @@ -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" diff --git a/main.py b/main.py index 1a2f460f..13a351e5 100644 --- a/main.py +++ b/main.py @@ -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 @@ -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") @@ -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 = """ diff --git a/readme.md b/readme.md index 40eebdbd..60953a30 100644 --- a/readme.md +++ b/readme.md @@ -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 @@ -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: diff --git a/requirements.txt b/requirements.txt index 45e7f3fb..3efc6f26 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,3 +5,4 @@ Pillow rich aiohttp prompt_toolkit +boto3 \ No newline at end of file