Skip to content

RBAC Instrument

RbacInstrument is an instrument that implements a role-based access control (RBAC) on input documents. RBAC allows to specify different instruments for each role, creating an orchestra for each role.

Configuration

Argument Type Description
role str The role to apply the RBAC to
instruments list[Instrument] The instruments to apply to the role

Usage Example

examples/role_based_pii.py
from eunomia.instruments import PiiInstrument, RbacInstrument
from eunomia.orchestra import Orchestra

eunomia = Orchestra(
    instruments=[
        PiiInstrument(entities=["EMAIL_ADDRESS"], edit_mode="replace"),
        RbacInstrument(
            role="specialist",
            instruments=[PiiInstrument(entities=["PERSON"], edit_mode="replace")],
        ),
    ]
)

text_original = "Hello, my name is John Doe and my email is john.doe@example.com."

text_edited_specialist = eunomia.run(text_original, role="specialist")
text_edited_manager = eunomia.run(text_original, role="manager")

print("Specialist:", text_edited_specialist)
print("Manager:", text_edited_manager)