PromptCompressor class

Prompt compression service using REFRAG principles.

Phase 1: Rule-based compression (stopwords, duplicates) Phase 2: Similarity-based sentence selection (future)

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

compress({required List<ChunkSearchResult> chunks, CompressionLevel level = CompressionLevel.balanced, int maxTokens = 2000, String language = 'ko'}) Future<CompressedContext>
Compress chunks for LLM context within a token budget.
compressSimple({required String text, CompressionLevel level = CompressionLevel.balanced}) Future<String>
Quick compress a single text string.
compressWithSimilarity({required List<ChunkSearchResult> chunks, required List<double> queryEmbedding, CompressionLevel level = CompressionLevel.balanced, int maxSentences = 15, double minSimilarity = 0.2, String language = 'ko'}) Future<CompressedContext>
Compress with Phase 2 similarity-based selection.
needsCompression({required String text, int tokenThreshold = 2000}) Future<bool>
Check if text needs compression based on token estimate.
scoreSentences({required List<String> sentences, required List<double> queryEmbedding, int topK = 10, double minSimilarity = 0.2}) Future<List<ScoredSentence>>
Select sentences most relevant to the query using embedding similarity.
setEmbeddingService(Future<List<double>> service(String)) → void
Set embedding service instance (call this during app initialization)
splitSentences(String text) Future<List<String>>
Split text into sentences.