diff --git a/lib/schema.ts b/lib/schema.ts index 7078e718..759ccef1 100644 --- a/lib/schema.ts +++ b/lib/schema.ts @@ -727,7 +727,12 @@ const LiteLLMModel = z.object({ */ const LiteLLMConfig = z.object({ environment_variables: z.map(z.string(), z.string()).optional(), - model_list: z.array(LiteLLMModel).optional().nullable().default([]), + model_list: z + .array(LiteLLMModel) + .optional() + .nullable() + .default([]) + .transform((value) => value ?? []), litellm_settings: z.object({ // ALL (https://github.com/BerriAI/litellm/blob/main/litellm/__init__.py) telemetry: z.boolean().default(false).optional(), diff --git a/lib/serve/rest-api/src/utils/generate_litellm_config.py b/lib/serve/rest-api/src/utils/generate_litellm_config.py index 81a1ba27..57cae97c 100644 --- a/lib/serve/rest-api/src/utils/generate_litellm_config.py +++ b/lib/serve/rest-api/src/utils/generate_litellm_config.py @@ -48,7 +48,9 @@ def generate_config(filepath: str) -> None: } for model in registered_models ] - config_contents["model_list"].extend(litellm_model_params) + config_models = config_contents["model_list"] or [] # ensure config_models is a list and not None + config_models.extend(litellm_model_params) + config_contents["model_list"] = config_models # Write updated config back to original path with open(filepath, "w") as fp: yaml.safe_dump(config_contents, fp)