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]: anthropic typing update for v0.41.0 release #17298

Open
mclean-connor opened this issue Dec 17, 2024 · 1 comment
Open

[Bug]: anthropic typing update for v0.41.0 release #17298

mclean-connor opened this issue Dec 17, 2024 · 1 comment
Labels
bug Something isn't working triage Issue needs to be triaged/prioritized

Comments

@mclean-connor
Copy link
Contributor

Bug Description

Anthropic updated their release. Types for prompt caching are now outdated and throw import errors:

from anthropic.types.beta.prompt_caching import (
    PromptCachingBetaTextBlockParam,
    PromptCachingBetaCacheControlEphemeralParam,
)

Based on, the change log, these can be updated to:

from anthropic.types import (
    TextBlockParam,
    CacheControlEphemeralParam,
)

Version

0.12.5

Steps to Reproduce

  1. install llama-index (0.12.5)
  2. install llama-index-llms-anthropic (0.6.1)
  3. use 0.41.0 release of anthropic package (released December 17, 2024)
  4. import llama-index-llms-anthropic package in python llama-index-llms-anthropic

Relevant Logs/Tracbacks

ropic/utils.py", line 18, in <module>
    from anthropic.types.beta.prompt_caching import (
ModuleNotFoundError: No module named 'anthropic.types.beta.prompt_caching'
@mclean-connor mclean-connor added bug Something isn't working triage Issue needs to be triaged/prioritized labels Dec 17, 2024
Copy link

dosubot bot commented Dec 17, 2024

Hey @mclean-connor! I'm here to help you with the issue you've encountered. I can assist with bug fixes, answer questions, and guide you on becoming a contributor. Let's work on resolving this together!

To resolve the import errors caused by the update in the anthropic package version 0.41.0, you need to update the import statements in your code. The outdated imports from anthropic.types.beta.prompt_caching should be replaced with the new imports from anthropic.types. Specifically, update your code as follows:

Replace:

from anthropic.types.beta.prompt_caching import (
    PromptCachingBetaTextBlockParam,
    PromptCachingBetaCacheControlEphemeralParam,
)

With:

from anthropic.types import (
    TextBlockParam,
    CacheControlEphemeralParam,
)

This change aligns with the updates in the anthropic package and should resolve the ModuleNotFoundError you are encountering.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

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

No branches or pull requests

1 participant