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

Wrong request options in retries #590

Closed
hahampis opened this issue Jul 13, 2024 · 4 comments
Closed

Wrong request options in retries #590

hahampis opened this issue Jul 13, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@hahampis
Copy link

We are using AsyncAnthropicBedrock class. We noticed that when a request is automatically retried, the request options do not have the correct values, resulting in 400 - Bad request. Example logs (actual content redacted):

2024-07-12 09:56:25,645 - anthropic._base_client - DEBUG - Request options: {'method': 'post', 'url': '/model/anthropic.claude-3-haiku-20240307-v1:0/invoke', 'timeout': 600, 'files': None, 'json_data': {'max_tokens': 4096, 'messages': [{'role': 'user', 'content': '...', , 'temperature': 0.0, 'top_k': 1, 'anthropic_version': 'bedrock-2023-05-31'}}
2024-07-12 09:56:25,658 - anthropic._base_client - DEBUG - Encountered Exception	
2024-07-12 12:56:25.665	Traceback (most recent call last):
...
2024-07-12 09:56:25,665 - anthropic._base_client - DEBUG - 1 retry left
2024-07-12 09:56:25,665 - anthropic._base_client - INFO - Retrying request to /v1/messages in 0.924755 seconds
2024-07-12 09:56:26,591 - anthropic._base_client - DEBUG - Request options: {'method': 'post', 'url': '/model/None/invoke', 'timeout': 600, 'files': None, 'json_data': {'max_tokens': 4096, 'messages': [{'role': 'user', 'content': '...', 'temperature': 0.0, 'top_k': 1, 'anthropic_version': 'bedrock-2023-05-31'}}
2024-07-12 09:56:26,773 - httpx - INFO - HTTP Request: POST https://bedrock-runtime.eu-central-1.amazonaws.com/model/None/invoke "HTTP/1.1 400 Bad Request"
2024-07-12 09:56:26,775 - anthropic._base_client - DEBUG - HTTP Request: POST https://bedrock-runtime.eu-central-1.amazonaws.com/model/None/invoke "400 Bad Request"
2024-07-12 09:56:26,775 - anthropic._base_client - DEBUG - Encountered httpx.HTTPStatusError

This started happening with version 0.31.0. Doesn't happen with version 0.30.1.
Maybe has something to do with #580 ?

@RobertCraigie RobertCraigie added the bug Something isn't working label Jul 15, 2024
@RobertCraigie
Copy link
Collaborator

Thanks for the report, I can reproduce this, working on a fix.

@RobertCraigie
Copy link
Collaborator

this will be fixed in the next release: #585, v0.31.1.

@yasyf
Copy link

yasyf commented Jul 17, 2024

I think this is happening with vertex too.. upon retry you get KeyError: 'model', which I think happens because the options payload is mutated. Fix here: #599

@RobertCraigie
Copy link
Collaborator

Sorry about that @yasyf, that will be fixed in the next release: #595

Until it's released (hopefully later today) you can either downgrade or install from github, e.g. python -m pip install -U git+https://github.com/anthropics/anthropic-sdk-python@next.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants