@@ -117,28 +117,30 @@ def _accumulate(self, step_usage: UsageParam) -> None:
117117 )
118118
119119 # Update costs from updated totals if pricing values are set
120- if (
120+ if not (
121121 self ._pricing
122122 and self ._pricing .input_cost_per_million_tokens
123123 and self ._pricing .output_cost_per_million_tokens
124124 ):
125- input_cost = (
126- self ._summary .input_tokens
127- * self ._pricing .input_cost_per_million_tokens
128- / 1e6
129- )
130- output_cost = (
131- self ._summary .output_tokens
132- * self ._pricing .output_cost_per_million_tokens
133- / 1e6
134- )
135- self ._summary .input_cost = input_cost
136- self ._summary .output_cost = output_cost
137- self ._summary .total_cost = input_cost + output_cost
138- self ._summary .currency = self ._pricing .currency
139- self ._summary .input_cost_per_million_tokens = (
140- self ._pricing .input_cost_per_million_tokens
141- )
142- self ._summary .output_cost_per_million_tokens = (
143- self ._pricing .output_cost_per_million_tokens
144- )
125+ return
126+
127+ input_cost = (
128+ self ._summary .input_tokens
129+ * self ._pricing .input_cost_per_million_tokens
130+ / 1e6
131+ )
132+ output_cost = (
133+ self ._summary .output_tokens
134+ * self ._pricing .output_cost_per_million_tokens
135+ / 1e6
136+ )
137+ self ._summary .input_cost = input_cost
138+ self ._summary .output_cost = output_cost
139+ self ._summary .total_cost = input_cost + output_cost
140+ self ._summary .currency = self ._pricing .currency
141+ self ._summary .input_cost_per_million_tokens = (
142+ self ._pricing .input_cost_per_million_tokens
143+ )
144+ self ._summary .output_cost_per_million_tokens = (
145+ self ._pricing .output_cost_per_million_tokens
146+ )
0 commit comments