Skip to content

Commit e20d631

Browse files
committed
Updates related to router slash commands
1 parent 71dc5a1 commit e20d631

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

jupyter_ai_chat_commands/extension_app.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,11 @@ async def initialize_async(self):
4040
router.observe_chat_init(lambda room_id, ychat: self.on_chat_init(router, room_id))
4141

4242
def on_chat_init(self, router: MessageRouter, room_id: str):
43-
router.observe_slash_cmd_msg(room_id, self.on_slash_command)
43+
router.observe_slash_cmd_msg(room_id, "refresh-personas", self.on_slash_command)
4444
self.log.info("Attached router observer.")
4545

46-
def on_slash_command(self, room_id: str, message: Message):
47-
first_word = get_first_word(message.body)
48-
assert first_word and first_word.startswith("/")
49-
50-
command_id = first_word[1:]
51-
if command_id == "refresh-personas":
52-
self.event_loop.create_task(self.handle_refresh_personas(room_id))
53-
return True
54-
55-
# If command is unrecognized, log an error
56-
self.log.warning(f"Unrecognized slash command: '/{command_id}'")
57-
return False
46+
def on_slash_command(self, room_id: str, command: str, message: Message):
47+
self.event_loop.create_task(self.handle_refresh_personas(room_id))
5848

5949
async def handle_refresh_personas(self, room_id: str):
6050
self.log.info(f"Received /refresh-personas in room '{room_id}'.")

0 commit comments

Comments
 (0)