ContextCompressor

Compresses source text to extract only the portions relevant to entity resolution.

Instead of passing entire conversations or documents to LLM calls, this extracts snippets around entity mentions to reduce token usage while preserving disambiguation context.

Example:

Full context (500 tokens):
"Hello! How are you today? I've been listening to a lot of music lately.
Speaking of which, I really love Brahms. His symphonies are incredible,
especially the Fourth. The way he develops themes... [300 more tokens]"

Compressed (50 tokens):
"...I really love Brahms. His symphonies are incredible, especially the Fourth..."

Inheritors

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
abstract fun compress(sourceText: String?, entityName: String): String?

Compress source text to extract relevant context for entity resolution.

Link copied to clipboard
open fun compressForAll(sourceText: String?, entityNames: List<String>): String?

Compress source text for multiple entities at once. May be more efficient than calling compress repeatedly.