Skip to content

Commit

Permalink
Fix None values from config file where array is expected (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
petermuller authored Jun 7, 2024
1 parent 71446ff commit d8e28f5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 6 additions & 1 deletion lib/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
4 changes: 3 additions & 1 deletion lib/serve/rest-api/src/utils/generate_litellm_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d8e28f5

Please sign in to comment.