Quickstart
After installing Eunomia, you can start using it by following this quickstart example.
Basic PII Replacement
The Orchestra
class is used in Eunomia to orchestrate the execution of multiple instruments on an input text.
The orchestra can be initialized with a list of instruments. In this example, we will start using the PiiInstrument
to identify and replace the PII, specifically the email address and person names.
from eunomia.instruments import PiiInstrument
eunomia = Orchestra(
instruments=[
PiiInstrument(entities=["EMAIL_ADDRESS", "PERSON"], edit_mode="replace"),
]
)
Now, we can run the orchestra with the run
method on any given input text.
Role-based PII Replacement
Let's say that based on the role of the interacting user, the person names inside texts can be either seen or replaced. We can do this by adding the RbacInstrument
to the orchestra, and enforcing the PII replacement only for users with a specific role.
from eunomia.instruments import PiiInstrument, RbacInstrument
eunomia = Orchestra(
instruments=[
PiiInstrument(entities=["EMAIL_ADDRESS"], edit_mode="replace"),
RbacInstrument(
role="specialist",
instruments=[PiiInstrument(entities=["PERSON"], edit_mode="replace")],
),
]
)
Now, we can run the orchestra while interacting with a "specialist"
user.
While, if we interact with a "manager"
user, the person names will not be replaced.
Congratulations! You've just made your first steps with Eunomia. You can continue to the detailed documentation or explore all available instruments.