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.
from rdakt_ai import RdaktConfig, EntityConfig, SessionConfig, load_config, create_store
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(),
)
| Field | Type | Default | Description |
|---|
mode | "active" | "audit" | "active" | Execution mode |
on_error | "warn_and_forward" | "block" | "warn_and_forward" | Error handling policy |
pipeline | list[str | dict] | ["regex"] | Detection pipeline stages |
entities | dict[str, EntityConfig] | {} | Per-entity-type configuration |
session | SessionConfig | SessionConfig() | Session store configuration |
| Property | Type | Description |
|---|
entity_strategies | dict[str, str] | Map of entity type to strategy name |
custom_patterns | dict[str, str] | Map of entity type to regex pattern |
session_store | str | Session store backend name |
store_options | dict[str, Any] | Extra options for store constructor |
EntityConfig(
strategy: Literal["token", "synthetic", "hybrid"] | None = None,
pattern: str | None = None,
)
| Field | Type | Default | Description |
|---|
strategy | str | None | None | Anonymization strategy for this type |
pattern | str | None | None | Custom regex pattern for this type |
SessionConfig(
store: Literal["memory", "sqlite", "redis"] = "memory",
**kwargs,
)
| Field | Type | Default | Description |
|---|
store | str | "memory" | Backend type |
| Additional fields | — | — | Passed to store constructor (e.g., path, url, ttl, prefix) |
| Property | Type | Description |
|---|
options | dict[str, Any] | Extra fields passed to store constructor |
def load_config(path: Path) -> RdaktConfig
Load configuration from a YAML file. Returns defaults if the file is not found.
def create_store(config: RdaktConfig) -> SessionStore
Create a session store instance from the configuration.
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"),
)
config = load_config("rdakt.yaml")
store = create_store(config)
middleware = RdaktMiddleware(config=config, store=store)