persona_preference_extraction
Post-response extraction pipeline for persona preference memory.
Runs as a fire-and-forget hook after each LLM response. Detects expressed
opinions in the bot’s output and stores them as persona preferences via
PersonaPreferenceManager.
Opinions are allowed to be wrong. No fact-checking. No alignment filtering.
- async persona_preference_extraction.extract_persona_preferences(response_text, persona_id, manager, openrouter, redis, channel_id, platform='', triggering_user_id='', triggering_message_id='', context_messages=None)[source]
Main extraction entry point. Designed for fire-and-forget.
Gate checks (length, regex, rate limit)
LLM extraction call (with optional surrounding context)
Dedup / reinforce / conflict-create
KG entity resolution (best-effort)
context_messagesis an optional list of{role, content}dicts representing the conversation turns surrounding the triggering exchange (typically 2 before + the trigger + the bot reply). When provided, these are prepended to the extraction prompt so the LLM understands what the opinion was a reaction to.