feat(llm): full multi-tier S/A/B/C/D with routing + pricing
Estende ModelTier a 5 livelli (S/A/B/C/D) con routing automatico: S/A/B via Anthropic SDK, C/D via OpenRouter (OpenAI SDK). Aggiunge prezzi per tier S (Opus), A (Sonnet placeholder) e D (Llama). Refactor LLMClient.complete con dispatch tramite tier_models map e helper _call_anthropic / _call_openrouter. Settings esposte per tutti e 5 i modelli env-configurabili. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -30,3 +30,34 @@ def test_tracker_per_tier_breakdown():
|
||||
summary = t.summary()
|
||||
assert "C" in summary["by_tier"]
|
||||
assert "B" in summary["by_tier"]
|
||||
|
||||
|
||||
def test_estimate_cost_tier_s():
|
||||
cost = estimate_cost(input_tokens=1_000_000, output_tokens=1_000_000, tier=ModelTier.S)
|
||||
assert cost == 15.00 + 75.00
|
||||
|
||||
|
||||
def test_estimate_cost_tier_a():
|
||||
cost = estimate_cost(input_tokens=1_000_000, output_tokens=1_000_000, tier=ModelTier.A)
|
||||
assert cost == 3.00 + 15.00
|
||||
|
||||
|
||||
def test_estimate_cost_tier_d():
|
||||
cost = estimate_cost(input_tokens=1_000_000, output_tokens=1_000_000, tier=ModelTier.D)
|
||||
assert cost == 0.10 + 0.30
|
||||
|
||||
|
||||
def test_tracker_summary_contains_all_five_tiers():
|
||||
t = CostTracker()
|
||||
for tier in (ModelTier.S, ModelTier.A, ModelTier.B, ModelTier.C, ModelTier.D):
|
||||
t.record(
|
||||
input_tokens=1_000,
|
||||
output_tokens=1_000,
|
||||
tier=tier,
|
||||
run_id="r",
|
||||
agent_id=f"a-{tier.value}",
|
||||
)
|
||||
summary = t.summary()
|
||||
for tier_letter in ("S", "A", "B", "C", "D"):
|
||||
assert tier_letter in summary["by_tier"]
|
||||
assert summary["by_tier"][tier_letter]["calls"] == 1
|
||||
|
||||
Reference in New Issue
Block a user