Package com.tnsai.rag
Enum Class ChunkContext
- All Implemented Interfaces:
Serializable,Comparable<ChunkContext>,Constable
Opt-in ingest-time transform that prepends chunk context before
embedding and BM25 indexing.
NONE is the default: the indexed text is the chunk body,
and the fingerprint payload carries no extra context fields.
STRUCTURAL prepends provenance the chunker already computed.
LLM prepends a short description from an installed
ChunkContextGenerator.
The prefix is indexed only. The original body is what the model
sees, so the prefix does not consume @Search.contextWindow.
@Knowledge.unit = LINE is rejected: a 50–100 token
preamble on a single line inverts the signal.
- Since:
- 0.15.0
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionPrefix from an installedChunkContextGenerator.No prefix.Deterministic prefix from origin, structural path, and line range. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringMetadata key holding the original chunk body when a prefix is indexed.static final intMaximum length of a structural or generated prefix, in characters (~100 tokens).static final intMaximum characters of adjacent-chunk text passed to an LLM generator as surrounding context. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringmodelVisibleContent(Document document) Returns the model-visible body of a stored document.static StringmodelVisibleContent(String indexedContent, Map<String, ?> metadata) Returns the model-visible chunk body: the stored display body when present, otherwise the indexed content.static ChunkContextReturns the enum constant of this class with the specified name.static ChunkContext[]values()Returns an array containing the constants of this enum class, in the order they are declared.Methods inherited from class java.lang.Enum
compareTo, describeConstable, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
-
Enum Constant Details
-
NONE
No prefix. Indexed text equals the chunk body. -
STRUCTURAL
Deterministic prefix from origin, structural path, and line range. No model call. -
LLM
Prefix from an installedChunkContextGenerator. TnsAI ships none; a missing provider fails ingest rather than publishing a half-contextualised index.
-
-
Field Details
-
DISPLAY_BODY_METADATA_KEY
Metadata key holding the original chunk body when a prefix is indexed. Retrieval output uses this value so the prefix stays index-only.- Since:
- 0.15.0
- See Also:
-
MAX_PREFIX_CHARS
public static final int MAX_PREFIX_CHARSMaximum length of a structural or generated prefix, in characters (~100 tokens). Longer provider output is truncated before indexing.- Since:
- 0.15.0
- See Also:
-
MAX_SURROUNDING_CHARS
public static final int MAX_SURROUNDING_CHARSMaximum characters of adjacent-chunk text passed to an LLM generator as surrounding context.- Since:
- 0.15.0
- See Also:
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
modelVisibleContent
Returns the model-visible chunk body: the stored display body when present, otherwise the indexed content.- Parameters:
indexedContent- text stored for embedding and BM25metadata- ingest metadata, possibly containingDISPLAY_BODY_METADATA_KEY- Returns:
- original body, or
indexedContentwhen none was stored - Since:
- 0.15.0
-
modelVisibleContent
Returns the model-visible body of a stored document.- Parameters:
document- indexed document, possibly carrying a display body- Returns:
- original body, or the indexed content when none was stored
- Since:
- 0.15.0
-