jupyter-ai icon indicating copy to clipboard operation
jupyter-ai copied to clipboard

Make help message template configurable

Open dlqqq opened this issue 1 year ago • 3 comments
trafficstars

Description

  • Makes the help message template configurable via traitlets.
  • Performs some fairly significant refactoring. The method for sending a help message has been moved from HelpChatHandler to the BaseChatHandler base class.
    • The reason for doing this is that /clear also needs to be able to send a help message. Since this functionality is shared by multiple chat handlers, it seemed like better practice to implement this exactly once in a base class and allow any chat handler to send a help message.
  • Fixes #932

Demo

Screenshot 2024-08-06 at 2 49 46 PM

Testing

To reproduce the above demo:

  1. Create a new config.py file in your current directory with the contents:
c.AiExtension.help_message_template = """
Sup. I'm {persona_name}. This is a sassy custom help message.

Here's the slash commands you can use. Use 'em or don't... I don't care.

{slash_commands_list}
""".strip()
  1. Start JupyterLab via jupyter lab --config=config.py.

Additional notes

I've added a new TestProviderAskLearnUnsupported class in the jupyter_ai_test package for local testing. You can verify that after switching to this model in the settings and running /clear, /ask and /learn do not show up in the help message as they are listed in unsupported_slash_commands.

  • We do not automatically regenerate the help message when switching between different LLMs, even if they differ in the slash commands that they support. This is a known issue.

dlqqq avatar Aug 06 '24 22:08 dlqqq

hello, since you are making this change, it seems like perhaps we can resolve https://github.com/jupyterlab/jupyter-ai/issues/851 by splitting the welcome and help message. I think it would make more sense to make the welcome message configurable via this traitlet while having the help chat handler define the help message. what do you think?

michaelchia avatar Aug 07 '24 16:08 michaelchia

@michaelchia I agree that we should split the welcome message and the help message in the future! This PR doesn't exclude that possibility; it's merely making the help message configurable.

dlqqq avatar Aug 07 '24 22:08 dlqqq

I think this also fixes https://github.com/jupyterlab/jupyter-ai/issues/927

krassowski avatar Aug 14 '24 09:08 krassowski