update first - 84
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Return '<total_tokens> <cost_usd>' for the provider-telemetry record that
|
||||
matches the given step, or print nothing if there is no genuine match.
|
||||
|
||||
Never falls back to an arbitrary record — reusing one sample's cost across
|
||||
every step would misrepresent an estimate as real per-step billing.
|
||||
|
||||
Usage: provider-cost-lookup.py <provider-usage.jsonl> <step-name>
|
||||
"""
|
||||
import json
|
||||
import sys
|
||||
|
||||
if len(sys.argv) < 3:
|
||||
sys.exit(0)
|
||||
path, step = sys.argv[1], sys.argv[2]
|
||||
match = None
|
||||
try:
|
||||
with open(path, encoding="utf-8") as fh:
|
||||
for line in fh:
|
||||
line = line.strip()
|
||||
if not line:
|
||||
continue
|
||||
rec = json.loads(line)
|
||||
if rec.get("step") == step:
|
||||
match = rec # last matching record wins
|
||||
except OSError:
|
||||
sys.exit(0)
|
||||
if match is not None:
|
||||
print(f"{match.get('total_tokens', 0)} {match.get('cost_usd', 0)}")
|
||||
Reference in New Issue
Block a user