From 9405d161b19d450953aa75ae022a98a1e8a5a11a Mon Sep 17 00:00:00 2001 From: Ghraven Date: Sat, 8 Aug 2026 12:08:15 +0800 Subject: [PATCH] fix(ui): harden token costs refresh script --- telemetry/ui/scripts/token_costs.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/telemetry/ui/scripts/token_costs.py b/telemetry/ui/scripts/token_costs.py index 2eb03769e..7ef1ba9b4 100644 --- a/telemetry/ui/scripts/token_costs.py +++ b/telemetry/ui/scripts/token_costs.py @@ -21,7 +21,8 @@ import requests import json -response = requests.get(url) +response = requests.get(url, timeout=30) +response.raise_for_status() data = response.json() keys_wanted = ["input_cost_per_token", "output_cost_per_token", "max_tokens", "max_input_tokens", "max_output_tokens"] @@ -34,5 +35,5 @@ del data[model_entry][key] # save the data -with open("model_costs.json", "w") as f: +with open("model_costs.json", "w", encoding="utf-8") as f: json.dump(data, f)