From d79df3a1e9ad4336c3cd57ed85045cf6a83a269e Mon Sep 17 00:00:00 2001 From: ishaan-jaff Date: Thu, 28 Dec 2023 22:11:08 +0530 Subject: [PATCH] (fix) together_ai cost tracking --- litellm/llms/together_ai.py | 2 +- litellm/utils.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/litellm/llms/together_ai.py b/litellm/llms/together_ai.py index e8a74724bc6..d4b85e9ca31 100644 --- a/litellm/llms/together_ai.py +++ b/litellm/llms/together_ai.py @@ -215,7 +215,7 @@ def completion( "choices" ][0]["finish_reason"] model_response["created"] = int(time.time()) - model_response["model"] = model + model_response["model"] = "together_ai/" + model usage = Usage( prompt_tokens=prompt_tokens, completion_tokens=completion_tokens, diff --git a/litellm/utils.py b/litellm/utils.py index af926d362fb..39723144889 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -2644,7 +2644,7 @@ def completion_cost( completion_tokens = token_counter(model=model, text=completion) # Calculate cost based on prompt_tokens, completion_tokens - if "togethercomputer" in model: + if "togethercomputer" in model or "together_ai" in model: # together ai prices based on size of llm # get_model_params_and_category takes a model name and returns the category of LLM size it is in model_prices_and_context_window.json model = get_model_params_and_category(model) @@ -2661,7 +2661,8 @@ def completion_cost( completion_tokens=completion_tokens, ) return prompt_tokens_cost_usd_dollar + completion_tokens_cost_usd_dollar - except: + except Exception as e: + print_verbose(f"LiteLLM: Excepton when cost calculating {str(e)}") return 0.0 # this should not block a users execution path