Open
0 of 1 issue completedDescription
Problem
In Jupyter AI v3, we are exploring ways to introduce multiple AI agents into the chat.
To do this, we need to define the data representation of an AI agent, and describe what it does.
Proposed Solution
A persona is a complete description of an agent which can directly accept user queries, and is treated like "just another user" in the chat.
- This agent should be
@
-mentionable from the chat. - When a user types a new message into the chat, the persona should respond intelligently:
- When there is only one user & one persona: always reply to new messages.
- Otherwise: only reply when
@
-mentioned.
- The persona should be able to fully represent Jupyternaut.
- The persona should be configurable and read from the
ConfigManager
to allow users to override our defaults.
Proposed interface:
class PersonaDefaults(BaseModel):
# required fields
name: str # e.g. "Jupyternaut"
avatar_path: str # e.g. /avatars/jupyternaut.svg
system_prompt: str # e.g. "You are a language model named..."
slash_commands: Set[str] = set("*") # change this to enable/disable slash commands
# optional fields
model_uid: Optional[str] = None # e.g. "ollama:deepseek-coder-v2"
# ^^^ set this to automatically default to a model after a fresh start, no config file
class Persona(BaseModel):
id: str # e.g. 'jupyternaut'
defaults: PersonaDefaults
subagents: Set[Persona]
config_manager: ConfigManager
@property
def name(self) -> str:
"""The name that users should use to `@`-mention this persona."
return self.config.jupyternaut.name or self.defaults.name
@property
def avatar_path(self) -> str:
"""The path to this persona's avatar, shown in the chat."""
return self.config.jupyternaut.avatar_path or self.defaults.avatar_path
@property
def system_prompt(self) -> str:
"""The system prompt used by this persona."""
return self.config.jupyternaut.system_prompt or self.defaults.system_prompt
@property
def lc_runnable(self) -> Runnable:
"""The LangChain runnable used to define the implementation of this persona."""
Additional context
We will elaborate on how to extend this to build a multi-agent collaboration (MAC) experience later in a future issue.