Class ChatModelSummarizer

java.lang.Object
org.springframework.ai.session.compaction.ChatModelSummarizer
All Implemented Interfaces:
CompactionSummarizer

public final class ChatModelSummarizer extends Object implements CompactionSummarizer
A CompactionSummarizer that asks a ChatModel for a rolling summary of the covered conversation: the prior summary is fed back as context, so each summary builds on its predecessors, and the first overlapSize preserved events are quoted for continuity. The summary comes back as a turn of two messages, a user "shadow prompt" and the assistant summary, so the model keeps seeing a user/assistant alternation. A failed model call or a null or blank reply declines: it is logged, the failure callback is called, and the view stays as it is.
Since:
2.1.0
Author:
Christian Tzolov
  • Field Details

    • DEFAULT_OVERLAP_SIZE

      public static final int DEFAULT_OVERLAP_SIZE
      Default number of preserved events quoted in the prompt for continuity.
      See Also:
    • DEFAULT_SHADOW_PROMPT

      public static final String DEFAULT_SHADOW_PROMPT
      The synthetic user message that opens each summary turn.
      See Also:
  • Method Details