LLMSummarizationCompressor
Models & Types · AiDotNet.PromptEngineering.Compression
Compressor that uses an LLM to intelligently summarize and compress prompts.
Inheritance: PromptCompressorBase → LLMSummarizationCompressor
For Beginners
Uses AI to make your prompt shorter while keeping the meaning.
Example:
When to use:
- For complex prompts where simple pattern matching won’t work
- When semantic understanding is required
- When maximum compression with preserved meaning is needed
How It Works
This compressor delegates compression to a language model, which can understand context and produce semantically equivalent but shorter versions of prompts. It’s the most intelligent form of compression but requires an LLM call.
Constructors
| Constructor | Summary |
|---|---|
LLMSummarizationCompressor(Func<string, CancellationToken, Task<string>> summarizeFunc, string systemPrompt, Func<string, int> tokenCounter) |
Initializes a new instance of the LLMSummarizationCompressor class. |
Properties
| Property | Summary |
|---|---|
string SystemPrompt { get; } |
Gets the compression prompt template. |
Methods
| Method | Summary |
|---|---|
Task<string> CompressAsync(string prompt, CompressionOptions options, CancellationToken cancellationToken) |
Compresses the prompt asynchronously using the LLM. |