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.
This commit is contained in:
vietpham1911 2024-05-16 14:11:29 +09:30 • committed by Rajan Paneru
parent 771f06bd17
commit 514477b1e7

View file

@ -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"],