BerriAI / litellm

Python SDK, Proxy Server (LLM Gateway) to call 100+ LLM APIs in OpenAI format - [Bedrock, Azure, OpenAI, VertexAI, Cohere, Anthropic, Sagemaker, HuggingFace, Replicate, Groq]
https://docs.litellm.ai/docs/
Other
12.56k stars 1.46k forks source link

[Feature]: All `model_group_alias` should show up in `/models`,`/model/info`,`/model_group/info` #5524

Closed taralika closed 3 weeks ago

taralika commented 3 weeks ago

The Feature

When the proxy-config.yaml has:

router_settings:
  model_group_alias: {"alias-1": "model-group-1"}
model_list:
  - model_name: model-group-1
    litellm_params:
      model: azure/gpt-1
      api_base: https://xyz1.openai.azure.com/
      api_key: os.environ/AOAI_KEY
  - model_name: model-group-1
    litellm_params:
      model: azure/gpt-2
      api_base: https://xyz2.openai.azure.com/
      api_key: os.environ/AOAI_KEY

Response for GET /models should look like this:

{
      "id": "model-group-1",
      "object": "model",
      "created": 1677610602,
      "owned_by": "openai"
},
{
      "id": "alias-1",
      "object": "model",
      "created": 1677610602,
      "owned_by": "openai"
}

Response for GET /model/info should look like this:

{
      "model_name": "model-group-1",
      "litellm_params": {
        "api_base": "https://xyz1.openai.azure.com/",
        "model": "azure/gpt-1"
      },
      "model_info": {
        "id": "8eefdf61e375ace21356414a23782159e703c6afe66eb7b46a3a17a2095f53b1",
        "db_model": false,
        "key": "azure/gpt-1",
        ...
      }
},
{
      "model_name": "model-group-1",
      "litellm_params": {
        "api_base": "https://xyz2.openai.azure.com/",
        "model": "azure/gpt-2"
      },
      "model_info": {
        "id": "8eefdf61e375ace21356414a23782159e703c6afe66eb7b46a3a17a2095f53b1",
        "db_model": false,
        "key": "azure/gpt-2",
        ...
      }
},
{
      "model_name": "alias-1",
      "litellm_params": {
        "api_base": "https://xyz1.openai.azure.com/",
        "model": "azure/gpt-1"
      },
      "model_info": {
        "id": "8eefdf61e375ace21356414a23782159e703c6afe66eb7b46a3a17a2095f53b1",
        "db_model": false,
        "key": "azure/gpt-1",
        ...
      }
},
{
      "model_name": "alias-1",
      "litellm_params": {
        "api_base": "https://xyz2.openai.azure.com/",
        "model": "azure/gpt-2"
      },
      "model_info": {
        "id": "8eefdf61e375ace21356414a23782159e703c6afe66eb7b46a3a17a2095f53b1",
        "db_model": false,
        "key": "azure/gpt-2",
        ...
      }
}

Response for GET /model_group/info should look like:

{
  "model_group": "model-group-1",
      "providers": [
        "azure"
      ],
      ...
},
{
  "model_group": "alias-1",
      "providers": [
        "azure"
      ],
      ...
}

Motivation, pitch

Users of litellm proxy have no idea what aliases are available, they can only see the model group names. Please expose the aliases at same level as model group names so users of the litellm proxy can take advantage of the aliases as well.

Twitter / LinkedIn details

No response

krrishdholakia commented 3 weeks ago

Hey @taralika curious - why do you use model_group_alias?

Context - trying to understand our users better

taralika commented 3 weeks ago

why do you use model_group_alias?

for various reasons:

  1. to align model names between usage from within litellm proxy and outside of proxy (directly to provider)
  2. to provide open-ai style model names that always point to current model version (and litellm proxy admin controls/updates this to point to new version when it comes out)
krrishdholakia commented 3 weeks ago

This is now live on v1.44.21

taralika commented 3 weeks ago

@krrishdholakia after upgrading to v1.44.21 our health checks have started failing. The issue I think is you're treating "model-group-1" itself as a model and including "model-group-1"in list of models with empty model_info and also performing health check on "model-group-1". Instead, you should look up all models underneath "model-group-1" and add them as models under model group "alias-1" and just perform health check once on these models.

You may want to revert this first and hotfix 1.44.21 as others who have aliases will also start seeing health checks fail.

krrishdholakia commented 3 weeks ago

@taralika when you say health checks do you mean calling /health?

taralika commented 3 weeks ago

@taralika when you say health checks do you mean calling /health?

yes

krrishdholakia commented 3 weeks ago

Got it - i'll push a fix + add a test for this to our ci/cd flow @taralika

taralika commented 2 weeks ago

hi @krrishdholakia is this fixed now? I tried v1.44.24 and I can see the "alias-1" in GET /models call, and I also see this alias doesn't show up in GET /health call - so that's great. But what's still missing is that GET /model/info has no mention of "alias-1" - as mentioned in description of this ticket, we'll need this so clients know what models are under this alias.