refactor: consolidate conversation_history to ConversationHistory class

Remove legacy globals.conversation_history (defaultdict of deques) and
route all callers through utils.conversation_history.ConversationHistory:

- globals.py: remove conversation_history + unused collections imports
- llm.py: remove backward-compat dual-write to legacy system
- api.py: /conversation/{user_id} now reads from ConversationHistory
- actions.py: reset_conversation uses clear_channel()
- figurine_notifier.py: use add_message() instead of buggy setdefault()
- bipolar_mode.py: fix clear_history -> clear_channel (was AttributeError
  silently swallowed by bare except), fix bare except -> except Exception
This commit is contained in:
2026-04-11 00:21:44 +03:00
parent 02686c3b96
commit 8b14160028
6 changed files with 11 additions and 22 deletions

View File

@@ -4,6 +4,7 @@ import asyncio
import globals
from utils.moods import load_mood_description
from utils.scheduled import send_bedtime_reminder
from utils.conversation_history import conversation_history
from utils.logger import get_logger
logger = get_logger('commands')
@@ -32,7 +33,7 @@ def calm_miku() -> str:
def reset_conversation(user_id):
globals.conversation_history[str(user_id)].clear()
conversation_history.clear_channel(str(user_id))
async def force_sleep() -> str: