diff --git a/instructor/client_anthropic.py b/instructor/client_anthropic.py index 9caf37cdc..d0e23590a 100644 --- a/instructor/client_anthropic.py +++ b/instructor/client_anthropic.py @@ -12,7 +12,6 @@ def from_anthropic( anthropic.Anthropic | anthropic.AnthropicBedrock | anthropic.AnthropicVertex ), mode: instructor.Mode = instructor.Mode.ANTHROPIC_TOOLS, - enable_prompt_caching: bool = False, beta: bool = False, **kwargs: Any, ) -> instructor.Instructor: ... @@ -26,7 +25,6 @@ def from_anthropic( | anthropic.AsyncAnthropicVertex ), mode: instructor.Mode = instructor.Mode.ANTHROPIC_TOOLS, - enable_prompt_caching: bool = False, beta: bool = False, **kwargs: Any, ) -> instructor.AsyncInstructor: ... diff --git a/instructor/utils.py b/instructor/utils.py index efdb590a3..088cebbaf 100644 --- a/instructor/utils.py +++ b/instructor/utils.py @@ -167,6 +167,12 @@ def update_total_usage( if isinstance(response_usage, AnthropicUsage) and isinstance( total_usage, AnthropicUsage ): + if not total_usage.cache_creation_input_tokens: + total_usage.cache_creation_input_tokens = 0 + + if not total_usage.cache_read_input_tokens: + total_usage.cache_read_input_tokens = 0 + total_usage.input_tokens += response_usage.input_tokens or 0 total_usage.output_tokens += response_usage.output_tokens or 0 total_usage.cache_creation_input_tokens += (