ContextBuilder class

Builds optimized context for LLM prompts.

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 Properties

debugCompressionRunnerOverride ↔ CompressionRunner?
getter/setter pair
debugTokenCounterOverride ↔ TokenCounter?
getter/setter pair

Static Methods

build({required List<ChunkSearchResult> searchResults, int tokenBudget = 2000, ContextStrategy strategy = ContextStrategy.relevanceFirst, String separator = '\n\n---\n\n', bool singleSourceMode = false}) → AssembledContext
Assemble context from search results within a token budget.
buildWithCompression({required List<ChunkSearchResult> searchResults, int tokenBudget = 2000, ContextStrategy strategy = ContextStrategy.relevanceFirst, int compressionLevel = 1, String language = 'ko', bool singleSourceMode = false}) → Future<AssembledContext>
Build context with REFRAG-style compression.
deriveContextBudgetForPrompt({required int fullPromptBudget, required String query, String? systemInstruction, bool useStrictMode = true, PromptBudgetOptions options = const PromptBudgetOptions()}) → int
Derive how many tokens can be safely assigned to context.text when the downstream consumer budgets the full prompt instead.
formatForPrompt({required String query, required AssembledContext context, String? systemInstruction, bool useStrictMode = true}) → String
Format context for LLM prompt.