Class LlmEventSummarizer

java.lang.Object
com.google.adk.summarizer.LlmEventSummarizer
All Implemented Interfaces:
BaseEventSummarizer

public final class LlmEventSummarizer extends Object implements BaseEventSummarizer
An LLM-based event summarizer for sliding window compaction.
  • Constructor Details

    • LlmEventSummarizer

      public LlmEventSummarizer(BaseLlm baseLlm)
    • LlmEventSummarizer

      public LlmEventSummarizer(BaseLlm baseLlm, @Nullable String promptTemplate)
      Creates a summarizer with the given prompt template; null selects the default template.
    • LlmEventSummarizer

      public LlmEventSummarizer(BaseLlm baseLlm, @Nullable String promptTemplate, InstantSource instantSource, UuidProvider uuidProvider)
      Creates a summarizer whose compaction events draw their id, invocation id, and timestamp from the given sources. Passing null as promptTemplate selects the default template.
  • Method Details

    • summarizeEvents

      public io.reactivex.rxjava3.core.Maybe<Event> summarizeEvents(List<Event> events)
      Description copied from interface: BaseEventSummarizer
      Compact a list of events into a single event.

      If compaction failed, return Maybe.empty(). Otherwise, compact into a content and return it.

      This method will summarize the events and return a new summary event indicating the range of events it summarized.

      Specified by:
      summarizeEvents in interface BaseEventSummarizer
      Parameters:
      events - Events to compact.
      Returns:
      The new compacted event, or Maybe.empty() if no compaction happened.