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

[Bug]: Bedrock support not working #3295

Closed
billdoors opened this issue Aug 5, 2024 · 5 comments
Closed

[Bug]: Bedrock support not working #3295

billdoors opened this issue Aug 5, 2024 · 5 comments

Comments

@billdoors
Copy link

Describe the bug

#3210

Steps to reproduce

  1. I verified that my aws_access_key, aws_secret_key, and aws_session_token are working fine using the following code:
from anthropic import AnthropicBedrock
client = AnthropicBedrock(
       aws_access_key="xxx",
       aws_secret_key="xxx",
       aws_session_token= "xxx"
        aws_region="us-east-1",
)

message = client.messages.create(
    model="anthropic.claude-3-sonnet-20240229-v1:0",
    max_tokens=256,
    messages=[{"role": "user", "content": "Hello, world. tell me a joke"}]
)
import autogen

config_list = {
        "model": "anthropic.claude-3-5-sonnet-20240620-v1:0",
        "aws_access_key":"xxx",
        "aws_secret_key":"xxx",
        "aws_session_token": "xxx",
        "aws_region":"us-east-1",
        "api_type": "anthropic",
    }
assistant = autogen.AssistantAgent("assistant", llm_config=config_list)

support_request = {
        "content": "I am unable to install the latest update of the software.",
        "role": "user"
    }

assistant.generate_reply(messages=[support_request])

I got error message: PermissionDeniedError: Error code: 403 - {'message': 'The security token included in the request is invalid.'}

Model Used

No response

Expected Behavior

No response

Screenshots and logs

No response

Additional Information

No response

@Varun2101
Copy link

Varun2101 commented Aug 5, 2024

Facing the same issue.

Appears to be related to f054840 where the aws_session_token was removed from required_keys. It's not optional if you're working with session access to AWS Bedrock (eg. for developing/testing code locally). It should get added to openai_config if it's not None.

@billdoors
Copy link
Author

@Varun2101 you are right. If I create an IAM user and provide the aws_access_key and aws_secret_key, it works.

@PrashantSaikia
Copy link

How do we make Autogen work with Bedrock? I am trying the following code with a Mistral model:

from autogen import AssistantAgent, UserProxyAgent
from dotenv import load_dotenv
import os

load_dotenv()

config_list = [
    {
        "model": "mistral.mixtral-8x7b-instruct-v0:1",
        "aws_access_key":os.getenv('aws_access_key_id'),
        "aws_secret_key":os.getenv('aws_secret_access_key'),
        "aws_region":"us-west-2",
        "aws_session_token":"none",
        "api_type": "mistral",
        "api_key": "none"
    }
]

assistant = AssistantAgent("assistant", llm_config={"config_list": config_list})

# Create a UserProxyAgent that can execute code
user_proxy = UserProxyAgent("user_proxy", code_execution_config={"use_docker": False})

# Initiate a chat between the user proxy and the assistant
message = f'''<s>[INST]
Enter your prompt here
[/INST]'''

user_proxy.initiate_chat(assistant, message=message)

It gives me the following error:

MistralAPIException: Status: 401. Message: {
  "message":"Unauthorized",
  "request_id":"02fb534ea9da864a9db3646dbc4cf16b"
}

@makkzone
Copy link
Contributor

makkzone commented Aug 7, 2024

As of now, it supports only anthropic.

Bedrock client is being added to Autogen through #3232 .

github-merge-queue bot pushed a commit that referenced this issue Aug 9, 2024
* Fix to consider session token in request

* Formatted

---------

Co-authored-by: Chi Wang <[email protected]>
@makkzone
Copy link
Contributor

makkzone commented Aug 9, 2024

@billdoors This was fixed. Please close this if you are good.

victordibia pushed a commit that referenced this issue Aug 28, 2024
* Fix to consider session token in request

* Formatted

---------

Co-authored-by: Chi Wang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants