-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Not able to use AnthropicsBedrockClient, Not able to import #6483
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
Labels
Comments
Hi, Thanks for testing this out and the feedback. |
3 tasks
Hi @amardeepjaiman , |
victordibia
added a commit
that referenced
this issue
May 10, 2025
<!-- Thank you for your contribution! Please review https://microsoft.github.io/autogen/docs/Contribute before opening a pull request. --> Some fixes with the AnthropicBedrockChatCompletionClient - Ensure `AnthropicBedrockChatCompletionClient` exported and can be imported. - Update the BedrockInfo keys serialization - client argument can be string (similar to api key in this ) but exported config should be Secret - Replace `AnthropicBedrock` with `AsyncAnthropicBedrock` : client should be async to work with the ag stack and the BaseAnthropicClient it inherits from - Improve `AnthropicBedrockChatCompletionClient` docstring to use the correct client arguments rather than serialized dict format. Expect ```python from autogen_ext.models.anthropic import AnthropicBedrockChatCompletionClient, BedrockInfo from autogen_core.models import UserMessage, ModelInfo async def main(): anthropic_client = AnthropicBedrockChatCompletionClient( model="anthropic.claude-3-5-sonnet-20240620-v1:0", temperature=0.1, model_info=ModelInfo(vision=False, function_calling=True, json_output=False, family="unknown", structured_output=True), bedrock_info=BedrockInfo( aws_access_key="<aws_access_key>", aws_secret_key="<aws_secret_key>", aws_session_token="<aws_session_token>", aws_region="<aws_region>", ), ) # type: ignore result = await anthropic_client.create([UserMessage(content="What is the capital of France?", source="user")]) print(result) await main() ``` <!-- Please add a reviewer to the assignee section when you create a PR. If you don't have the access to it, we will shortly find a reviewer and assign them to your PR. --> ## Why are these changes needed? <!-- Please give a short summary of the change and the problem this solves. --> ## Related issue number <!-- For example: "Closes #1234" --> Closes #6483 ## Checks - [ ] I've included any doc changes needed for <https://microsoft.github.io/autogen/>. See <https://github.com/microsoft/autogen/blob/main/CONTRIBUTING.md> to build and test documentation locally. - [ ] I've added tests (if relevant) corresponding to the changes introduced in this PR. - [ ] I've made sure all auto checks have passed. --------- Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What happened?
Describe the bug
I am getting following import while using the AnthroipcsBedrockClient using Autogen-ext[Anthropics]==0.5.6 package:
File "C:\Users\ajaiman\Projects\code\Official\AgenticAI-ITSM\app\utils\bedrock_llm_anthropics.py", line 8, in
from autogen_ext.models.anthropic import AnthropicBedrockChatCompletionClient
ImportError: cannot import name 'AnthropicBedrockChatCompletionClient' from 'autogen_ext.models.anthropic' (C:\Users\ajaiman\Projects\code\Official\AgenticAI-ITSM.venv2\Lib\site-packages\autogen_ext\models\anthropic_init_.py)
To Reproduce
Using the following code:
config = {
"model": "anthropic.claude-3-5-sonnet-20240620-v1:0",
"temperature": 0.1,
"model_info": {
"vision": True,
"function_calling": True,
"json_output": True,
"family": ModelFamily.CLAUDE_3_5_SONNET,
"structured_output": True
},
"bedrock_info": {
"aws_access_key": AWS_ACCESS_KEY_ID,
"aws_secret_key": AWS_SECRET_ACCESS_KEY,
"aws_region": AWS_REGION,
},
}
anthropic_client = AnthropicBedrockChatCompletionClient(**config)
model_result = await anthropic_client.create(
messages=[UserMessage(content="Whats the weather in Paris?", source="User")]
)
print(model_result)
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
Add any other context about the problem here.
Which packages was the bug in?
Python AgentChat (autogen-agentchat>=0.4.0)
AutoGen library version.
Python 0.5.6
Other library version.
No response
Model used
anthropic.claude-3-5-sonnet-20240620-v1:0
Model provider
AWS Bedrock
Other model provider
No response
Python version
3.11
.NET version
None
Operating system
Windows
The text was updated successfully, but these errors were encountered: