continuedev / continue

⏩ Continue is the leading open-source AI code assistant. You can connect any models and any context to build custom autocomplete and chat experiences inside VS Code and JetBrains
https://docs.continue.dev/
Apache License 2.0
19.6k stars 1.71k forks source link

Bedrock Authentication. AWS profile with name default not found in ~/.aws/credentials, using default profile #2446

Open cam-white-aeroflow opened 1 month ago

cam-white-aeroflow commented 1 month ago

Before submitting your bug report

Relevant environment info

- OS: MacOS 14.3 (23D56)
- Continue: 
Published
2023-05-27, 15:17:59
Last released
2024-09-25, 02:42:21
- IDE: VS Code
- Model: anthropic.claude-3-5-sonnet-20240620-v1:0
- config.json:

{
  "models": [
    {
      "title": "Claude 3.5 Sonnet",
      "provider": "bedrock",
      "model": "anthropic.claude-3-5-sonnet-20240620-v1:0",
      "region": "us-east-1",
      "profile": "default"
    }
  ]
}

Description

I am attempting to configure cursor to use claude 3.5 sonnet via AWS Bedrock. Currently my aws configuration and credentials are as follows

Context

cat ~/.aws/config | pbcopy:

[default]
region = us-east-1
output = json

cat ~/.aws/credentials | pbcopy: (with values omitted)

[default]
aws_access_key_id = <key_id>
aws_secret_access_key = <key>
aws_session_token = <token>

I am confident that these credentials+config are fine because I am able to invoke the model directly via the AWS CLI

aws bedrock-runtime converse \
--model-id anthropic.claude-3-5-sonnet-20240620-v1:0 \
--messages '[{"role": "user", "content": [{"text": "Describe the purpose of a \"hello world\" program in one line."}]}]' \
--inference-config '{"maxTokens": 512, "temperature": 0.5, "topP": 0.9}' | pbcopy
{
    "output": {
        "message": {
            "role": "assistant",
            "content": [
                {
                    "text": "A \"hello world\" program demonstrates the basic syntax of a programming language by displaying a simple greeting message."
                }
            ]
        }
    },
    "stopReason": "end_turn",
    "usage": {
        "inputTokens": 22,
        "outputTokens": 24,
        "totalTokens": 46
    },
    "metrics": {
        "latencyMs": 960
    }
}

Problem

I have attempted to configure continue to use the same model and the same profile + credentials cat ~/.continue/config.json | pbcopy

{
  "models": [
    {
      "title": "Claude 3.5 Sonnet",
      "provider": "bedrock",
      "model": "anthropic.claude-3-5-sonnet-20240620-v1:0",
      "region": "us-east-1",
      "profile": "default"
    }
  ]
}

However when I attempt to use the chat interface, I get the following error message

Could not resolve credentials using profile: [default] in configuration/credentials file(s).

The logs contain a suspicious warning

AWS profile with name default not found in ~/.aws/credentials, using default profile

At first I thought I made some dumb whitespace or spelling mistake but I do not believe I did. With the exception of omitting my aws keys, the files I have provided are unmodified, piped directly from cat into pbcopy

To reproduce

  1. open chat interface with cmd+L
  2. type a test prompt such as 'hello'
  3. press the enter button
  4. observe error

Log output

console.ts:137 [Extension Host] AWS profile with name default not found in ~/.aws/credentials, using default profile
console.ts:137 [Extension Host] CredentialsProviderError: Could not resolve credentials using profile: [default] in configuration/credentials file(s).
    at resolveProfileData (/Users/cam.white/.vscode/extensions/continue.continue-0.8.52-darwin-arm64/out/extension.js:477034:13)
    at /Users/cam.white/.vscode/extensions/continue.continue-0.8.52-darwin-arm64/out/extension.js:477043:14
    at async Bedrock._getCredentials (/Users/cam.white/.vscode/extensions/continue.continue-0.8.52-darwin-arm64/out/extension.js:483872:18)
    at async Bedrock._streamChat (/Users/cam.white/.vscode/extensions/continue.continue-0.8.52-darwin-arm64/out/extension.js:483785:29)
    at async Bedrock.streamChat (/Users/cam.white/.vscode/extensions/continue.continue-0.8.52-darwin-arm64/out/extension.js:104627:30)
    at async llmStreamChat (/Users/cam.white/.vscode/extensions/continue.continue-0.8.52-darwin-arm64/out/extension.js:516613:23)
    at async i.value (/Users/cam.white/.vscode/extensions/continue.continue-0.8.52-darwin-arm64/out/extension.js:523115:29)
log.ts:439   ERR [Extension Host] Error handling webview message: {
  "msg": {
    "messageId": "b16c15e4-40c0-464b-b905-7c2149a86e7e",
    "messageType": "llm/streamChat",
    "data": {
      "messages": [
        {
          "role": "user",
          "content": [
            {
              "type": "text",
              "text": "hello"
            }
          ]
        }
      ],
      "title": "Claude 3.5 Sonnet",
      "completionOptions": {}
    }
  }
}

CredentialsProviderError: Could not resolve credentials using profile: [default] in configuration/credentials file(s).
console.ts:137 [Extension Host] Error handling webview message: {
  "msg": {
    "messageId": "b16c15e4-40c0-464b-b905-7c2149a86e7e",
    "messageType": "llm/streamChat",
    "data": {
      "messages": [
        {
          "role": "user",
          "content": [
            {
              "type": "text",
              "text": "hello"
            }
          ]
        }
      ],
      "title": "Claude 3.5 Sonnet",
      "completionOptions": {}
    }
  }
}

CredentialsProviderError: Could not resolve credentials using profile: [default] in configuration/credentials file(s).
notificationsAlerts.ts:42 Could not resolve credentials using profile: [default] in configuration/credentials file(s).

Patrick-Erichsen commented 1 month ago

Hi @cam-white-aeroflow , thanks for the great writeup here! The Bedrock provider was contributed by a community member so unfortunately I'm not the most familiar with it.

This appears to be the lines you're hitting: https://github.com/continuedev/continue/blob/main/core/llm/llms/Bedrock.ts#L152-L164

My only thought is to perhaps try removing the profile from your config.json, e.g.

{
  "models": [
    {
      "title": "Claude 3.5 Sonnet",
      "provider": "bedrock",
      "model": "anthropic.claude-3-5-sonnet-20240620-v1:0",
      "region": "us-east-1",
    }
  ]
}

This should then set your profile to "bedrock", which should fail, and then fallback to the default profile here: https://github.com/continuedev/continue/blob/main/core/llm/llms/Bedrock.ts#L161

Other than that my best guess is that there is some unexpected behavior going on with the fromIni method we're importing: https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-credential-providers/Variable/fromIni/

Apologies for the inconclusive troubleshooting though.

cc @KoStard - wondering if you have any insights here.

gcwngo commented 1 month ago

@cam-white-aeroflow running into this issue as well, any luck on solving this?