mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-17 09:34:48 +00:00
fix(proxy): label provider-prefixed public models by their shipped name
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
489f3e9a50
commit
c33fdec70a
2 changed files with 10 additions and 5 deletions
|
|
@ -221,11 +221,10 @@ _PUBLIC_MODELS: Final[frozenset[str]] = frozenset(GetModelCostMap.load_local_mod
|
|||
def _public_model_label(model: str, provider: str | None) -> str:
|
||||
"""Only names shipped in the packaged pricing map are exported; anything
|
||||
else, including names operators registered for billing, becomes "other"."""
|
||||
if model in _PUBLIC_MODELS:
|
||||
return model
|
||||
if provider is not None and f"{provider}/{model}" in _PUBLIC_MODELS:
|
||||
return f"{provider}/{model}"
|
||||
return "other"
|
||||
candidates: Final = (
|
||||
(model, f"{provider}/{model}", model.removeprefix(f"{provider}/")) if provider is not None else (model,)
|
||||
)
|
||||
return next((candidate for candidate in candidates if candidate in _PUBLIC_MODELS), "other")
|
||||
|
||||
|
||||
class _ConfigParamWhere(TypedDict):
|
||||
|
|
|
|||
|
|
@ -194,6 +194,12 @@ def test_shipped_provider_prefixed_model_labels_as_itself() -> None:
|
|||
assert ut._public_model_label(model, provider) == shipped
|
||||
|
||||
|
||||
def test_provider_prefixed_bare_shipped_model_labels_as_bare_name() -> None:
|
||||
bare: Final = min(key for key in ut._PUBLIC_MODELS if "/" not in key and f"openai/{key}" not in ut._PUBLIC_MODELS)
|
||||
assert ut._public_model_label(f"openai/{bare}", "openai") == bare
|
||||
assert ut._public_model_label(f"openai/{bare}", None) == "other"
|
||||
|
||||
|
||||
async def test_success_event_with_missing_payload_records_nothing() -> None:
|
||||
recorder, reader = _recorder_with_reader()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue