feat(token-tracking): surface token_usage in ReportData
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -187,6 +187,9 @@ def build_report(run_dir: Path, metrics: list[str]) -> ReportData:
|
||||
summary_markdown = run_reader.read_summary_markdown(run_dir)
|
||||
advice_markdown = run_reader.read_advice_markdown(run_dir)
|
||||
metric_weights, doc_weights = _read_weights_from_snapshot(run_dir)
|
||||
# Read once up front so both the empty-frame and full branches can surface it.
|
||||
metadata = run_reader._read_json(run_dir / "metadata.json")
|
||||
token_usage = metadata.get("token_usage") or {}
|
||||
|
||||
if frame.empty or not metrics:
|
||||
return ReportData(
|
||||
@@ -196,6 +199,7 @@ def build_report(run_dir: Path, metrics: list[str]) -> ReportData:
|
||||
advice_markdown=advice_markdown,
|
||||
metric_weights=metric_weights,
|
||||
doc_weights=doc_weights,
|
||||
token_usage=token_usage,
|
||||
)
|
||||
|
||||
score_rows_list = frame.to_dict(orient="records")
|
||||
@@ -218,7 +222,6 @@ def build_report(run_dir: Path, metrics: list[str]) -> ReportData:
|
||||
|
||||
# Cross-run history: scores of the same question in *other* runs (Approach A —
|
||||
# on-demand global scan, excluding the run currently being viewed).
|
||||
metadata = run_reader._read_json(run_dir / "metadata.json")
|
||||
current_run_id = str(metadata.get("run_id") or run_dir.name)
|
||||
history_index = question_history.build_question_history_index(
|
||||
exclude_run_id=current_run_id
|
||||
@@ -235,4 +238,5 @@ def build_report(run_dir: Path, metrics: list[str]) -> ReportData:
|
||||
weighted_score_mean=_round_or_none(overall_ws),
|
||||
metric_weights=metric_weights,
|
||||
doc_weights=doc_weights,
|
||||
token_usage=token_usage,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user