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:
@@ -1746,9 +1746,9 @@ def get_autonomous_stats():
|
||||
|
||||
@app.get("/conversation/{user_id}")
|
||||
def get_conversation(user_id: str):
|
||||
if user_id in globals.conversation_history:
|
||||
return {"conversation": list(globals.conversation_history[user_id])}
|
||||
return {"conversation": []}
|
||||
"""Get conversation history for a user/channel (uses centralized ConversationHistory)."""
|
||||
messages = conversation_history.get_recent_messages(user_id)
|
||||
return {"conversation": [{"author": author, "content": content, "is_bot": is_bot} for author, content, is_bot in messages]}
|
||||
|
||||
# ========== Figurine DM Subscription APIs ==========
|
||||
@app.get("/figurines/subscribers")
|
||||
|
||||
Reference in New Issue
Block a user