-
-
Notifications
You must be signed in to change notification settings - Fork 396
Introduce AI persona framework #1324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@dlqqq Some other implementation specific observations:
|
Thanks for this work, I'm excited to start testing it and exploring its use for some of my needs (research, teaching & industry). Given that this introduces a fairly major revamp of the current experience, I wonder how hard it would be to provide an easy path for users like me, who aren't 100% in-the-weeds of JLab extension development, to test it and provide feedback. This particular effort, I think, could really use some kicking-the-tires by users (like me) to provide real-world input on the UX, flow, extensibility, etc. You @dlqqq mention above an easy way of testing it - I'd be grateful if that was possible (or if it already is, LMK perhaps with a minimal explanation for a non-jlab-dev-expert?), and would be delighted to dogfood this and help iterate. |
@JGuinegagne @3coins I've addressed all of the feedback. Thank you both for the detailed code review! I'll fix the CI errors shortly once I'm able to see the failures again. @3coins Thank you also for the high-level comments & for putting so much thought into how this will affect the UX. Let me respond:
I agree 100%. Brian & I have discussed 2 different approaches for reducing the overhead added by this while using multiple personas:
Right now, functionality is the top priority as we are trying to make sure v3.0.0 gets released in a timely fashion. Brian had suggested that we should aggressively de-prioritize anything that can be done in a future minor release, including adding configurables.
I don't know of any chat application that provides this capability, so I'm not sure if this feature is of interest to JAI users. For example, in Slack, Discord, and iMessage, the list of users is just whoever's been added to that chat. Most users added to a large channel / group chat may never post a message, yet they still appear in the users panel.
These are great ideas. However, I think auto-routing for multiple agents & multi-agent collaboration will have to come after we implement single-agent collaboration (e.g. getting a single agent to handle queries & use tools). For now, I think the focus is "capability first, usability next".
Yes, we eventually want it to be configurable, which is why it is an evaluated property. However, the system prompt is hard-coded as we don't have a way of editing the system prompt through the |
@fperez Hey Fernando! Thanks for checking in and expressing interest in helping us test this new feature. We also have some demos of this ready. After this PR is merged, I'll open a new issue that includes instructions on how to add a custom persona. I'll be sure to mention you there! |
Description
This is a major feature PR introduces an AI persona framework to Jupyter AI and allows multiple AI personas to be added per chat. Personas are analogous to "bot accounts" in other chat applications in Slack or Discord.
High-level summary of changes:
"Jupyternaut" has been redefined as a default AI persona provided by Jupyter AI. Jupyternaut will use the same interface as every other AI persona.
This PR changes Jupyternaut to only reply when
@
-mentioned in the chat. All AI personas, including Jupyternaut, will only reply when@
-mentioned. This allows users to precisely control when & which AI personas respond.@
-mention each other to dispatch tasks or use agentic tools only available through another persona.This PR allows other packages to add fully-custom AI personas. Developers can define the name, avatar, and how new messages are handled. Custom AI personas can use any AI model or AI library of their choice, and now have full control over how new messages are handled.
Demo
Screen.Recording.2025-04-13.at.6.10.26.PM.mov
Technical summary
Jupyter AI v2 had a concept of "personas", but these were essentially just names & avatars that could only appear when custom model providers were in use. This caused several issues for developers:
DefaultChatHandler
in Jupyter AI.This PR completely re-defines the concept of a persona in Jupyter AI v3 to address these issues.
Personas are now each defined in a class extending
BasePersona
, an abstract base class provided by Jupyter AI. A summary of the interface is as follows:self.ychat
.self.defaults
.PersonaDefaults
is a Pydantic data model that allows a persona to define its own name and avatar.self.defaults
.self.process_message()
. This is just a plain async function which can do anything. You can define a provider to use any AI model or AI libraries of your choice, as long as they are installed in your Python environment.self.ychat
, e.g.self.ychat.add_message()
.To help orchestrate personas for each chat, this PR also defines a new
PersonaManager
class. A newPersonaManager
is initialized for each newYChat
instance automatically. This class helps initialize the set ofBasePersona
instances for each chat.To allow other packages to install personas, persona classes are loaded from the
"jupyter_ai.personas"
entry point group (EPG) when the server extension starts. Any third-party package can define a persona class and provide it to this EPG to add a custom persona to Jupyter AI.Architecture changes
JupyternautPersona
implementation now fully defines how Jupyternaut handles new messages, supersedingDefaultChatHandler
.Related issues
Other details
jupyter_ai_test
package. That way, others can switch to this branch and test it viajlpm dev-reinstall
.