Prioritize active_model over model_name for pricing lookup
- Swapped parameter order in effective_rates() to pass alias (active_model) as model_name - This ensures the actual running model is displayed in hook output - Updated docstring to clarify the new priority order - All 30 tests still pass Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
@@ -273,8 +273,8 @@ allowlist = ["agent-cost-estimator"]
|
||||
|
||||
def effective_rates(args, pricing, meta):
|
||||
"""Return (rates, key, currency, is_default) after table lookup and CLI overrides."""
|
||||
result = get_model_prices(pricing, args.model or meta.model_name,
|
||||
meta.alias)
|
||||
result = get_model_prices(pricing, args.model or meta.alias,
|
||||
meta.model_name)
|
||||
# Handle different return value counts for backward compatibility
|
||||
if len(result) == 4:
|
||||
rates, key, currency, is_default = result
|
||||
|
||||
@@ -194,12 +194,15 @@ def _lookup_in_providers(data: dict, provider: str | None, model_name: str, alia
|
||||
def get_model_prices(pricing, model_name=None, alias=None, provider=None):
|
||||
"""Return (rates dict, matched key, currency, is_default) for the model.
|
||||
|
||||
Lookup order:
|
||||
Lookup order (prioritizes the actual running model):
|
||||
1. If provider specified: provider.model_name, provider.alias, provider.default
|
||||
2. If provider not specified:
|
||||
a. Search all providers for model_name or alias
|
||||
a. Search all providers for model_name (passed as active_model) or alias (passed as model_name)
|
||||
b. Fall back to first provider's default model
|
||||
|
||||
Note: Callers should pass the actual model as model_name and the internal
|
||||
alias as the alias parameter to prioritize the real running model.
|
||||
|
||||
Raises ValueError when nothing matches and there is no
|
||||
"default".
|
||||
|
||||
|
||||
Reference in New Issue
Block a user