RedaktAIDocs

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, DetectorStage

RdaktPipeline

Constructor

RdaktPipeline(*, stages: list[RdaktStage])
ParameterTypeDescription
stageslist[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)
ParameterTypeDescription
detectorDetectorAny 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 automatically

Overlap Resolution

When multiple stages detect overlapping entities:

  1. Longest match wins — the entity spanning more characters takes priority
  2. Priority tiebreaker — if spans are equal, the detector with higher detector_priority wins

Aliases

For backwards compatibility:

RegexStage = DetectorStage  # Alias
NerStage = DetectorStage    # Alias

See Also

On this page