diff --git a/packages/jupyter-ai-test/jupyter_ai_test/test_providers.py b/packages/jupyter-ai-test/jupyter_ai_test/test_providers.py index b32b22acc..1ec042afb 100644 --- a/packages/jupyter-ai-test/jupyter_ai_test/test_providers.py +++ b/packages/jupyter-ai-test/jupyter_ai_test/test_providers.py @@ -76,6 +76,7 @@ class TestProviderWithStreaming(BaseProvider, TestLLMWithStreaming): """User inputs expected by this provider when initializing it. Each `Field` `f` should be passed in the constructor as a keyword argument, keyed by `f.key`.""" + class TestProviderAskLearnUnsupported(BaseProvider, TestLLMWithStreaming): id: ClassVar[str] = "test-provider-ask-learn-unsupported" """ID for this provider class.""" diff --git a/packages/jupyter-ai/jupyter_ai/chat_handlers/base.py b/packages/jupyter-ai/jupyter_ai/chat_handlers/base.py index 71cf25646..83aaef4f0 100644 --- a/packages/jupyter-ai/jupyter_ai/chat_handlers/base.py +++ b/packages/jupyter-ai/jupyter_ai/chat_handlers/base.py @@ -111,7 +111,7 @@ class BaseChatHandler: """Format string template that is used to build the help message. Specified from traitlets configuration.""" - chat_handlers: Dict[str, 'BaseChatHandler'] + chat_handlers: Dict[str, "BaseChatHandler"] """Dictionary of chat handlers. Allows one chat handler to reference other chat handlers, which is necessary for some use-cases like printing the help message.""" @@ -127,7 +127,7 @@ def __init__( preferred_dir: Optional[str], dask_client_future: Awaitable[DaskClient], help_message_template: str, - chat_handlers: Dict[str, 'BaseChatHandler'], + chat_handlers: Dict[str, "BaseChatHandler"], ): self.log = log self.config_manager = config_manager @@ -381,16 +381,18 @@ def output_dir(self) -> str: return self.preferred_dir else: return self.root_dir - + def send_help_message(self, human_msg: Optional[HumanChatMessage] = None) -> None: """Sends a help message to all connected clients.""" lm_provider = self.config_manager.lm_provider - unsupported_slash_commands = lm_provider.unsupported_slash_commands if lm_provider else set() + unsupported_slash_commands = ( + lm_provider.unsupported_slash_commands if lm_provider else set() + ) chat_handlers = self.chat_handlers - slash_commands = {k: v for k, v in chat_handlers.items() if k != "default" } + slash_commands = {k: v for k, v in chat_handlers.items() if k != "default"} for key in unsupported_slash_commands: del slash_commands[key] - + # markdown string that lists the slash commands slash_commands_list = "\n".join( [ @@ -399,7 +401,9 @@ def send_help_message(self, human_msg: Optional[HumanChatMessage] = None) -> Non ] ) - help_message_body = self.help_message_template.format(persona_name=self.persona.name, slash_commands_list=slash_commands_list) + help_message_body = self.help_message_template.format( + persona_name=self.persona.name, slash_commands_list=slash_commands_list + ) help_message = AgentChatMessage( id=uuid4().hex, time=time.time(), diff --git a/packages/jupyter-ai/jupyter_ai/chat_handlers/clear.py b/packages/jupyter-ai/jupyter_ai/chat_handlers/clear.py index df88a7db1..2d4252256 100644 --- a/packages/jupyter-ai/jupyter_ai/chat_handlers/clear.py +++ b/packages/jupyter-ai/jupyter_ai/chat_handlers/clear.py @@ -27,4 +27,4 @@ async def process_message(self, _): break # re-send help message - self.send_help_message() \ No newline at end of file + self.send_help_message() diff --git a/packages/jupyter-ai/jupyter_ai/chat_handlers/help.py b/packages/jupyter-ai/jupyter_ai/chat_handlers/help.py index 718ea2e63..cd8556863 100644 --- a/packages/jupyter-ai/jupyter_ai/chat_handlers/help.py +++ b/packages/jupyter-ai/jupyter_ai/chat_handlers/help.py @@ -2,6 +2,7 @@ from .base import BaseChatHandler, SlashCommandRoutingType + class HelpChatHandler(BaseChatHandler): id = "help" name = "Help" @@ -15,4 +16,4 @@ def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) async def process_message(self, message: HumanChatMessage): - self.send_help_message(message) \ No newline at end of file + self.send_help_message(message) diff --git a/packages/jupyter-ai/jupyter_ai/extension.py b/packages/jupyter-ai/jupyter_ai/extension.py index f80ae766d..e89f6bdb4 100644 --- a/packages/jupyter-ai/jupyter_ai/extension.py +++ b/packages/jupyter-ai/jupyter_ai/extension.py @@ -178,9 +178,9 @@ class AiExtension(ExtensionApp): 'Jupyternaut'. - `slash_commands_list`: A string containing a bulleted list of the - slash commands available to the configured language model. + slash commands available to the configured language model. """, - config=True + config=True, ) def initialize_settings(self): @@ -369,9 +369,10 @@ def _show_help_message(self): # call `send_help_message()` on any instance of `BaseChatHandler`. The # `default` chat handler should always exist, so we reference that # object when calling `send_help_message()`. - default_chat_handler: DefaultChatHandler = self.settings["jai_chat_handlers"]["default"] + default_chat_handler: DefaultChatHandler = self.settings["jai_chat_handlers"][ + "default" + ] default_chat_handler.send_help_message() - async def _get_dask_client(self): return DaskClient(processes=False, asynchronous=True)