Skip to content
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

Fix None values from config file where array is expected #24

Merged
merged 1 commit into from
Jun 7, 2024

Conversation

petermuller
Copy link
Contributor

I received a report that one of my recent changes was causing an error when deploying the REST API container without a LiteLLM models list defined, which is the default for new config files. Because it was left as a null value and not an array, the Python file for generating the rest of the LiteLLM config received a None instead of an empty list. This fix includes two fixes for the same issue:

  1. On the typescript side, the schema was updated so that it forces an array if the array is not defined. The "default" function only applies if the field is undefined, not if it's null: the case we're solving for.
  2. On the python side, we now check if the model list is truthy before trying to extend it, which catches the None case. If it is None (or any falsy value), it'll return an empty list, which can then be extended properly.

Tested by deploying to my account with these changes and with the models_list defined, but not populated, as in, my config is:

  litellmConfig:
    litellm_settings:
      telemetry: false  # Don't try to send telemetry to LiteLLM servers.
      drop_params: true  # don't fail if params not recognized
    model_list: # evaluates to `null` because field is defined but has no value. I want this to become []

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@petermuller petermuller requested a review from estohlmann June 7, 2024 17:56
@petermuller petermuller self-assigned this Jun 7, 2024
@petermuller petermuller merged commit d8e28f5 into main Jun 7, 2024
2 checks passed
@petermuller petermuller deleted the bugfix/litellm-models branch June 7, 2024 18:27
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.

2 participants