Skip to content

Commit

Permalink
Merge pull request #57 from AndreCNF/fix/return_if_not_prompt_nor_mes…
Browse files Browse the repository at this point in the history
…sage

fix: 🐛 Skip updating estimates if event isn't a prompt nor message
  • Loading branch information
areibman authored Jun 21, 2024
2 parents e1d52db + 1c5dae9 commit 39c669f
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tokencost/callbacks/llama_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ def _calc_llm_event_cost(self, payload: dict) -> None:
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"]
Expand Down

0 comments on commit 39c669f

Please sign in to comment.