Skip to content

Add models import command #10581

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
May 15, 2025

Conversation

msabramo
Copy link
Contributor

@msabramo msabramo commented May 6, 2025

Add a models import command that can import models from a LiteLLM proxy YAML config file.

This doesn't handle shared LLM credentials yet, which I'd like to eventually support.

Examples of usage

Screenshot 2025-05-07 at 8 30 53 AM

Screenshot 2025-05-07 at 8 27 36 AM

$ litellm-proxy models import \
  --only-access-groups-matching-regex='default-models' \
  --dry-run \
  ~/work/dmg/litellm_proxy_config.yaml
                                       Models that would be imported if --dry-run was not provided
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┓
┃ Model Name                                ┃ Upstream Model                                                           ┃ Access Groups  ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━┩
│ gemini-2.5-flash-preview-04-17            │ vertex_ai/gemini-2.5-flash-preview-04-17                                 │ default-models │
│ gpt-4o-2024-05-13-managed                 │ azure/gpt-4o-2024-05-13-prod-filter                                      │ default-models │
│ gpt-4o-2024-05-13-no-filter               │ azure/gpt-4o-2024-05-13-no-filter                                        │ default-models │
...
└───────────────────────────────────────────┴──────────────────────────────────────────────────────────────────────────┴────────────────┘
Model Import Summary
┏━━━━━━━━━━━┳━━━━━━━┓
┃ Provider  ┃ Count ┃
┡━━━━━━━━━━━╇━━━━━━━┩
│ vertex_ai │ 11    │
│ azure     │ 14    │
│ bedrock   │ 26    │
│ azure_ai  │ 5     │
│ gemini    │ 1     │
│ sagemaker │ 2     │
│ Total     │ 59    │
└───────────┴───────┘

Relevant issues

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • I have added a screenshot of my new test passing locally
    Screenshot 2025-05-06 at 9 09 27 PM
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

Type

🆕 New Feature

Changes

Copy link

vercel bot commented May 6, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
litellm ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 9, 2025 8:04pm

@msabramo
Copy link
Contributor Author

msabramo commented May 9, 2025

Hmmm did unit tests not run? Because I just noticed they're failing for me locally 😄

@msabramo
Copy link
Contributor Author

msabramo commented May 9, 2025

Hmmm did unit tests not run? Because I just noticed they're failing for me locally 😄

Oh maybe because main is not the target branch?

@msabramo msabramo changed the base branch from litellm_proxy_cli_staging to main May 9, 2025 14:58
@msabramo msabramo changed the base branch from main to litellm_proxy_cli_staging May 9, 2025 14:58
@msabramo msabramo force-pushed the proxy-client-cli-models-import branch from 3e74b82 to 6a0ee95 Compare May 9, 2025 15:09
@CLAassistant
Copy link

CLAassistant commented May 9, 2025

CLA assistant check
All committers have signed the CLA.

@msabramo msabramo changed the base branch from litellm_proxy_cli_staging to main May 9, 2025 15:09
@msabramo
Copy link
Contributor Author

msabramo commented May 9, 2025

Hmmm did unit tests not run? Because I just noticed they're failing for me locally 😄

Oh maybe because main is not the target branch?

OK I merged from main into my branch (and fixed conflicts) and then changed the target branch to main, but I also fixed the test failure, so the unit tests should hopefully run and pass...

@msabramo
Copy link
Contributor Author

msabramo commented May 9, 2025

Hmmm, something seems stuck?

Screenshot 2025-05-09 at 9 59 46 AM

@msabramo
Copy link
Contributor Author

msabramo commented May 9, 2025

Just pushed an empty commit to see if the CI reruns and is happier...

msabramo added 4 commits May 9, 2025 11:03
to `models import` which only processes models where
`litelllm_params.model` matches the regex
to `models import` which only processes models where at least one item
in `model_info.access_groups` matches the regex. Add a unit test.
@msabramo msabramo force-pushed the proxy-client-cli-models-import branch from 604dba0 to 2c85fef Compare May 9, 2025 18:03
@msabramo
Copy link
Contributor Author

msabramo commented May 9, 2025

Did some refactoring and rebased and removed the empty commit

for better understandability and Intellisense
@msabramo
Copy link
Contributor Author

msabramo commented May 9, 2025

Cc: @ishaan-jaff

@@ -109,6 +109,52 @@ Options:
- `--param`, `-p`: Model parameters in key=value format (can be specified multiple times)
- `--info`, `-i`: Model info in key=value format (can be specified multiple times)

#### Import Models

Import models from a YAML file:
Copy link
Contributor

Choose a reason for hiding this comment

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

Hey when would you want to import from a yaml?

I don't understand what the user is trying to achieve with this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The use case is one I think I mentioned to you. We have a bunch of models in the YAML config for our self-hosted instance and this would help us bring them over to the cloud instance. The filtering options let us do it gradually.

Copy link
Contributor

@krrishdholakia krrishdholakia May 10, 2025

Choose a reason for hiding this comment

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

Hey @msabramo where does this porting from yaml to db happen in the code? from what i can see it gets appended to a model list, but i didn't see a /model/new call in this PR

Copy link
Contributor Author

@msabramo msabramo May 11, 2025

Choose a reason for hiding this comment

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

client.models.new call

client.models.new(
model_name=model_info_obj.model_name,
model_params=model_info_obj.model_params,
model_info=model_info_obj.model_info,
)

@krrishdholakia krrishdholakia merged commit 322b678 into BerriAI:main May 15, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants