CompositeCompressor

Models & Types ยท AiDotNet.PromptEngineering.Compression

Compressor that chains multiple compressors together in sequence.

Inheritance: PromptCompressorBase โ†’ CompositeCompressor

For Beginners

Combines multiple compressors for better results.

Example:

Order matters:

  • Put rule-based compressors first
  • Put aggressive compressors last
  • Each compressor should work well with the output of the previous one

How It Works

This compressor applies multiple compression strategies in sequence, with each compressor working on the output of the previous one. This allows combining the strengths of different compression approaches.

Constructors

Constructor Summary
CompositeCompressor(IEnumerable<IPromptCompressor> compressors, Func<string, int> tokenCounter) Initializes a new instance of the CompositeCompressor class.
CompositeCompressor(IPromptCompressor[] compressors) Initializes a new instance of the CompositeCompressor class.

Properties

Property Summary
IReadOnlyList<IPromptCompressor> Compressors { get; } Gets the list of compressors in this composite.

Methods

Method Summary
CompositeCompressor CreateAggressivePipeline() Creates a composite compressor with an aggressive pipeline for maximum compression.
CompositeCompressor CreateStandardPipeline() Creates a composite compressor with a standard pipeline for general use.
Task<string> CompressAsync(string prompt, CompressionOptions options, CancellationToken cancellationToken) Compresses the prompt asynchronously by applying all compressors in sequence.