Ensure cost per token is float.

This commit is contained in:
Harings Rob 2024-11-19 13:57:07 +01:00
parent 7550aba474
commit 95bfb230e4
No known key found for this signature in database
GPG key ID: 3A20FEADE1CD75C4

View file

@ -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)