models-dev 1.0.53__tar.gz → 1.0.55__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {models_dev-1.0.53 → models_dev-1.0.55}/.gitignore +1 -0
- {models_dev-1.0.53 → models_dev-1.0.55}/PKG-INFO +1 -1
- {models_dev-1.0.53 → models_dev-1.0.55}/pyproject.toml +1 -1
- {models_dev-1.0.53 → models_dev-1.0.55}/scripts/update.py +42 -7
- models_dev-1.0.55/src/models_dev/data.json.gz +0 -0
- {models_dev-1.0.53 → models_dev-1.0.55}/uv.lock +1 -1
- models_dev-1.0.53/src/models_dev/data.json.gz +0 -0
- {models_dev-1.0.53 → models_dev-1.0.55}/LICENSE +0 -0
- {models_dev-1.0.53 → models_dev-1.0.55}/README.md +0 -0
- {models_dev-1.0.53 → models_dev-1.0.55}/src/models_dev/__init__.py +0 -0
- {models_dev-1.0.53 → models_dev-1.0.55}/src/models_dev/_loader.py +0 -0
- {models_dev-1.0.53 → models_dev-1.0.55}/src/models_dev/_types.py +0 -0
- {models_dev-1.0.53 → models_dev-1.0.55}/src/models_dev/py.typed +0 -0
- {models_dev-1.0.53 → models_dev-1.0.55}/tests/test_data.py +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# /// script
|
|
2
|
-
# dependencies = ["anthropic", "httpx", "gitpython"]
|
|
2
|
+
# dependencies = ["anthropic", "httpx", "gitpython", "models-dev"]
|
|
3
3
|
# ///
|
|
4
4
|
"""Update data.json.gz from models.dev.
|
|
5
5
|
|
|
@@ -48,11 +48,14 @@ def compute_diff(old: str, new: str) -> str:
|
|
|
48
48
|
return "".join(diff)
|
|
49
49
|
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
MODEL_ID = "claude-haiku-4-5-20251001"
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def generate_commit_message(diff: str) -> tuple[str, int, int]:
|
|
55
|
+
"""Generate commit message using Anthropic API. Returns (message, in_tokens, out_tokens)."""
|
|
53
56
|
api_key = os.environ.get("ANTHROPIC_API_KEY")
|
|
54
57
|
if not api_key:
|
|
55
|
-
return "chore: update models data"
|
|
58
|
+
return "chore: update models data", 0, 0
|
|
56
59
|
|
|
57
60
|
import anthropic
|
|
58
61
|
|
|
@@ -64,11 +67,28 @@ def generate_commit_message(diff: str) -> str:
|
|
|
64
67
|
)
|
|
65
68
|
prompt = f"{prompt}\n\n{diff[:10000]}"
|
|
66
69
|
resp = client.messages.create(
|
|
67
|
-
model=
|
|
70
|
+
model=MODEL_ID,
|
|
68
71
|
max_tokens=1000,
|
|
69
72
|
messages=[{"role": "user", "content": prompt}],
|
|
70
73
|
)
|
|
71
|
-
return resp.content[0].text.strip()
|
|
74
|
+
return resp.content[0].text.strip(), resp.usage.input_tokens, resp.usage.output_tokens
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def print_token_stats(input_tokens: int, output_tokens: int) -> None:
|
|
78
|
+
"""Print token usage and cost using models-dev pricing."""
|
|
79
|
+
from models_dev import get_model_by_id
|
|
80
|
+
|
|
81
|
+
model = get_model_by_id("anthropic", MODEL_ID)
|
|
82
|
+
if not model.cost:
|
|
83
|
+
print(f"Tokens: {input_tokens} in, {output_tokens} out (no pricing data)")
|
|
84
|
+
return
|
|
85
|
+
|
|
86
|
+
input_cost = (input_tokens / 1_000_000) * (model.cost.input or 0)
|
|
87
|
+
output_cost = (output_tokens / 1_000_000) * (model.cost.output or 0)
|
|
88
|
+
total_cost = input_cost + output_cost
|
|
89
|
+
|
|
90
|
+
print(f"Tokens: {input_tokens} in, {output_tokens} out")
|
|
91
|
+
print(f"Cost: ${total_cost:.6f} (${model.cost.input}/M in, ${model.cost.output}/M out)")
|
|
72
92
|
|
|
73
93
|
|
|
74
94
|
def get_version() -> str:
|
|
@@ -95,8 +115,22 @@ def save_data(data_str: str) -> None:
|
|
|
95
115
|
f.write(json.dumps(json.loads(data_str), separators=(",", ":")))
|
|
96
116
|
|
|
97
117
|
|
|
118
|
+
def get_action_url() -> str | None:
|
|
119
|
+
"""Get GitHub Action run URL from environment."""
|
|
120
|
+
server = os.environ.get("GITHUB_SERVER_URL")
|
|
121
|
+
repo = os.environ.get("GITHUB_REPOSITORY")
|
|
122
|
+
run_id = os.environ.get("GITHUB_RUN_ID")
|
|
123
|
+
if server and repo and run_id:
|
|
124
|
+
return f"{server}/{repo}/actions/runs/{run_id}"
|
|
125
|
+
return None
|
|
126
|
+
|
|
127
|
+
|
|
98
128
|
def commit(message: str) -> None:
|
|
99
129
|
"""Commit changes."""
|
|
130
|
+
action_url = get_action_url()
|
|
131
|
+
if action_url:
|
|
132
|
+
message = f"{message}\n\nAction: {action_url}"
|
|
133
|
+
|
|
100
134
|
repo = git.Repo(ROOT)
|
|
101
135
|
repo.index.add(["python/pyproject.toml", "python/src/models_dev/data.json.gz"])
|
|
102
136
|
repo.index.commit(message)
|
|
@@ -122,8 +156,9 @@ def main() -> int:
|
|
|
122
156
|
print(diff[:500])
|
|
123
157
|
|
|
124
158
|
print("Generating commit message...")
|
|
125
|
-
message = generate_commit_message(diff)
|
|
159
|
+
message, input_tokens, output_tokens = generate_commit_message(diff)
|
|
126
160
|
print(f"Message: {message}")
|
|
161
|
+
print_token_stats(input_tokens, output_tokens)
|
|
127
162
|
|
|
128
163
|
if args.dry_run:
|
|
129
164
|
print("Dry run, stopping")
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|