diff --git a/packages/jupyter-ai/jupyter_ai/chat_handlers/base.py b/packages/jupyter-ai/jupyter_ai/chat_handlers/base.py index 017f342fd..4d4c6807d 100644 --- a/packages/jupyter-ai/jupyter_ai/chat_handlers/base.py +++ b/packages/jupyter-ai/jupyter_ai/chat_handlers/base.py @@ -20,10 +20,10 @@ class BaseChatHandler(Configurable): multiple chat handler classes.""" # Class attributes - id: ClassVar[str] = "base" + id: ClassVar[str] = ... """ID for this chat handler; should be unique""" - name: ClassVar[str] = "Base Chat Handler" # TODO: make NotImplemented + name: ClassVar[str] = ... """User-facing name of this handler""" description: ClassVar[Optional[str]] @@ -32,15 +32,13 @@ class BaseChatHandler(Configurable): optimized for model interpretation, not human-facing help. Not necessary when the routing method is "slash_command".""" - # TODO: make NotImplemented - help: ClassVar[ - str - ] = "This is used when the message in the chat interface is not a command" + help: ClassVar[str] = ... """What this chat handler does, which third-party models it contacts, the format of the data it returns to the user, etc. Used in the UI.""" - # TODO: make NotImplemented - routing_method: ClassVar[str] = "slash_command" + routing_method: ClassVar[str] = ... + """The routing method that sends commands to this handler. + Either "natural_language" or "slash_command".""" slash_id: ClassVar[Optional[str]] """Slash ID for routing a chat command to this handler. Only one handler diff --git a/packages/jupyter-ai/jupyter_ai/extension.py b/packages/jupyter-ai/jupyter_ai/extension.py index 65439d656..aea2396da 100644 --- a/packages/jupyter-ai/jupyter_ai/extension.py +++ b/packages/jupyter-ai/jupyter_ai/extension.py @@ -106,7 +106,6 @@ def initialize_settings(self): eps = entry_points() # initialize chat handlers - self.log.info("Found entry point groups " + ", ".join(sorted(eps.groups))) chat_handler_eps = eps.select(group="jupyter_ai.chat_handlers") chat_handler_kwargs = { @@ -157,14 +156,9 @@ def initialize_settings(self): # Slash IDs may contain only alphanumerics and underscores. slash_id = chat_handler.slash_id - if slash_id: - # TODO: Validate slash ID (/^[A-Za-z0-9_]+$/) - command_name = f"/{slash_id}" - else: - command_name = "default" - self.log.info( - f"Trying to register chat handler `{chat_handler.id}` with command `{command_name}`" - ) + # TODO: Validate slash ID (/^[A-Za-z0-9_]+$/) + # The "default" handler above takes precedence over any "default" command here + command_name = f"/{chat_handler.slash_id}" if chat_handler.slash_id else "default" if command_name in jai_chat_handlers: self.log.error( @@ -179,8 +173,6 @@ def initialize_settings(self): self.settings["jai_chat_handlers"] = jai_chat_handlers - retriever = Retriever(learn_chat_handler=learn_chat_handler) - ask_chat_handler = AskChatHandler(**chat_handler_kwargs, retriever=retriever) latency_ms = round((time.time() - start) * 1000) self.log.info(f"Initialized Jupyter AI server extension in {latency_ms} ms.")