Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds LLM cost view in insights #376

Merged
merged 6 commits into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions telemetry/ui/scripts/model_costs.json

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions telemetry/ui/scripts/token_costs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
url = "https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json"

# Load the data
import requests
import json

response = requests.get(url)
skrawcz marked this conversation as resolved.
Show resolved Hide resolved
data = response.json()

keys_wanted = ["input_cost_per_token", "output_cost_per_token", "max_tokens", "max_input_tokens", "max_output_tokens"]

del data["sample_spec"]
# Extract the keys we want
for model_entry in data:
for key in list(data[model_entry].keys()):
if key not in keys_wanted:
del data[model_entry][key]

# save the data
with open("model_costs.json", "w") as f:
json.dump(data, f)
Loading
Loading