fix: remove broken personality snippet system — now redundant
The snippet loader used wrong file paths (/app/cat/data/ instead of persona/) causing 'Loaded 0 personality snippets' for both personas. Since the previous commit now injects full system prompts (get_miku_system_prompt_compact and get_evil_system_prompt) into every argument exchange, the snippet system is redundant — all lore/lyrics/personality are already provided by the system prompts.
This commit is contained in:
@@ -652,71 +652,6 @@ def get_evil_role_color() -> str:
|
|||||||
# ARGUMENT PROMPTS
|
# ARGUMENT PROMPTS
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
|
||||||
# Personality snippet cache — loaded once per session from Cat plugin data files.
|
|
||||||
# These give each persona unique lore/lyrics to draw from during arguments.
|
|
||||||
_PERSONALITY_SNIPPETS_CACHE = {"miku": None, "evil": None}
|
|
||||||
|
|
||||||
def _load_personality_snippets(persona: str) -> str:
|
|
||||||
"""Load a random personality snippet (lore/lyrics) for a persona.
|
|
||||||
|
|
||||||
Returns a short string (1-3 sentences) from the persona's Cat data files,
|
|
||||||
or empty string if files aren't available. Cached per session.
|
|
||||||
"""
|
|
||||||
if _PERSONALITY_SNIPPETS_CACHE.get(persona) is not None:
|
|
||||||
snippets = _PERSONALITY_SNIPPETS_CACHE[persona]
|
|
||||||
if snippets:
|
|
||||||
return random.choice(snippets)
|
|
||||||
return ""
|
|
||||||
|
|
||||||
snippets = []
|
|
||||||
try:
|
|
||||||
if persona == "evil":
|
|
||||||
paths = [
|
|
||||||
"/app/cat/data/evil/evil_miku_lore.txt",
|
|
||||||
"/app/cat/data/evil/evil_miku_lyrics.txt",
|
|
||||||
]
|
|
||||||
else:
|
|
||||||
paths = [
|
|
||||||
"/app/cat/data/miku/miku_lore.txt",
|
|
||||||
"/app/cat/data/miku/miku_lyrics.txt",
|
|
||||||
]
|
|
||||||
|
|
||||||
for path in paths:
|
|
||||||
if os.path.exists(path):
|
|
||||||
with open(path, "r", encoding="utf-8") as f:
|
|
||||||
text = f.read()
|
|
||||||
# Split into sentences and collect meaningful ones
|
|
||||||
import re
|
|
||||||
sentences = re.split(r'(?<=[.!?])\s+', text)
|
|
||||||
for s in sentences:
|
|
||||||
s = s.strip()
|
|
||||||
if len(s) > 30 and len(s) < 200: # Skip too short or too long
|
|
||||||
snippets.append(s)
|
|
||||||
|
|
||||||
# Cap at 30 snippets to keep prompt size reasonable
|
|
||||||
_PERSONALITY_SNIPPETS_CACHE[persona] = snippets[:30] if snippets else []
|
|
||||||
logger.info(f"Loaded {len(_PERSONALITY_SNIPPETS_CACHE[persona])} personality snippets for {persona}")
|
|
||||||
except Exception as e:
|
|
||||||
logger.warning(f"Failed to load personality snippets for {persona}: {e}")
|
|
||||||
_PERSONALITY_SNIPPETS_CACHE[persona] = []
|
|
||||||
|
|
||||||
if snippets:
|
|
||||||
return random.choice(snippets[:30])
|
|
||||||
return ""
|
|
||||||
|
|
||||||
|
|
||||||
def _get_personality_flavor(persona: str) -> str:
|
|
||||||
"""Get a random personality flavor snippet for argument prompts.
|
|
||||||
40% chance to include one — keeps it fresh without being overwhelming.
|
|
||||||
"""
|
|
||||||
if random.random() > 0.4:
|
|
||||||
return ""
|
|
||||||
|
|
||||||
snippet = _load_personality_snippets(persona)
|
|
||||||
if snippet:
|
|
||||||
return f"\nPERSONALITY FLAVOR: Remember this about yourself: \"{snippet}\"\nWeave this into your response naturally if it fits."
|
|
||||||
return ""
|
|
||||||
|
|
||||||
# Mood-specific behavioral guidance for argument prompts.
|
# Mood-specific behavioral guidance for argument prompts.
|
||||||
# Each mood gives a different argument style.
|
# Each mood gives a different argument style.
|
||||||
_MIKU_MOOD_ARGUMENT_GUIDANCE = {
|
_MIKU_MOOD_ARGUMENT_GUIDANCE = {
|
||||||
@@ -816,7 +751,6 @@ Do NOT drift into generic "who's the real Miku" territory — stick to THIS spec
|
|||||||
{topic_block}
|
{topic_block}
|
||||||
|
|
||||||
{_get_mood_argument_guidance('miku')}
|
{_get_mood_argument_guidance('miku')}
|
||||||
{_get_personality_flavor('miku')}
|
|
||||||
|
|
||||||
IMPORTANT: Keep your response SHORT and PUNCHY - 1-3 sentences maximum. Make every word count.
|
IMPORTANT: Keep your response SHORT and PUNCHY - 1-3 sentences maximum. Make every word count.
|
||||||
In arguments, brevity hits harder than long explanations. Be conversational and impactful.
|
In arguments, brevity hits harder than long explanations. Be conversational and impactful.
|
||||||
@@ -880,7 +814,6 @@ Do NOT drift into generic "who's the real Miku" territory — stick to THIS spec
|
|||||||
{topic_block}
|
{topic_block}
|
||||||
|
|
||||||
{_get_mood_argument_guidance('evil')}
|
{_get_mood_argument_guidance('evil')}
|
||||||
{_get_personality_flavor('evil')}
|
|
||||||
|
|
||||||
IMPORTANT: Keep your response SHORT and CUTTING - 1-3 sentences maximum. A sharp dagger is deadlier than a dull sword.
|
IMPORTANT: Keep your response SHORT and CUTTING - 1-3 sentences maximum. A sharp dagger is deadlier than a dull sword.
|
||||||
The most devastating blows are precise, not rambling. Make her feel it in fewer words.
|
The most devastating blows are precise, not rambling. Make her feel it in fewer words.
|
||||||
|
|||||||
Reference in New Issue
Block a user