RdaktPipeline
Composable detection pipeline with stage chaining
Orchestrates detection by running a chain of stages and resolving overlapping entity detections.
Import
from rdakt_ai import RdaktPipeline, RdaktStage, DetectorStageRdaktPipeline
Constructor
RdaktPipeline(*, stages: list[RdaktStage])| Parameter | Type | Description |
|---|---|---|
stages | list[RdaktStage] | Pipeline stages to execute in order |
Methods
detect (async)
async def detect(self, text: str) -> list[Entity]Run all stages and return resolved (non-overlapping) entities.
detect_sync
def detect_sync(self, text: str) -> list[Entity]Synchronous version of detect.
RdaktStage
Abstract base class for pipeline stages.
Abstract Methods
async def process(self, text: str, context: RdaktContext, call_next: CallNext) -> None: ...
def process_sync(self, text: str, context: RdaktContext, call_next_sync: CallNextSync) -> None: ...DetectorStage
Wraps a Detector into a pipeline stage.
Constructor
DetectorStage(detector: Detector)| Parameter | Type | Description |
|---|---|---|
detector | Detector | Any object implementing the Detector protocol |
Usage
from rdakt_ai import RdaktPipeline, DetectorStage, RegexDetector
# Single detector
pipeline = RdaktPipeline(stages=[
DetectorStage(RegexDetector()),
])
entities = pipeline.detect_sync("Email me at john@example.com")
# Multiple detectors
from rdakt_ai import SpacyDetector
pipeline = RdaktPipeline(stages=[
DetectorStage(RegexDetector()),
DetectorStage(SpacyDetector()),
])
entities = await pipeline.detect("John Smith's email is john@example.com")
# Both regex and NER results, overlaps resolved automaticallyOverlap Resolution
When multiple stages detect overlapping entities:
- Longest match wins — the entity spanning more characters takes priority
- Priority tiebreaker — if spans are equal, the detector with higher
detector_prioritywins
Aliases
For backwards compatibility:
RegexStage = DetectorStage # Alias
NerStage = DetectorStage # AliasSee Also
- Detection Pipeline — concept overview
- Custom Detectors — building custom stages