Skip to content

armgit / burr

Public Imported from GitHub
0

Build applications that make decisions (chatbots, agents, simulations, etc...). Monitor, trace, persist, and execute on your own infrastructure.

fix: harden token cost refresh script (#918)

Rolly Calma24f05e37ace7
diff --git a/telemetry/ui/scripts/token_costs.py b/telemetry/ui/scripts/token_costs.py
index 2eb03769..7ef1ba9b 100644
--- a/telemetry/ui/scripts/token_costs.py
+++ b/telemetry/ui/scripts/token_costs.py
@@ -21,7 +21,8 @@ url = "https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_c
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 @@ for model_entry in data:
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)