jarvis-cloud / backend /agent /personas.py
Jarvis2345's picture
Squash history β€” remove all prior commits (secret hygiene, S4)
a31f556
Raw
History Blame Contribute Delete
2.02 kB
from typing import Dict
from modules.assistant_identity import set_mode, get_identity_persona_prompt
# ── Β§2.1b Space Context Voice Injection ──────────────────────────────────────
# Persona-specific acknowledgement phrases for space transitions.
# {space} is substituted with the canonical space name at call time.
# Two variants per persona: one for each direction of the toggle.
SPACE_ACK_PROMPTS = {
"jarvis": {
"dark_space": "Switching to Dark Space. Adjusting parameters accordingly, sir.",
"family_friendly": "Switching to Family Friendly mode, sir. Filters engaged.",
},
"friday": {
"dark_space": "Got it β€” moving into Dark Space mode for you, boss.",
"family_friendly": "Family Friendly mode activated. All good, boss.",
},
}
def get_space_ack_prompt(persona: str, space_key: str) -> str:
"""
Returns the correct persona+space acknowledgement string.
space_key must be 'dark_space' or 'family_friendly'.
Falls back gracefully for unknown keys.
"""
persona = (persona or "friday").lower()
space_key = (space_key or "dark_space").lower().replace(" ", "_")
prompts = SPACE_ACK_PROMPTS.get(persona, SPACE_ACK_PROMPTS["friday"])
return prompts.get(space_key, f"Space changed to {space_key.replace('_', ' ')}.")
def inject_persona(active_persona: str, user_transcript: str) -> Dict[str, str]:
"""Injects persona logic before sending to LLM router using the central identity system."""
# Temporarily set mode to ensure we get the correct prompt
set_mode(active_persona.lower())
# Retrieve the massive detailed identity prompt from central config
system_prompt = get_identity_persona_prompt()
print(f"V15 Voice Pipeline: Applying {active_persona} persona context from central identity module.")
return {
"system_prompt": system_prompt,
"transcript": user_transcript
}