flavor_memory

Flavor Memory — Per-channel gustatory history in Redis.

Tracks which flavors a user has referenced, how often, and when. Provides familiarity bonuses: more mentions → stronger OXT/MOR on re-encounter.

async flavor_memory.record_flavor(redis_client, channel_id, flavor_name)[source]

Log a flavor reference for a channel.

Each entry: {“flavor”: name, “ts”: timestamp, “count”: N} Maintains a running history of the last _MAX_HISTORY unique flavors.

Return type:

None

Parameters:
  • redis_client (Any)

  • channel_id (str)

  • flavor_name (str)

async flavor_memory.get_flavor_affinity(redis_client, channel_id, flavor_name)[source]

Get familiarity bonus for a specific flavor in this channel.

Returns a multiplier: 1.0 for unknown, up to ~1.5 for very familiar. The bonus follows a log curve: rapid early gain, diminishing returns.

Used as a multiplier on OXT and MOR deltas during Phase 4 NCM computation.

Return type:

float

Parameters:
  • redis_client (Any)

  • channel_id (str)

  • flavor_name (str)

async flavor_memory.get_history(redis_client, channel_id)[source]

Get the full flavor history for a channel.

Return type:

List[Dict[str, Any]]

Parameters:
  • redis_client (Any)

  • channel_id (str)

async flavor_memory.get_top_flavors(redis_client, channel_id, n=5)[source]

Get the N most frequently referenced flavors for a channel.

Return type:

List[str]

Parameters:
  • redis_client (Any)

  • channel_id (str)

  • n (int)