From cee178b86f3d4bc1cef288be5f67267725a50592 Mon Sep 17 00:00:00 2001 From: Piyush Jain Date: Wed, 26 Jun 2024 15:11:53 -0700 Subject: [PATCH] Fixes error when allowed or blocked model list is passed in config (#855) * Fixes error when allowed or blocked model list is passed in config. * Simplified null check. --- packages/jupyter-ai/jupyter_ai/handlers.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/jupyter-ai/jupyter_ai/handlers.py b/packages/jupyter-ai/jupyter_ai/handlers.py index 339863c3f..a2ef152cb 100644 --- a/packages/jupyter-ai/jupyter_ai/handlers.py +++ b/packages/jupyter-ai/jupyter_ai/handlers.py @@ -291,10 +291,12 @@ def filter_predicate(local_model_id: str): # filter out every model w/ model ID according to allow/blocklist for provider in providers: - provider.models = list(filter(filter_predicate, provider.models)) - provider.chat_models = list(filter(filter_predicate, provider.chat_models)) + provider.models = list(filter(filter_predicate, provider.models or [])) + provider.chat_models = list( + filter(filter_predicate, provider.chat_models or []) + ) provider.completion_models = list( - filter(filter_predicate, provider.completion_models) + filter(filter_predicate, provider.completion_models or []) ) # filter out every provider with no models which satisfy the allow/blocklist, then return