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

Fix AttributeError with missing usage fields in AnthropicBedrock #1292

Open
2 of 8 tasks
emcf opened this issue Jan 3, 2025 · 0 comments · May be fixed by #1293
Open
2 of 8 tasks

Fix AttributeError with missing usage fields in AnthropicBedrock #1292

emcf opened this issue Jan 3, 2025 · 0 comments · May be fixed by #1293
Labels
anthropic bug Something isn't working

Comments

@emcf
Copy link

emcf commented Jan 3, 2025

  • This is actually a bug report.
  • I am not getting good LLM Results
  • I have tried asking for help in the community on discord or discussions and have not received a response.
  • I have tried searching the documentation and have not found an answer.

What Model are you using?

  • gpt-3.5-turbo
  • gpt-4-turbo
  • gpt-4
  • Other (please specify): us.anthropic.claude-3-5-sonnet-20241022-v2:0

Describe the bug
The usage object for Anthropic’s Bedrock client does not contain certain fields (cache_creation_input_tokens, cache_read_input_tokens), which causes an AttributeError in instructor.utils.update_total_usage() when attempting to sum usage stats.

To Reproduce

  1. Instantiate an AnthropicBedrock client (e.g., anthropic.AnthropicBedrock(...)).
  2. Use instructor.from_anthropic to wrap the client.
  3. Run test_client_anthropic_bedrock_response
  4. Get error: AttributeError: 'Usage' object has no attribute 'cache_creation_input_tokens'.

Expected behavior
instructor should gracefully handle Anthropic usage objects that don’t have those fields, rather than raising an AttributeError.

Screenshots
N/A

@github-actions github-actions bot added anthropic bug Something isn't working labels Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
anthropic bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant