From 710958865298011346a1c7f8ddfa977d183172fe Mon Sep 17 00:00:00 2001 From: Hongbo <12580159+ya0guang@users.noreply.github.com> Date: Mon, 26 Feb 2024 22:21:02 -0500 Subject: [PATCH 1/2] fix bug: check before using the variables --- .../jupyter-ai/jupyter_ai/completions/handlers/llm_mixin.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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..9ce9fba85 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}." From dbdf87677641f64642a29c0379a952af12e2316d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 27 Feb 2024 03:21:22 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../jupyter-ai/jupyter_ai/completions/handlers/llm_mixin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 9ce9fba85..1371e3cbf 100644 --- a/packages/jupyter-ai/jupyter_ai/completions/handlers/llm_mixin.py +++ b/packages/jupyter-ai/jupyter_ai/completions/handlers/llm_mixin.py @@ -32,7 +32,7 @@ def get_llm_chain(self): 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 )