관리자 사용량 근거를 정교화
This commit is contained in:
parent
ccdcfcd2f5
commit
707dba4f8f
10 changed files with 1136 additions and 209 deletions
|
|
@ -78,6 +78,81 @@ class UsageReportTest(unittest.TestCase):
|
|||
self.assertIsNone(report["top_cost_model"])
|
||||
self.assertEqual(report["summary"]["metered_coverage"], 0.0)
|
||||
|
||||
def test_model_cost_report_warns_when_only_part_of_a_model_is_priced(self) -> None:
|
||||
report = build_model_cost_report(
|
||||
{
|
||||
"cost_usd": 4.5,
|
||||
"cost_basis": "partial",
|
||||
"by_provider": [
|
||||
{
|
||||
"provider": "agy_cli",
|
||||
"model": "gemini-3.7-flash-high",
|
||||
"turns": 2,
|
||||
"tokens_in": 2_000_000,
|
||||
"tokens_out": 2_000_000,
|
||||
"cost_usd": 4.5,
|
||||
"cost_basis": "partial",
|
||||
}
|
||||
],
|
||||
}
|
||||
)
|
||||
|
||||
self.assertIn("partial_model_cost", report["warnings"])
|
||||
self.assertIn("unavailable_model_cost", report["warnings"])
|
||||
self.assertIsNone(report["summary"]["cost_per_turn_usd"])
|
||||
self.assertIsNone(report["models"][0]["cost_share"])
|
||||
|
||||
def test_model_cost_report_warns_for_reference_upper_bound(self) -> None:
|
||||
report = build_model_cost_report(
|
||||
{
|
||||
"cost_usd": 0.1,
|
||||
"by_provider": [
|
||||
{
|
||||
"provider": "agy_cli",
|
||||
"model": "gemini-3.7-flash-high",
|
||||
"turns": 1,
|
||||
"tokens_in": 100_000,
|
||||
"tokens_out": 1_000,
|
||||
"cost_usd": 0.1,
|
||||
"cost_basis": "reference_upper_bound",
|
||||
}
|
||||
],
|
||||
}
|
||||
)
|
||||
|
||||
self.assertIn("reference_upper_bound_cost", report["warnings"])
|
||||
|
||||
def test_model_cost_report_preserves_partial_upper_bound_uncertainty(self) -> None:
|
||||
report = build_model_cost_report(
|
||||
{
|
||||
"cost_usd": 4.5,
|
||||
"cost_basis": "partial_upper_bound",
|
||||
"budget": {
|
||||
"status": "indeterminate",
|
||||
"remaining_usd": None,
|
||||
"cost_basis": "partial_upper_bound",
|
||||
},
|
||||
"by_provider": [
|
||||
{
|
||||
"provider": "agy_cli",
|
||||
"model": "gemini-3.7-flash-high",
|
||||
"turns": 2,
|
||||
"tokens_in": 2_000_000,
|
||||
"tokens_out": 2_000_000,
|
||||
"cost_usd": 4.5,
|
||||
"cost_basis": "partial_upper_bound",
|
||||
}
|
||||
],
|
||||
}
|
||||
)
|
||||
|
||||
self.assertEqual(report["summary"]["cost_basis"], "partial_upper_bound")
|
||||
self.assertIsNone(report["summary"]["cost_per_turn_usd"])
|
||||
self.assertIsNone(report["budget"]["remaining_usd"])
|
||||
self.assertIn("partial_upper_bound_model_cost", report["warnings"])
|
||||
self.assertIn("unavailable_model_cost", report["warnings"])
|
||||
self.assertIn("budget_indeterminate", report["warnings"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue