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.
@@ -8,3 +8,4 @@ build/
8
8
  .ruff_cache/
9
9
  .idea/
10
10
  python/.venv/
11
+ .env
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: models-dev
3
- Version: 1.0.53
3
+ Version: 1.0.55
4
4
  Summary: Typed Python interface to models.dev API data
5
5
  Project-URL: Homepage, https://github.com/vklimontovich/models-dev
6
6
  Project-URL: Documentation, https://models.dev
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "models-dev"
3
- version = "1.0.53"
3
+ version = "1.0.55"
4
4
  description = "Typed Python interface to models.dev API data"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -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
- def generate_commit_message(diff: str) -> str:
52
- """Generate commit message using Anthropic API."""
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="claude-haiku-4-5",
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")
@@ -34,7 +34,7 @@ wheels = [
34
34
 
35
35
  [[package]]
36
36
  name = "models-dev"
37
- version = "1.0.53"
37
+ version = "1.0.55"
38
38
  source = { editable = "." }
39
39
 
40
40
  [package.dev-dependencies]
File without changes
File without changes