diff --git a/tokencost/callbacks/llama_index.py b/tokencost/callbacks/llama_index.py index ee4ef8e..d11c1ab 100644 --- a/tokencost/callbacks/llama_index.py +++ b/tokencost/callbacks/llama_index.py @@ -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"]