Class ChatModelSummarizer
java.lang.Object
org.springframework.ai.session.compaction.ChatModelSummarizer
- All Implemented Interfaces:
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
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault number of preserved events quoted in the prompt for continuity.static final StringThe synthetic user message that opens each summary turn. -
Method Summary
Modifier and TypeMethodDescriptionstatic ChatModelSummarizer.Buildersummarize(SummaryRequest request) Summarizes the events that leave the view.
-
Field Details
-
DEFAULT_OVERLAP_SIZE
public static final int DEFAULT_OVERLAP_SIZEDefault number of preserved events quoted in the prompt for continuity.- See Also:
-
DEFAULT_SHADOW_PROMPT
The synthetic user message that opens each summary turn.- See Also:
-
-
Method Details
-
builder
-
summarize
Description copied from interface:CompactionSummarizerSummarizes the events that leave the view.- Specified by:
summarizein interfaceCompactionSummarizer- Parameters:
request- what to summarize, with the prior summary to build on and the kept events for continuity- Returns:
- the messages of the summary turn, in order; empty to leave the view unchanged
-