From 514477b1e717d4cba84a19e428bf170b9e3b0c34 Mon Sep 17 00:00:00 2001 From: vietpham1911 Date: Thu, 16 May 2024 14:11:29 +0930 Subject: [PATCH] Bug fix: The prior code removed values like "supports_function_calling" or "supports_vision". This is fixed now. Nothing is being removed. Only the pricings and the maximum tokens are being edited and new models in openrouter are being added. --- auto_update_pricing.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/auto_update_pricing.py b/auto_update_pricing.py index bda59d398ef..f59d4b4729b 100644 --- a/auto_update_pricing.py +++ b/auto_update_pricing.py @@ -33,14 +33,17 @@ def update_local_data(local_data, remote_data): model_suffix = model_name[len("openrouter/"):] for model in remote_data["data"]: if model["id"] == model_suffix: - model_info["max_tokens"] = model["context_length"] - model_info["input_cost_per_token"] = model["pricing"]["prompt"] - model_info["output_cost_per_token"] = model["pricing"]["completion"] + # Update only the values that need to be updated + model_info.update({ + "max_tokens": model["context_length"], + "input_cost_per_token": model["pricing"]["prompt"], + "output_cost_per_token": model["pricing"]["completion"] + }) break # Add models not in local data yet for model in remote_data["data"]: model_id = model["id"] - if model_id not in local_data: + if f"openrouter/{model_id}" not in local_data: local_data[f"openrouter/{model_id}"] = { "max_tokens": model["context_length"], "input_cost_per_token": model["pricing"]["prompt"],