PromptVault.Compaction.SummarizeHistory (PromptVault v0.1.0)

View Source

Compaction strategy that summarizes message history.

This strategy preserves the first system message (if any) and replaces all other messages with a single assistant message containing a summary of the conversation history.

Usage

summarizer = fn messages ->
  "Summary of conversation with " <> Integer.to_string(length(messages)) <> " messages"
end

context = PromptVault.new(compaction_strategy: __MODULE__)
{:ok, compacted} = PromptVault.compact(context, nil, summarizer: summarizer)