From 14ca299271a49e6e2bcf63c160c0162c8121036a Mon Sep 17 00:00:00 2001 From: Ivan Leo Date: Thu, 26 Dec 2024 13:15:57 +0800 Subject: [PATCH] fix: update pyright errors --- instructor/client_anthropic.py | 2 -- instructor/utils.py | 6 ++++++ 2 files changed, 6 insertions(+), 2 deletions(-) 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 += (