feat(token-tracking): capture token usage in /api/score/async job runs
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -1190,7 +1190,7 @@ def test_run_writes_token_usage_to_metadata(tmp_path, monkeypatch):
|
||||
return {m: 0.9 for m in kwargs["metrics"]}
|
||||
|
||||
monkeypatch.setattr(
|
||||
"webapp.services.score_job_manager.inline_scorer.score", _fake_score
|
||||
"webapp.services.inline_scorer.inline_scorer.score", _fake_score
|
||||
)
|
||||
|
||||
request = ScoreRequest(question="q?", answer="a.", metrics=["answer_relevancy"])
|
||||
@@ -1216,7 +1216,7 @@ def test_run_writes_empty_token_usage_when_nothing_recorded(tmp_path, monkeypatc
|
||||
return {m: 0.9 for m in kwargs["metrics"]}
|
||||
|
||||
monkeypatch.setattr(
|
||||
"webapp.services.score_job_manager.inline_scorer.score", _fake_score
|
||||
"webapp.services.inline_scorer.inline_scorer.score", _fake_score
|
||||
)
|
||||
|
||||
request = ScoreRequest(question="q?", answer="a.", metrics=["answer_relevancy"])
|
||||
@@ -1399,7 +1399,7 @@ def test_session_accumulates_token_usage_across_calls(tmp_path, monkeypatch):
|
||||
return {m: 0.9 for m in kwargs["metrics"]}
|
||||
|
||||
monkeypatch.setattr(
|
||||
"webapp.services.session_score_manager.inline_scorer.score", _fake_score
|
||||
"webapp.services.inline_scorer.inline_scorer.score", _fake_score
|
||||
)
|
||||
|
||||
request = ScoreRequest(question="q?", answer="a.", metrics=["answer_relevancy"])
|
||||
@@ -1432,7 +1432,7 @@ def test_session_first_call_writes_token_usage_from_scratch(tmp_path, monkeypatc
|
||||
return {m: 0.9 for m in kwargs["metrics"]}
|
||||
|
||||
monkeypatch.setattr(
|
||||
"webapp.services.session_score_manager.inline_scorer.score", _fake_score
|
||||
"webapp.services.inline_scorer.inline_scorer.score", _fake_score
|
||||
)
|
||||
|
||||
request = ScoreRequest(question="q?", answer="a.", metrics=["answer_relevancy"])
|
||||
|
||||
Reference in New Issue
Block a user