models-dev 1.0.54__tar.gz → 1.0.56__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.56/.gitignore +1 -0
- {models_dev-1.0.54 → models_dev-1.0.56}/PKG-INFO +1 -1
- {models_dev-1.0.54 → models_dev-1.0.56}/pyproject.toml +1 -1
- {models_dev-1.0.54 → models_dev-1.0.56}/scripts/update.py +55 -9
- models_dev-1.0.56/src/models_dev/data.json.gz +0 -0
- {models_dev-1.0.54 → models_dev-1.0.56}/uv.lock +1 -1
- models_dev-1.0.54/.gitignore +0 -10
- models_dev-1.0.54/src/models_dev/data.json.gz +0 -0
- {models_dev-1.0.54 → models_dev-1.0.56}/LICENSE +0 -0
- {models_dev-1.0.54 → models_dev-1.0.56}/README.md +0 -0
- {models_dev-1.0.54 → models_dev-1.0.56}/src/models_dev/__init__.py +0 -0
- {models_dev-1.0.54 → models_dev-1.0.56}/src/models_dev/_loader.py +0 -0
- {models_dev-1.0.54 → models_dev-1.0.56}/src/models_dev/_types.py +0 -0
- {models_dev-1.0.54 → models_dev-1.0.56}/src/models_dev/py.typed +0 -0
- {models_dev-1.0.54 → models_dev-1.0.56}/tests/test_data.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/.env
|
|
@@ -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
|
|
|
@@ -23,6 +23,7 @@ DATA_URL = "https://models.dev/api.json"
|
|
|
23
23
|
ROOT = Path(__file__).parent.parent.parent
|
|
24
24
|
DATA_PATH = ROOT / "python" / "src" / "models_dev" / "data.json.gz"
|
|
25
25
|
PYPROJECT_PATH = ROOT / "python" / "pyproject.toml"
|
|
26
|
+
NODE_PACKAGE_PATH = ROOT / "node" / "package.json"
|
|
26
27
|
|
|
27
28
|
|
|
28
29
|
def fetch_latest() -> str:
|
|
@@ -48,11 +49,14 @@ def compute_diff(old: str, new: str) -> str:
|
|
|
48
49
|
return "".join(diff)
|
|
49
50
|
|
|
50
51
|
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
MODEL_ID = "claude-haiku-4-5-20251001"
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def generate_commit_message(diff: str) -> tuple[str, int, int]:
|
|
56
|
+
"""Generate commit message using Anthropic API. Returns (message, in_tokens, out_tokens)."""
|
|
53
57
|
api_key = os.environ.get("ANTHROPIC_API_KEY")
|
|
54
58
|
if not api_key:
|
|
55
|
-
return "chore: update models data"
|
|
59
|
+
return "chore: update models data", 0, 0
|
|
56
60
|
|
|
57
61
|
import anthropic
|
|
58
62
|
|
|
@@ -64,11 +68,28 @@ def generate_commit_message(diff: str) -> str:
|
|
|
64
68
|
)
|
|
65
69
|
prompt = f"{prompt}\n\n{diff[:10000]}"
|
|
66
70
|
resp = client.messages.create(
|
|
67
|
-
model=
|
|
71
|
+
model=MODEL_ID,
|
|
68
72
|
max_tokens=1000,
|
|
69
73
|
messages=[{"role": "user", "content": prompt}],
|
|
70
74
|
)
|
|
71
|
-
return resp.content[0].text.strip()
|
|
75
|
+
return resp.content[0].text.strip(), resp.usage.input_tokens, resp.usage.output_tokens
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def print_token_stats(input_tokens: int, output_tokens: int) -> None:
|
|
79
|
+
"""Print token usage and cost using models-dev pricing."""
|
|
80
|
+
from models_dev import get_model_by_id
|
|
81
|
+
|
|
82
|
+
model = get_model_by_id("anthropic", MODEL_ID)
|
|
83
|
+
if not model.cost:
|
|
84
|
+
print(f"Tokens: {input_tokens} in, {output_tokens} out (no pricing data)")
|
|
85
|
+
return
|
|
86
|
+
|
|
87
|
+
input_cost = (input_tokens / 1_000_000) * (model.cost.input or 0)
|
|
88
|
+
output_cost = (output_tokens / 1_000_000) * (model.cost.output or 0)
|
|
89
|
+
total_cost = input_cost + output_cost
|
|
90
|
+
|
|
91
|
+
print(f"Tokens: {input_tokens} in, {output_tokens} out")
|
|
92
|
+
print(f"Cost: ${total_cost:.6f} (${model.cost.input}/M in, ${model.cost.output}/M out)")
|
|
72
93
|
|
|
73
94
|
|
|
74
95
|
def get_version() -> str:
|
|
@@ -78,7 +99,7 @@ def get_version() -> str:
|
|
|
78
99
|
|
|
79
100
|
|
|
80
101
|
def bump_version() -> str:
|
|
81
|
-
"""Bump patch version and
|
|
102
|
+
"""Bump patch version in pyproject.toml and package.json. Returns new version."""
|
|
82
103
|
content = PYPROJECT_PATH.read_text()
|
|
83
104
|
old = get_version()
|
|
84
105
|
parts = old.split(".")
|
|
@@ -86,6 +107,12 @@ def bump_version() -> str:
|
|
|
86
107
|
new = ".".join(parts)
|
|
87
108
|
content = re.sub(r'^version = ".+"', f'version = "{new}"', content, flags=re.MULTILINE)
|
|
88
109
|
PYPROJECT_PATH.write_text(content)
|
|
110
|
+
|
|
111
|
+
# Update node package.json
|
|
112
|
+
pkg = json.loads(NODE_PACKAGE_PATH.read_text())
|
|
113
|
+
pkg["version"] = new
|
|
114
|
+
NODE_PACKAGE_PATH.write_text(json.dumps(pkg, indent=2) + "\n")
|
|
115
|
+
|
|
89
116
|
return new
|
|
90
117
|
|
|
91
118
|
|
|
@@ -95,10 +122,28 @@ def save_data(data_str: str) -> None:
|
|
|
95
122
|
f.write(json.dumps(json.loads(data_str), separators=(",", ":")))
|
|
96
123
|
|
|
97
124
|
|
|
125
|
+
def get_action_url() -> str | None:
|
|
126
|
+
"""Get GitHub Action run URL from environment."""
|
|
127
|
+
server = os.environ.get("GITHUB_SERVER_URL")
|
|
128
|
+
repo = os.environ.get("GITHUB_REPOSITORY")
|
|
129
|
+
run_id = os.environ.get("GITHUB_RUN_ID")
|
|
130
|
+
if server and repo and run_id:
|
|
131
|
+
return f"{server}/{repo}/actions/runs/{run_id}"
|
|
132
|
+
return None
|
|
133
|
+
|
|
134
|
+
|
|
98
135
|
def commit(message: str) -> None:
|
|
99
136
|
"""Commit changes."""
|
|
137
|
+
action_url = get_action_url()
|
|
138
|
+
if action_url:
|
|
139
|
+
message = f"{message}\n\nAction: {action_url}"
|
|
140
|
+
|
|
100
141
|
repo = git.Repo(ROOT)
|
|
101
|
-
repo.index.add([
|
|
142
|
+
repo.index.add([
|
|
143
|
+
"python/pyproject.toml",
|
|
144
|
+
"python/src/models_dev/data.json.gz",
|
|
145
|
+
"node/package.json",
|
|
146
|
+
])
|
|
102
147
|
repo.index.commit(message)
|
|
103
148
|
|
|
104
149
|
|
|
@@ -122,8 +167,9 @@ def main() -> int:
|
|
|
122
167
|
print(diff[:500])
|
|
123
168
|
|
|
124
169
|
print("Generating commit message...")
|
|
125
|
-
message = generate_commit_message(diff)
|
|
170
|
+
message, input_tokens, output_tokens = generate_commit_message(diff)
|
|
126
171
|
print(f"Message: {message}")
|
|
172
|
+
print_token_stats(input_tokens, output_tokens)
|
|
127
173
|
|
|
128
174
|
if args.dry_run:
|
|
129
175
|
print("Dry run, stopping")
|
|
Binary file
|
models_dev-1.0.54/.gitignore
DELETED
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|