Skip to content

Commit

Permalink
fix: update pyright errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanleomk committed Dec 26, 2024
1 parent e476bc5 commit 14ca299
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 0 additions & 2 deletions instructor/client_anthropic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand All @@ -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: ...
Expand Down
6 changes: 6 additions & 0 deletions instructor/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 += (
Expand Down

0 comments on commit 14ca299

Please sign in to comment.