Usage
To use the OpenAI Moderation Guardrail, you need to import it and pass it to the Agent with thepre_hooks
parameter:
Moderation model
By default, the OpenAI Moderation Guardrail will use OpenAI’somni-moderation-latest
model.
You can adjust which model is used for moderation by providing the moderation_model
parameter:
Moderation categories
You can specify which categories the guardrail should check for. By default, the guardrail will consider all the existing moderation categories. You can check the list of categories in OpenAI’s docs. You can override the default list of moderation categories using theraise_for_categories
parameter: