API Overview

On this page

Package exports

Everything below is exported from the package root (context/__init__'s __all__). Click through to the module page for full details.

Configuration

ContextEngineConfig, ContextConfig, QueryAnalyzerConfig, RetrieverConfig, FilterConfig, RankingConfig, ComposerConfig, GuardConfig, CacheConfig, LengthCounter — see config

Models

QueryAnalysis, QueryIntent, QueryComplexity, RetrievalMethod, SourceQuality, ScoredChunk, ContextResult, ConversationTurn, ConversationHistory, chunk_metadata_dict — see models

Strategy interfaces (abstract base classes)

DeduplicationStrategy, RankingStrategy, CompressionStrategy, BudgetAllocationStrategy, QueryAnalyzerStrategy, ChunkFilterStrategy, ChunkRankingStrategy, ContextComposerStrategy, ContextGuardStrategy, HybridRetrieverStrategy — see strategy

Query analysis

RuleBasedQueryAnalyzer, build_query_analyzer — see query_analyzer

Retrieval

BM25Scorer, VectorRetriever, KeywordRetriever, MetadataRetriever, HybridRetriever — see retriever

Pipeline (filter / rank / compose)

char_counter, make_token_counter, ChunkFilter, CompositeRanker, SmartContextComposer — see pipeline

Guard, learning, cache, budget allocation

ContextGuard, AdaptiveLearningSystem, ContextCache, EqualBudgetAllocation, WeightedBudgetAllocation, ComplexityBasedAllocation — see guard_and_learning

Main engine

ContextEngine, ContextManager — see engine

Legacy compatibility (not in __all__, but importable)

validate_chunk, PrefixDeduplication, HashDeduplication, GreedyCompression, ScoreRanking — see legacy_compat

API summary table

APITypeModuleDescription
ContextEngineClassengineMain pipeline orchestrator — index(chunks, ...) and index_documents(texts, chunker, ...)
ContextManagerClassengineBackward-compatible subclass of ContextEngine
ContextEngineConfig / ContextConfigDataclassconfigRoot configuration object
QueryAnalyzerConfigDataclassconfigQuery analyzer settings
RetrieverConfigDataclassconfigRetriever weights/toggles
FilterConfigDataclassconfigChunk filtering settings
RankingConfigDataclassconfigRanking weights
ComposerConfigDataclassconfigContext composition settings
GuardConfigDataclassconfigGuard thresholds/toggles
CacheConfigDataclassconfigLRU cache settings
QueryAnalysisDataclassmodelsResult of analyzing one query
ScoredChunkDataclassmodelsUnified wrapper around any chunk object
ContextResultDataclassmodelsFinal output of ContextEngine.run()
ConversationTurnDataclassmodelsOne Q/A turn
ConversationHistoryDataclassmodelsMulti-turn conversation state
chunk_metadata_dictFunctionmodelsNormalizes a chunk's metadata (dict or ChunkMetadata dataclass) into a plain dict
QueryIntentEnummodels7-value intent classification
QueryComplexityEnummodels3-value complexity classification
RetrievalMethodEnummodels4-value retrieval method tag
SourceQualityEnummodels4-value source quality tag
RuleBasedQueryAnalyzerClassquery_analyzerDefault QueryAnalyzerStrategy implementation
build_query_analyzerFunctionquery_analyzerFactory for query analyzers
BM25ScorerClassretrieverDependency-free BM25 keyword scorer
VectorRetrieverClassretrieverNative zerda.vector_database-backed, external-adapter-backed, or in-memory semantic retrieval
KeywordRetrieverClassretrieverBM25-based retrieval
MetadataRetrieverClassretrieverPure metadata-filter retrieval
HybridRetrieverClassretrieverCombines the above three via RRF + weighted scoring
ChunkFilterClasspipelineNoise/length/dedup filtering
CompositeRankerClasspipelineMulti-factor composite scoring and ranking
SmartContextComposerClasspipelineTemplate-based context assembly under budget
ContextTemplateClasspipelineFormatting template (not exported at package root)
char_counterFunctionpipelineCharacter-based LengthCounter
make_token_counterFunctionpipelineBuilds a tokenizer-based LengthCounter
ContextGuardClassguard_and_learningContext validation
AdaptiveLearningSystemClassguard_and_learningRolling-window usage stats + budget suggestion
ContextCacheClassguard_and_learningIn-memory LRU+TTL cache
EqualBudgetAllocationClassguard_and_learningEqual split of a multi-query budget
WeightedBudgetAllocationClassguard_and_learningWeighted split of a multi-query budget
ComplexityBasedAllocationClassguard_and_learningComplexity-weighted split of a multi-query budget
validate_chunkFunctionlegacy_compatRaises TypeError on malformed legacy chunks
PrefixDeduplicationClasslegacy_compatLegacy prefix-based dedup
HashDeduplicationClasslegacy_compatLegacy SHA-256 dedup
ScoreRankingClasslegacy_compatLegacy score-sort ranking
GreedyCompressionClasslegacy_compatLegacy greedy context compression

Back to docs home · Architecture · Configuration

Related pages