Problem
Multiple AI agents should be able to share the same chat, and for that to happen, they need to have different identities shown on their messages.
The current way we do this in Jupyter AI is to hack the awareness model to override the user that YChat sends from:
https://github.com/jupyter-ai-contrib/jupyter-ai-persona-manager/blob/main/jupyter_ai_persona_manager/persona_awareness.py
We also do a similar hack to allow a 'System' user to be shown in response to system-level commands (e.g. /refresh-personas):
https://github.com/jupyter-ai-contrib/jupyter-ai-persona-manager/blob/6adda36d188070a5b7cc510794af8db4f6510c1e/jupyter_ai_persona_manager/persona_manager.py#L391
Proposed Solution
Provide a simple server-side Python-model-only API for adding users to the chat, and allow messages to be sent from there. Then, agents on the server can send messages attributed to one of these previously-added users:
BaseChatModel.add_user(user=...)
BaseChatModel.send_message(self, user=..., ...)
Additional context
I am inclined to just call this "user" since you have to pass in a User model. But, maybe user is not the right name, open to suggestions here.
Long term, I think it would be easier to define an extremely simple ChatUser class that add_user() returns, e.g.
# persona calls add_user() to add itself to the chat
self.chat.add_user() -> ChatUser
# this ChatUser just forwards the method call to self.parent (BaseChatModel) and helps pass in the `user` argument
self.chat_user.send_message(...)
self.chat_user.broadcast_writing_status(...)
If folks are open to this I'm happy to include this with the PR.
Problem
Multiple AI agents should be able to share the same chat, and for that to happen, they need to have different identities shown on their messages.
The current way we do this in Jupyter AI is to hack the awareness model to override the user that
YChatsends from:https://github.com/jupyter-ai-contrib/jupyter-ai-persona-manager/blob/main/jupyter_ai_persona_manager/persona_awareness.py
We also do a similar hack to allow a 'System' user to be shown in response to system-level commands (e.g.
/refresh-personas):https://github.com/jupyter-ai-contrib/jupyter-ai-persona-manager/blob/6adda36d188070a5b7cc510794af8db4f6510c1e/jupyter_ai_persona_manager/persona_manager.py#L391
Proposed Solution
Provide a simple server-side Python-model-only API for adding users to the chat, and allow messages to be sent from there. Then, agents on the server can send messages attributed to one of these previously-added users:
Additional context
I am inclined to just call this "user" since you have to pass in a
Usermodel. But, maybe user is not the right name, open to suggestions here.Long term, I think it would be easier to define an extremely simple
ChatUserclass thatadd_user()returns, e.g.If folks are open to this I'm happy to include this with the PR.