From cfe5e19d8c4f767cf7fa11d94bc3cb32f983e37d Mon Sep 17 00:00:00 2001 From: krassowski <5832902+krassowski@users.noreply.github.com> Date: Sun, 10 Dec 2023 12:16:07 +0000 Subject: [PATCH] Move `BaseLLMHandler` to `/completions` rename to `LLMHandlerMixin` --- packages/jupyter-ai/jupyter_ai/completions/handlers/base.py | 4 ++-- .../{llm_handler.py => completions/handlers/llm_mixin.py} | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) rename packages/jupyter-ai/jupyter_ai/{llm_handler.py => completions/handlers/llm_mixin.py} (91%) diff --git a/packages/jupyter-ai/jupyter_ai/completions/handlers/base.py b/packages/jupyter-ai/jupyter_ai/completions/handlers/base.py index a1cdeb0d1..275bf2bd0 100644 --- a/packages/jupyter-ai/jupyter_ai/completions/handlers/base.py +++ b/packages/jupyter-ai/jupyter_ai/completions/handlers/base.py @@ -3,6 +3,7 @@ # necessary to prevent circular import from typing import TYPE_CHECKING, AsyncIterator, Dict +from jupyter_ai.completions.handlers.llm_mixin import LLMHandlerMixin from jupyter_ai.completions.models import ( CompletionError, InlineCompletionList, @@ -12,13 +13,12 @@ ModelChangedNotification, ) from jupyter_ai.config_manager import ConfigManager, Logger -from jupyter_ai.llm_handler import BaseLLMHandler if TYPE_CHECKING: from jupyter_ai.handlers import InlineCompletionHandler -class BaseInlineCompletionHandler(BaseLLMHandler): +class BaseInlineCompletionHandler(LLMHandlerMixin): """Class implementing completion handling.""" handler_kind = "completion" diff --git a/packages/jupyter-ai/jupyter_ai/llm_handler.py b/packages/jupyter-ai/jupyter_ai/completions/handlers/llm_mixin.py similarity index 91% rename from packages/jupyter-ai/jupyter_ai/llm_handler.py rename to packages/jupyter-ai/jupyter_ai/completions/handlers/llm_mixin.py index bf268e567..a0a3b0505 100644 --- a/packages/jupyter-ai/jupyter_ai/llm_handler.py +++ b/packages/jupyter-ai/jupyter_ai/completions/handlers/llm_mixin.py @@ -4,9 +4,12 @@ from jupyter_ai_magics.providers import BaseProvider -class BaseLLMHandler: +class LLMHandlerMixin: """Base class containing shared methods and attributes used by LLM handler classes.""" + # This could be used to derive `BaseChatHandler` too (there is a lot of duplication!), + # but it was decided against it to avoid introducing conflicts for backports against 1.x + handler_kind: str def __init__(