Merge pull request #57 from AndreCNF/fix/return_if_not_prompt_nor_message

fix: 🐛 Skip updating estimates if event isn't a prompt nor message
This commit is contained in:
Alex Reibman
2024-06-21 10:35:00 -07:00
committed by GitHub

View File

@@ -39,6 +39,8 @@ class TokenCostHandler(BaseCallbackHandler):
estimates = calculate_all_costs_and_tokens(
messages_str, response, self.model
)
else:
return
self.prompt_cost += estimates["prompt_cost"]
self.completion_cost += estimates["completion_cost"]