From 95bfb230e404b791d7b29e1335b07bbdf7075318 Mon Sep 17 00:00:00 2001 From: Harings Rob Date: Tue, 19 Nov 2024 13:57:07 +0100 Subject: [PATCH] Ensure cost per token is float. --- litellm/utils.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/litellm/utils.py b/litellm/utils.py index cb8a533541..8a1a45eefa 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -1972,6 +1972,11 @@ def register_model(model_cost: Union[str, dict]): # noqa: PLR0915 loaded_model_cost = litellm.get_model_cost_map(url=model_cost) for key, value in loaded_model_cost.items(): + ## Change, if present, input_cost_per_token and output_cost_per_token to float + if "input_cost_per_token" in value: + value["input_cost_per_token"] = float(value["input_cost_per_token"]) + if "output_cost_per_token" in value: + value["output_cost_per_token"] = float(value["output_cost_per_token"]) ## get model info ## try: existing_model: Union[ModelInfo, dict] = get_model_info(model=key)