Skip to content

feat: implement dynamic model detection support for inference providers using litellm#2886

Merged
ashwinb merged 1 commit intollamastack:mainfrom
mattf:add-check-model-avail-for-litellm
Jul 28, 2025
Merged

feat: implement dynamic model detection support for inference providers using litellm#2886
ashwinb merged 1 commit intollamastack:mainfrom
mattf:add-check-model-avail-for-litellm

Conversation

@mattf
Copy link
Collaborator

@mattf mattf commented Jul 24, 2025

What does this PR do?

This enhancement allows inference providers using LiteLLMOpenAIMixin to validate model availability against LiteLLM's official provider model listings, improving reliability and user experience when working with different AI service providers.

  • Add litellm_provider_name parameter to LiteLLMOpenAIMixin constructor
  • Add check_model_availability method to LiteLLMOpenAIMixin using litellm.models_by_provider
  • Update Gemini, Groq, and SambaNova inference adapters to pass litellm_provider_name

Test Plan

standard CI.

api_key_from_config: str | None,
provider_data_api_key_field: str,
openai_compat_api_base: str | None = None,
litellm_provider_name: str | None = None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we make this required?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can. if i make it required right now it'll step on other related changes in flight by new developers.

ok to file a follow up issue to make it required?

Copy link
Contributor

@ashwinb ashwinb Jul 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that is fine because in my opinion check_model_availability cannot be half-assed and say "I can't do my job because you did not provide me with very important information earlier". I also do need this in my own work. Let's make this required.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ashwinb ok, i've made it required.

@r3v5 this will superseded your PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @mattf

@r3v5
Copy link
Contributor

r3v5 commented Jul 25, 2025

This new infrastructure with litellm for check_model_availability() is fine. If the PR is merged, I can do rebase and very quickly implement that for Anthropic here #2879 and afterwards for all models from list here #2504

@mattf
Copy link
Collaborator Author

mattf commented Jul 26, 2025

image this is weird.

@mattf mattf force-pushed the add-check-model-avail-for-litellm branch 2 times, most recently from b83c24a to 3272221 Compare July 26, 2025 10:54
@mattf mattf requested a review from ashwinb July 26, 2025 11:01
…rs using litellm

This enhancement allows inference providers using LiteLLMOpenAIMixin to validate
model availability against LiteLLM's official provider model listings, improving
reliability and user experience when working with different AI service providers.

- Add litellm_provider_name parameter to LiteLLMOpenAIMixin constructor
- Add check_model_availability method to LiteLLMOpenAIMixin using litellm.models_by_provider
- Update Anthropic, OpenAI, Llama, Gemini, Groq, and SambaNova inference adapters to pass litellm_provider_name
@mattf mattf force-pushed the add-check-model-avail-for-litellm branch from 3272221 to 923c08c Compare July 28, 2025 14:05
Copy link
Contributor

@ashwinb ashwinb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@ashwinb ashwinb merged commit 47c078f into llamastack:main Jul 28, 2025
77 checks passed
eranco74 added a commit to eranco74/assisted-chat that referenced this pull request Jul 30, 2025
 - Specify the default model and provider in the LSC config

This is required because following
llamastack/llama-stack#2886 llama-stack discover
the models dynamically, if we don't pass a provider and model it falls
back to the firt model it finds (regadless of what we have in the
llama-stack config.yaml)
Note that it's also listing vertexAI models (which work with the
vertexAI API)!

Signed-off-by: Eran Cohen <eranco@redhat.com>
eranco74 added a commit to eranco74/assisted-chat that referenced this pull request Jul 30, 2025
Specify the default model and provider in the LSC config

This is required because following
llamastack/llama-stack#2886 llama-stack discovers the models dynamically, if we don't pass a provider and model, it falls back to the first model it finds (regardless of what we have in the llama-stack config.yaml)

Note that it's also listing vertexAI models (which work with the vertexAI API)!

Signed-off-by: Eran Cohen <eranco@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants