config
On this page
All configuration dataclasses and enumerations for the router system, centralized so the entire system can be tuned from one RouterConfig object.
Enumerations
SimilarityMetric(str, Enum)
COSINE = "cosine", DOT_PRODUCT = "dot_product", EUCLIDEAN = "euclidean". Consumed by SemanticScorer.
ExecutionMode(str, Enum)
SINGLE = "single", SEQUENTIAL = "sequential", PARALLEL = "parallel". Consumed by ExecutionEngine.execute.
AggregationStrategy(str, Enum)
FIRST_WINS = "first_wins", VOTING = "voting", MERGE = "merge". Consumed at HierarchicalRouter construction time to select an aggregator instance — see the Configuration page for the important caveat that VOTING has no dedicated implementation.
ConfidenceLevel(str, Enum)
HIGH = "high", MEDIUM = "medium", LOW = "low", NONE = "none". Produced by ConfidenceEvaluator.evaluate.
LogLevel(str, Enum)
DEBUG = "DEBUG", INFO = "INFO", WARNING = "WARNING", ERROR = "ERROR". Consumed by RouterLogger.
All enums inherit from both str and Enum, so they compare equal to their string values (e.g. ConfidenceLevel.HIGH == "high" is True) and serialize cleanly with json.dumps when accessed via .value.
Sub-config dataclasses
Each is a plain @dataclass with no methods beyond the generated __init__/__repr__/__eq__. All fields have defaults, so every sub-config is constructible with zero arguments.
RouterConfig
@dataclass
class RouterConfig:
embedding: EmbeddingConfig = field(default_factory=EmbeddingConfig)
scoring: ScoringConfig = field(default_factory=ScoringConfig)
execution: ExecutionConfig = field(default_factory=ExecutionConfig)
cache: CacheConfig = field(default_factory=CacheConfig)
feedback: FeedbackConfig = field(default_factory=FeedbackConfig)
observability: ObservabilityConfig = field(default_factory=ObservabilityConfig)
llm_model: Optional[str] = None
llm_api_key: Optional[str] = None
raise_on_no_match: bool = False
The single entry point passed to HierarchicalRouter(config=...). See Configuration → RouterConfig for the full field table.
Class methods
RouterConfig.fast() -> RouterConfig
Returns a new RouterConfig() with scoring.top_k = 1, execution.mode = ExecutionMode.SINGLE, cache.enabled = True. All other fields remain at their dataclass defaults.
Time complexity: O(1) — constructs a handful of dataclasses.
RouterConfig.accurate() -> RouterConfig
Returns a new RouterConfig() with scoring.top_k = 3, execution.mode = ExecutionMode.PARALLEL, scoring.llm_weight = 0.20, scoring.semantic_weight = 0.60. Note scoring.keyword_weight is left at its default 0.20, so the three scoring weights after calling accurate() are semantic=0.60, keyword=0.20, llm=0.20 before HybridScorer's internal normalization (they already sum to 1.0 here, so normalization is a no-op in this specific preset).
Examples
1. Basic — defaults:
from zerda.router import RouterConfig
config = RouterConfig()
2. Intermediate — partial override:
from zerda.router import RouterConfig, CacheConfig
config = RouterConfig(cache=CacheConfig(enabled=False))
3. Advanced — preset plus override:
config = RouterConfig.accurate()
config.execution.parallel_timeout = 20.0
config.llm_model = "gpt-4o-mini"
config.llm_api_key = "sk-..."
4. Error handling: RouterConfig performs no field validation (e.g. out-of-range thresholds, negative timeouts are accepted silently) — invalid values will surface later as unexpected scoring/execution behavior rather than a constructor-time error. Validate your own config values if they come from user input.
5. Production-ready — environment-driven config:
import os
from zerda.router import RouterConfig, ScoringConfig, ExecutionConfig, ExecutionMode
config = RouterConfig(
scoring=ScoringConfig(top_k=int(os.environ.get("ROUTER_TOP_K", "5"))),
execution=ExecutionConfig(mode=ExecutionMode(os.environ.get("ROUTER_MODE", "single"))),
llm_model=os.environ.get("ROUTER_LLM_MODEL"),
llm_api_key=os.environ.get("OPENAI_API_KEY"),
)
Related APIs: HierarchicalRouter, full field reference on the Configuration page.