diff --git a/packages/jupyter-ai/jupyter_ai/completions/handlers/llm_mixin.py b/packages/jupyter-ai/jupyter_ai/completions/handlers/llm_mixin.py index da8765b39..1371e3cbf 100644 --- a/packages/jupyter-ai/jupyter_ai/completions/handlers/llm_mixin.py +++ b/packages/jupyter-ai/jupyter_ai/completions/handlers/llm_mixin.py @@ -30,6 +30,9 @@ def get_llm_chain(self): lm_provider = self.config_manager.lm_provider lm_provider_params = self.config_manager.lm_provider_params + if not lm_provider or not lm_provider_params: + return None + curr_lm_id = ( f'{self.llm.id}:{lm_provider_params["model_id"]}' if self.llm else None ) @@ -39,9 +42,6 @@ def get_llm_chain(self): else None ) - if not lm_provider or not lm_provider_params: - return None - if curr_lm_id != next_lm_id: self.log.info( f"Switching {self.handler_kind} language model from {curr_lm_id} to {next_lm_id}."