Skip to content

Commit f3bdf67

Browse files
committed
Updated README with correct APIs
1 parent 4a5b872 commit f3bdf67

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ router = self.serverapp.web_app.settings.get("jupyter-ai", {}).get("router")
1818
def on_new_chat(room_id: str, ychat: YChat):
1919
print(f"New chat connected: {room_id}")
2020

21+
def on_chat_reset(room_id: str, new_ychat: YChat):
22+
print(f"Chat document reset: {room_id}")
23+
2124
def on_slash_command(room_id: str, command: str, message: Message):
2225
print(f"Slash command '{command}' in {room_id}: {message.body}")
2326

@@ -26,6 +29,7 @@ def on_regular_message(room_id: str, message: Message):
2629

2730
# Register the callbacks
2831
router.observe_chat_init(on_new_chat)
32+
router.observe_chat_reset(on_chat_reset) # Called when .chat file is modified directly
2933
router.observe_slash_cmd_msg("room-id", "help", on_slash_command) # Only /help commands
3034
router.observe_chat_msg("room-id", on_regular_message)
3135
```
@@ -40,6 +44,7 @@ router.observe_chat_msg("room-id", on_regular_message)
4044
### Available Methods
4145

4246
- `observe_chat_init(callback)` - Called when new chat sessions are initialized with `(room_id, ychat)`
47+
- `observe_chat_reset(callback)` - Called when a YChat document is reset (requires `jupyter_server_documents`) with `(room_id, new_ychat)`
4348
- `observe_slash_cmd_msg(room_id, command_pattern, callback)` - Called for specific slash commands matching the pattern in a specific room
4449
- `observe_chat_msg(room_id, callback)` - Called for regular (non-slash) messages in a specific room
4550

0 commit comments

Comments
 (0)