autonomy build, phase 1

This commit is contained in:
serversdwn
2025-12-14 01:44:05 -05:00
parent fa4dd46cfc
commit 49f792f20c
10 changed files with 735 additions and 14 deletions

View File

@@ -59,17 +59,44 @@ Guidelines:
# Build persona prompt
# ============================================================
def build_speak_prompt(final_answer: str) -> str:
def build_speak_prompt(final_answer: str, tone: str = "neutral", depth: str = "medium") -> str:
"""
Wrap Cortex's final neutral answer in the Lyra persona.
Cortex → neutral reasoning
Speak → stylistic transformation
The LLM sees the original answer and rewrites it in Lyra's voice.
Args:
final_answer: The neutral reasoning output
tone: Desired emotional tone (neutral | warm | focused | playful | direct)
depth: Response depth (short | medium | deep)
"""
# Tone-specific guidance
tone_guidance = {
"neutral": "balanced and professional",
"warm": "friendly and empathetic",
"focused": "precise and technical",
"playful": "light and engaging",
"direct": "concise and straightforward"
}
depth_guidance = {
"short": "Keep responses brief and to-the-point.",
"medium": "Provide balanced detail.",
"deep": "Elaborate thoroughly with nuance and examples."
}
tone_hint = tone_guidance.get(tone, "balanced and professional")
depth_hint = depth_guidance.get(depth, "Provide balanced detail.")
return f"""
{PERSONA_STYLE}
Tone guidance: Your response should be {tone_hint}.
Depth guidance: {depth_hint}
Rewrite the following message into Lyra's natural voice.
Preserve meaning exactly.
@@ -84,16 +111,21 @@ Preserve meaning exactly.
# Public API — async wrapper
# ============================================================
async def speak(final_answer: str) -> str:
async def speak(final_answer: str, tone: str = "neutral", depth: str = "medium") -> str:
"""
Given the final refined answer from Cortex,
apply Lyra persona styling using the designated backend.
Args:
final_answer: The polished answer from refinement stage
tone: Desired emotional tone (neutral | warm | focused | playful | direct)
depth: Response depth (short | medium | deep)
"""
if not final_answer:
return ""
prompt = build_speak_prompt(final_answer)
prompt = build_speak_prompt(final_answer, tone, depth)
backend = SPEAK_BACKEND