ContextCompressorBase<T>

Base Classes · AiDotNet.RetrievalAugmentedGeneration.ContextCompression

Provides a base implementation for context compressors with common functionality.

Implements: IContextCompressor<T>

Known derived types: AutoCompressor<T>, DocumentSummarizer<T>, LLMContextCompressor<T>, SelectiveContextCompressor<T>

For Beginners

This is the foundation that all context compressors build upon.

Think of it like a template for reducing document size:

  • It handles common tasks (checking inputs aren’t null or empty)
  • Specific compression methods (LLM-based, rule-based) fill in how they compress
  • This ensures all compressors work consistently

How It Works

This abstract class implements the IContextCompressor interface and provides common functionality for context compression strategies. It handles validation and delegates to derived classes for the core compression logic.

Methods

Method Summary
List<Document<T>> Compress(List<Document<T>> documents, string query, Dictionary<string, object> options) Compresses a collection of documents while preserving relevance to the query.
Task<List<Document<T>>> CompressAsync(List<Document<T>> documents, string query, Dictionary<string, object> options, CancellationToken cancellationToken) Asynchronously compresses a collection of documents while preserving relevance to the query.