diff --git a/bot/api.py b/bot/api.py index 5fb46c5..7437f1e 100644 --- a/bot/api.py +++ b/bot/api.py @@ -201,6 +201,14 @@ def get_logs(): def get_last_prompt(): return {"prompt": globals.LAST_FULL_PROMPT or "No prompt has been issued yet."} +@app.get("/prompt/cat") +def get_last_cat_prompt(): + """Get the last Cheshire Cat interaction (prompt + response) for Web UI.""" + interaction = globals.LAST_CAT_INTERACTION + if not interaction.get("prompt"): + return {"prompt": "No Cheshire Cat interaction has occurred yet.", "response": "", "user": "", "mood": "", "timestamp": ""} + return interaction + @app.get("/mood") def get_current_mood(): return {"mood": globals.DM_MOOD, "description": globals.DM_MOOD_DESCRIPTION} diff --git a/bot/bot.py b/bot/bot.py index 7366207..e85beb8 100644 --- a/bot/bot.py +++ b/bot/bot.py @@ -99,9 +99,12 @@ async def on_ready(): intercept_external_loggers() # Restore evil mode state from previous session (if any) - from utils.evil_mode import restore_evil_mode_on_startup + from utils.evil_mode import restore_evil_mode_on_startup, restore_evil_cat_state restore_evil_mode_on_startup() + # Restore Cat personality/model state (async — needs event loop running) + await restore_evil_cat_state() + # Restore bipolar mode state from previous session (if any) from utils.bipolar_mode import restore_bipolar_mode_on_startup restore_bipolar_mode_on_startup() @@ -549,6 +552,14 @@ async def on_message(message): ) if response: logger.info(f"🐱 Cat embed response for {author_name}") + import datetime + globals.LAST_CAT_INTERACTION = { + "prompt": enhanced_prompt, + "response": response[:500] if response else "", + "user": author_name, + "mood": globals.DM_MOOD, + "timestamp": datetime.datetime.now().isoformat(), + } except Exception as e: logger.warning(f"🐱 Cat embed error, fallback: {e}") response = None @@ -637,7 +648,19 @@ async def on_message(message): response_type=response_type, ) if response: - logger.info(f"🐱 Cat response for {author_name} (mood: {current_mood})") + effective_mood = current_mood + if globals.EVIL_MODE: + effective_mood = f"EVIL:{getattr(globals, 'EVIL_DM_MOOD', 'evil_neutral')}" + logger.info(f"🐱 Cat response for {author_name} (mood: {effective_mood})") + # Track Cat interaction for Web UI Last Prompt view + import datetime + globals.LAST_CAT_INTERACTION = { + "prompt": prompt, + "response": response[:500] if response else "", + "user": author_name, + "mood": effective_mood, + "timestamp": datetime.datetime.now().isoformat(), + } except Exception as e: logger.warning(f"🐱 Cat pipeline error, falling back to query_llama: {e}") response = None diff --git a/bot/globals.py b/bot/globals.py index 86d6167..6a9fb39 100644 --- a/bot/globals.py +++ b/bot/globals.py @@ -68,7 +68,7 @@ AVAILABLE_MOODS = [ EVIL_MODE = False EVIL_DM_MOOD = "evil_neutral" EVIL_DM_MOOD_DESCRIPTION = "Evil Miku is calculating and cold." -EVIL_AVAILABLE_MOODS = ["aggressive", "cunning", "sarcastic", "evil_neutral"] +EVIL_AVAILABLE_MOODS = ["aggressive", "cunning", "sarcastic", "evil_neutral", "bored", "manic", "jealous", "melancholic", "playful_cruel", "contemptuous"] # EVIL_MOOD_EMOJIS removed — canonical source is utils/moods.py # Bipolar Mode System (both Mikus can argue via webhooks) @@ -83,6 +83,15 @@ BOT_USER = None LAST_FULL_PROMPT = "" +# Cheshire Cat last interaction tracking (for Web UI Last Prompt toggle) +LAST_CAT_INTERACTION = { + "prompt": "", + "response": "", + "user": "", + "mood": "", + "timestamp": "", +} + # Persona Dialogue System (conversations between Miku and Evil Miku) LAST_PERSONA_DIALOGUE_TIME = 0 # Timestamp of last dialogue for cooldown diff --git a/bot/static/index.html b/bot/static/index.html index a49eae6..6b3b492 100644 --- a/bot/static/index.html +++ b/bot/static/index.html @@ -433,6 +433,20 @@ color: #fff; border-bottom-color: #4CAF50; } + + /* Prompt source toggle buttons */ + .prompt-source-btn { + background: #333; + color: #aaa; + } + .prompt-source-btn.active { + background: #4CAF50; + color: #fff; + } + .prompt-source-btn:hover:not(.active) { + background: #444; + color: #ddd; + } .tab-content { display: none; @@ -661,6 +675,7 @@ + @@ -1149,13 +1164,35 @@