Skip to main content

Module context_builder

Module context_builder 

Source
Expand description

Context building for graph-based RAG.

Extracts N-hop subgraph neighborhoods, retrieves entity connections, filters by predicate, ranks triples by relevance, truncates to a token budget, formats structured context from templates, merges multi-entity contexts, and deduplicates redundant triples.

Structsยง

BuiltContext
Built context ready for LLM consumption.
ContextBuilder
Builds LLM context from a knowledge graph by extracting relevant subgraphs.
ContextBuilderConfig
Configuration for the context builder.
ContextTriple
A single RDF-like triple used as context.
KnowledgeGraph
A simple in-memory knowledge graph for context extraction.
ScoredTriple
A scored triple (used during ranking).