RedaktAIDocs

RdaktConfig

Main configuration class for Rdakt AI

RdaktConfig holds all configuration for the middleware. It can be created programmatically or loaded from a YAML file.

Import

from rdakt_ai import RdaktConfig, EntityConfig, SessionConfig, load_config, create_store

RdaktConfig

RdaktConfig(
    mode: Literal["active", "audit"] = "active",
    on_error: Literal["warn_and_forward", "block"] = "warn_and_forward",
    pipeline: list[str | dict[str, Any]] = ["regex"],
    entities: dict[str, EntityConfig] = {},
    session: SessionConfig = SessionConfig(),
)

Fields

FieldTypeDefaultDescription
mode"active" | "audit""active"Execution mode
on_error"warn_and_forward" | "block""warn_and_forward"Error handling policy
pipelinelist[str | dict]["regex"]Detection pipeline stages
entitiesdict[str, EntityConfig]{}Per-entity-type configuration
sessionSessionConfigSessionConfig()Session store configuration

Properties

PropertyTypeDescription
entity_strategiesdict[str, str]Map of entity type to strategy name
custom_patternsdict[str, str]Map of entity type to regex pattern
session_storestrSession store backend name
store_optionsdict[str, Any]Extra options for store constructor

EntityConfig

EntityConfig(
    strategy: Literal["token", "synthetic", "hybrid"] | None = None,
    pattern: str | None = None,
)
FieldTypeDefaultDescription
strategystr | NoneNoneAnonymization strategy for this type
patternstr | NoneNoneCustom regex pattern for this type

SessionConfig

SessionConfig(
    store: Literal["memory", "sqlite", "redis"] = "memory",
    **kwargs,
)
FieldTypeDefaultDescription
storestr"memory"Backend type
Additional fields——Passed to store constructor (e.g., path, url, ttl, prefix)

Properties

PropertyTypeDescription
optionsdict[str, Any]Extra fields passed to store constructor

Functions

load_config

def load_config(path: Path) -> RdaktConfig

Load configuration from a YAML file. Returns defaults if the file is not found.

create_store

def create_store(config: RdaktConfig) -> SessionStore

Create a session store instance from the configuration.

Usage

Programmatic

config = RdaktConfig(
    mode="active",
    on_error="block",
    pipeline=["regex", {"ner": {"model": "en_core_web_sm"}}],
    entities={
        "PERSON": EntityConfig(strategy="synthetic"),
        "EMAIL": EntityConfig(strategy="token"),
    },
    session=SessionConfig(store="sqlite", path="sessions.db"),
)

From YAML

config = load_config("rdakt.yaml")
store = create_store(config)
middleware = RdaktMiddleware(config=config, store=store)

See Also

On this page