Skip to content

Commit 0e3722f

Browse files
authoredFeb 20, 2025
Implement simple add for TokenUsage (#1002)
1 parent b38681d commit 0e3722f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed
 

‎src/codemodder/llm.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,13 @@ class TokenUsage:
127127
completion_tokens: int = 0
128128
prompt_tokens: int = 0
129129

130-
def __iadd__(self, other: Self) -> Self:
130+
def __add__(self, other: TokenUsage) -> TokenUsage:
131+
return TokenUsage(
132+
completion_tokens=self.completion_tokens + other.completion_tokens,
133+
prompt_tokens=self.prompt_tokens + other.prompt_tokens,
134+
)
135+
136+
def __iadd__(self, other: TokenUsage) -> Self:
131137
self.completion_tokens += other.completion_tokens
132138
self.prompt_tokens += other.prompt_tokens
133139
return self

0 commit comments

Comments
 (0)