You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Then, install your package so that Jupyter AI adds custom chat handlers
462
462
to the existing chat handlers.
463
463
464
+
## Overriding or disabling a built-in slash command
465
+
466
+
You can define a custom implementation of a built-in slash command by following the steps above on building a custom slash command. This will involve creating and installing a new package. Then, to override a chat handler with this custom implementation, provide an entry point with a name matching the ID of the chat handler to override.
467
+
468
+
For example, to override `/ask` with a `CustomAskChatHandler` class, add the following to `pyproject.toml` and re-install the new package:
469
+
470
+
```python
471
+
[project.entry-points."jupyter_ai.chat_handlers"]
472
+
ask ="<module-path>:CustomAskChatHandler"
473
+
```
474
+
475
+
You can also disable a built-in slash command by providing a mostly-empty chat handler with `disabled = True`. For example, to disable the default `ask` chat handler of Jupyter AI, define a new `DisabledAskChatHandler`:
476
+
477
+
```python
478
+
classDisabledAskChatHandler:
479
+
id='ask'
480
+
disabled =True
481
+
```
482
+
483
+
Then, provide this as an entry point in your custom package:
484
+
```python
485
+
[project.entry-points."jupyter_ai.chat_handlers"]
486
+
ask ="<module-path>:DisabledAskChatHandler"
487
+
```
488
+
489
+
Finally, re-install your custom package. After starting JupyterLab, the `/ask` command should now be disabled.
490
+
491
+
:::{warning}
492
+
:name: entry-point-name
493
+
To override or disable a built-in slash command via an entry point, the name of the entry point (left of the `=` symbol) must match the chat handler ID exactly.
494
+
:::
495
+
464
496
## Streaming output from custom slash commands
465
497
466
498
Jupyter AI supports streaming output in the chat session. When a response is
0 commit comments