File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ def initialize
10
10
@tool_calls = { }
11
11
@input_tokens = 0
12
12
@output_tokens = 0
13
+ @cached_tokens = 0
14
+ @cache_creation_tokens = 0
13
15
@latest_tool_call_id = nil
14
16
end
15
17
@@ -35,6 +37,8 @@ def to_message(response)
35
37
tool_calls : tool_calls_from_stream ,
36
38
input_tokens : @input_tokens . positive? ? @input_tokens : nil ,
37
39
output_tokens : @output_tokens . positive? ? @output_tokens : nil ,
40
+ cached_tokens : @cached_tokens . positive? ? @cached_tokens : nil ,
41
+ cache_creation_tokens : @cache_creation_tokens . positive? ? @cache_creation_tokens : nil ,
38
42
raw : response
39
43
)
40
44
end
@@ -90,6 +94,8 @@ def find_tool_call(tool_call_id)
90
94
def count_tokens ( chunk )
91
95
@input_tokens = chunk . input_tokens if chunk . input_tokens
92
96
@output_tokens = chunk . output_tokens if chunk . output_tokens
97
+ @cached_tokens = chunk . cached_tokens if chunk . cached_tokens
98
+ @cache_creation_tokens = chunk . cache_creation_tokens if chunk . cache_creation_tokens
93
99
end
94
100
end
95
101
end
You can’t perform that action at this time.
0 commit comments