From 00b001b96bed475be543f95065ae60a588f47af9 Mon Sep 17 00:00:00 2001 From: ishaan-jaff Date: Fri, 5 Jan 2024 15:26:04 +0530 Subject: [PATCH] (feat) completion_cost: improve model=None error --- litellm/utils.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/litellm/utils.py b/litellm/utils.py index 3f3978dd2..09cb52343 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -2848,6 +2848,10 @@ def completion_cost( elif len(prompt) > 0: prompt_tokens = token_counter(model=model, text=prompt) completion_tokens = token_counter(model=model, text=completion) + if model == None: + raise ValueError( + f"Model is None and does not exist in passed completion_response. Passed completion_response={completion_response}, model={model}" + ) # Calculate cost based on prompt_tokens, completion_tokens if "togethercomputer" in model or "together_ai" in model: