45 lines
1.3 KiB
Python
45 lines
1.3 KiB
Python
from decimal import Decimal
|
|
|
|
from agent.models_dev import ModelInfo
|
|
from agent.usage_pricing import PricingEntry
|
|
from hermes_cli.model_cost_guard import expensive_model_warning
|
|
|
|
|
|
def test_no_warning_when_known_prices_are_at_threshold():
|
|
info = ModelInfo(
|
|
id="edge/model",
|
|
name="edge/model",
|
|
family="",
|
|
provider_id="test",
|
|
cost_input=20.0,
|
|
cost_output=100.0,
|
|
)
|
|
|
|
assert expensive_model_warning("edge/model", provider="test", model_info=info) is None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_openai_gpt55_pro_warns_for_nous_portal_pricing(monkeypatch):
|
|
monkeypatch.setattr("agent.models_dev.get_model_info", lambda *_args, **_kwargs: None)
|
|
monkeypatch.setattr(
|
|
"agent.usage_pricing.fetch_endpoint_model_metadata",
|
|
lambda base_url, api_key="": {
|
|
"openai/gpt-5.5-pro": {
|
|
"pricing": {
|
|
"prompt": "0.000025",
|
|
"completion": "0.000125",
|
|
}
|
|
}
|
|
},
|
|
)
|
|
|
|
warning = expensive_model_warning("openai/gpt-5.5-pro", provider="nous")
|
|
|
|
assert warning is not None
|
|
assert warning.input_cost_per_million == Decimal("25.000000")
|
|
assert warning.output_cost_per_million == Decimal("125.000000")
|
|
assert "did you mean to select openai/gpt-5.5?" in warning.message
|