mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-06 08:16:43 +00:00
fix(proxy): preserve legacy fine-tune ids in /v1/models filtering
This commit is contained in:
parent
2f84870362
commit
4e953d3e78
2 changed files with 39 additions and 2 deletions
|
|
@ -4,7 +4,6 @@ from typing import Dict, List, Optional, Set
|
|||
|
||||
import litellm
|
||||
from litellm._logging import verbose_proxy_logger
|
||||
from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider
|
||||
from litellm.proxy._types import SpecialModelNames, UserAPIKeyAuth
|
||||
from litellm.router import Router
|
||||
from litellm.router_utils.fallback_event_handlers import get_fallback_model_group
|
||||
|
|
@ -74,8 +73,18 @@ def _is_resolvable_dynamic_model(model: str) -> bool:
|
|||
- provider-qualified routes such as `bedrock/us.amazon.nova-micro-v1:0`
|
||||
or JSON-registry providers such as `publicai/some-new-model`
|
||||
- dynamic model identifiers such as OpenAI fine-tunes
|
||||
(`ft:gpt-4o:my-org:custom:id`)
|
||||
(`ft:gpt-4o:my-org:custom:id`, `ft:davinci-002:org:suffix:id`)
|
||||
"""
|
||||
# OpenAI fine-tuned model ids are valid dynamic models, including legacy
|
||||
# bases such as `ft:davinci-002:...` and `ft:babbage-002:...`.
|
||||
# Keep them without calling get_llm_provider(), which currently does not
|
||||
# recognize every historical fine-tune base and prints provider-help text
|
||||
# on failure.
|
||||
if model.startswith("ft:"):
|
||||
return True
|
||||
|
||||
from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider
|
||||
|
||||
try:
|
||||
get_llm_provider(model=model)
|
||||
return True
|
||||
|
|
|
|||
|
|
@ -347,3 +347,31 @@ def test_get_complete_model_list_keeps_openai_finetune_model_ids():
|
|||
)
|
||||
|
||||
assert result == [finetuned_model]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"finetuned_model",
|
||||
[
|
||||
"ft:davinci-002:my-org:custom-suffix:model-id",
|
||||
"ft:babbage-002:my-org:custom-suffix:model-id",
|
||||
],
|
||||
)
|
||||
def test_get_complete_model_list_keeps_legacy_openai_finetune_model_ids(
|
||||
finetuned_model: str,
|
||||
):
|
||||
"""
|
||||
Legacy OpenAI fine-tuned model IDs should also remain visible even though
|
||||
get_llm_provider() does not recognize all historical fine-tune base names.
|
||||
"""
|
||||
from litellm.proxy.auth.model_checks import get_complete_model_list
|
||||
|
||||
result = get_complete_model_list(
|
||||
key_models=[finetuned_model],
|
||||
team_models=[],
|
||||
proxy_model_list=[],
|
||||
user_model=None,
|
||||
infer_model_from_keys=False,
|
||||
model_access_groups={},
|
||||
)
|
||||
|
||||
assert result == [finetuned_model]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue