jupyter-ai
jupyter-ai copied to clipboard
Make help message template configurable
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
HelpChatHandlerto theBaseChatHandlerbase class.- The reason for doing this is that
/clearalso 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.
- The reason for doing this is that
- Fixes #932
Demo
Testing
To reproduce the above demo:
- Create a new
config.pyfile 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()
- 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.
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 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.
I think this also fixes https://github.com/jupyterlab/jupyter-ai/issues/927