Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Sep 27, 2023
1 parent af164df commit b5e3cb5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
1 change: 1 addition & 0 deletions packages/jupyter-ai/jupyter_ai/chat_handlers/ask.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class AskChatHandler(BaseChatHandler):
query the documents from the index, and sends this context
to the LLM to generate the final reply.
"""

id = "ask-chat-handler"
name = "Ask with Local Data"
description = "Ask a question augmented with learned data"
Expand Down
11 changes: 6 additions & 5 deletions packages/jupyter-ai/jupyter_ai/chat_handlers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from jupyter_ai.config_manager import ConfigManager, Logger
from jupyter_ai.models import AgentChatMessage, HumanChatMessage
from jupyter_ai_magics.providers import BaseProvider

from traitlets.config import Configurable

if TYPE_CHECKING:
Expand All @@ -19,15 +18,17 @@
class BaseChatHandler(Configurable):
"""Base ChatHandler class containing shared methods and attributes used by
multiple chat handler classes."""

# Class attributes
id: str = 'base-chat-handler'
id: str = "base-chat-handler"
"""ID for this chat handler; should be unique"""

name: str = 'Base Chat Handler' # TODO: make NotImplemented
name: str = "Base Chat Handler" # TODO: make NotImplemented
"""User-facing name of this handler"""

description: str = "Handler for messages that are not commands" # TODO: make NotImplemented
description: str = (
"Handler for messages that are not commands" # TODO: make NotImplemented
)
"""Description used for routing requests, to be used when dispatching
messages to model providers. Also shown in the UI."""

Expand Down
16 changes: 10 additions & 6 deletions packages/jupyter-ai/jupyter_ai/extension.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from importlib_metadata import entry_points
import logging
import time

from dask.distributed import Client as DaskClient
from importlib_metadata import entry_points
from jupyter_ai.chat_handlers.learn import Retriever
from jupyter_ai_magics.utils import get_em_providers, get_lm_providers
from jupyter_server.extension.application import ExtensionApp
Expand Down Expand Up @@ -95,7 +95,7 @@ def initialize_settings(self):
"root_dir": self.serverapp.root_dir,
"dask_client_future": dask_client_future,
# TODO: Set ask_chat_handler based on a retriever related to the learn_chat_handler
"retriever": None
"retriever": None,
}

for chat_handler_ep in chat_handler_eps:
Expand All @@ -116,17 +116,21 @@ def initialize_settings(self):
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}`")

self.log.info(
f"Trying to register chat handler `{chat_handler.id}` with command `{command_name}`"
)

if command_name in jai_chat_handlers:
self.log.error(
f"Unable to register chat handler `{chat_handler.id}` because command `{command_name}` already has a handler"
)
continue

jai_chat_handlers[command_name] = chat_handler
self.log.info(f"Registered chat handler `{chat_handler.id}` with command `{command_name}`.")

self.log.info(
f"Registered chat handler `{chat_handler.id}` with command `{command_name}`."
)

self.settings["jai_chat_handlers"] = jai_chat_handlers

"""
Expand Down

0 comments on commit b5e3cb5

Please sign in to comment.