mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 10:44:24 +00:00
fix(model_cost_map): fix json parse error on model cost map + add unit test (#8629)
Fixes https://github.com/BerriAI/litellm/pull/8619#issuecomment-2666693045
This commit is contained in:
parent
49610485a2
commit
ea985dda0b
3 changed files with 38 additions and 1 deletions
|
@ -2961,3 +2961,18 @@ async def test_cost_calculator_with_custom_pricing_router(model_item, custom_pri
|
|||
)
|
||||
# assert resp.model == "random-model"
|
||||
assert resp._hidden_params["response_cost"] > 0
|
||||
|
||||
|
||||
def test_json_valid_model_cost_map():
|
||||
import json
|
||||
|
||||
os.environ["LITELLM_LOCAL_MODEL_COST_MAP"] = "True"
|
||||
|
||||
model_cost = litellm.get_model_cost_map(url="")
|
||||
|
||||
try:
|
||||
# Attempt to serialize and deserialize the JSON
|
||||
json_str = json.dumps(model_cost)
|
||||
json.loads(json_str)
|
||||
except json.JSONDecodeError as e:
|
||||
assert False, f"Invalid JSON format: {str(e)}"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue