Spaces:
Running
Running
File size: 2,015 Bytes
a31f556 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | 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
}
|