Generative AI Moderation
- class datarobot.models.moderation.configuration.ModerationConfiguration
Details of overall moderation configuration for a model.
- classmethod get(config_id)
Get a guard configuration by ID.
Added in version v3.6.
- Parameters:
config_id (
str) – ID of the configuration.- Returns:
Retrieved configuration.
- Return type:
- Raises:
datarobot.errors.ClientError – If the server responded with 4xx status.
datarobot.errors.ServerError – If the server responded with 5xx status.
- classmethod list(entity_id, entity_type)
Returns a list of guard configurations.
Added in version v3.6.
- Parameters:
entity_id (
str) – ID of the entity.entity_type (
ModerationGuardEntityType) – Type of the entity.
- Returns:
a list of configurations
- Return type:
List[ModerationConfiguration]- Raises:
datarobot.errors.ClientError – If the server responded with 4xx status.
datarobot.errors.ServerError – If the server responded with 5xx status.
- classmethod create(template_id, name, description, stages, entity_id, entity_type, intervention=None, llm_type=None, deployment_id=None, model_info=None, nemo_info=None, openai_api_key='', openai_api_base='', openai_deployment_id='', openai_credential='')
Create a configuration. This is not a full create from scratch; it’s based on a template.
Added in version v3.6.
- Parameters:
template_id (
str) – ID of the template to base this configuration on.name (
str) – Name of the configuration.description (
str) – Description of the configuration.stages (
List[ModerationGuardStage]) – The stages of moderation where this guard is active.entity_id (
str) – ID of the custom model version or playground this configuration applies to.entity_type (
ModerationGuardEntityType) – Type of the associatedentity_id.llm_type (
Optional[ModerationGuardLlmType]) – The backing LLM this guard uses.nemo_info (
Optional[GuardNemoInfo]) – Additional configuration for NeMo Guardrails guards.model_info (
Optional[GuardModelInfo]) – Additional configuration for guards using a deployed model.intervention (
Optional[GuardInterventionForConfiguration]) – The assessment conditions, and action the guard should take if conditions are met.openai_api_key (
str) – Token to use for OpenAI. Deprecated; useopenai_credentialinstead.openai_api_base (
Optional[str]) – Base of the OpenAI connection.openai_deployment_id (
Optional[str]) – ID of the OpenAI deployment.openai_credential (
Optional[str]) – ID of the credential defined in DataRobot for OpenAI.
- Returns:
Created ModerationConfiguration.
- Return type:
- Raises:
datarobot.errors.ClientError – If the server responded with 4xx status.
datarobot.errors.ServerError – If the server responded with 5xx status.
- update(name=None, description=None, intervention=None, llm_type=None, deployment_id=None, model_info=None, nemo_info=None, openai_api_key='', openai_api_base='', openai_deployment_id='', openai_credential='')
Updates the configuration. All fields are optional, and omitted fields are left unchanged.
entity_id, entity_type, and stages cannot be modified for a guard configuration,.
Added in version v3.6.
- Parameters:
name (
str) – Name of the configuration.description (
str) – Description of the configuration.llm_type (
Optional[ModerationGuardLlmType]) – The backing LLM this guard uses.nemo_info (
Optional[GuardNemoInfo]) – Additional configuration for NeMo Guardrails guards.model_info (
Optional[GuardModelInfo]) – Additional configuration for guards using a deployed model.intervention (
Optional[GuardInterventionForConfiguration]) – The assessment conditions, and action the guard should take if conditions are met.openai_api_key (
str) – Token to use for OpenAI. Deprecated; useopenai_credentialinstead.openai_api_base (
Optional[str]) – Base of the OpenAI connection.openai_deployment_id (
Optional[str]) – ID of the OpenAI deployment.openai_credential (
Optional[str]) – ID of the credential defined in DataRobot for OpenAI.
- Raises:
datarobot.errors.ClientError – If the server responded with 4xx status.
datarobot.errors.ServerError – If the server responded with 5xx status.
- Return type:
None
- refresh()
Updates the moderation configuration with the latest data from server.
Added in version v3.6.
- Raises:
datarobot.errors.ClientError – If the server responded with 4xx status.
datarobot.errors.ServerError – If the server responded with 5xx status.
- Return type:
None
- delete()
Deletes the configuration.
Added in version v3.6.
- Raises:
datarobot.errors.ClientError – If the server responded with 4xx status.
datarobot.errors.ServerError – If the server responded with 5xx status.
- Return type:
None
- class datarobot.models.moderation.intervention.GuardInterventionCondition
Defines a condition for intervention.
- class datarobot.models.moderation.intervention.GuardInterventionForTemplate
Defines the intervention conditions and actions a guard can take. Configuration schema differs slightly from template because changes were requested after templates were baked in.
- classmethod ensure_object(maybe_dict)
Intervention may arrive as an object, or as a dict. Return an object.
- Return type:
- class datarobot.models.moderation.intervention.GuardInterventionForConfiguration
Defines the intervention conditions and actions a guard can take. Configuration schema differs slightly from template because changes were requested after templates were baked in.
- classmethod ensure_object(maybe_dict)
Intervention may arrive as an object, or as a dict. Return an object.
- Return type:
- class datarobot.models.moderation.model_info.GuardModelInfo
Model information for moderation templates and configurations. Omitted optional values are stored and presented as: * [] (for class names) * None (all others)
- to_dict()
Convert the model information object to a dictionary.
- Return type:
Dict[str,Union[str,List[str],None]]
- classmethod ensure_object(maybe_dict)
Model info may arrive as an object, or as a dict. Return an object.
- Return type:
- class datarobot.models.moderation.model_version_update.ModelVersionUpdate
Implements the save-configuration operation from the moderation UI. All guard configurations and overall config is saved to a new custom model version.
- classmethod new_custom_model_version_with_config(custom_model_id, overall_config, configs)
Create a new custom model version with the provided moderation configuration :type custom_model_id:
str:param custom_model_id: :type overall_config:OverallModerationConfig:param overall_config: :type configs:List[ModerationConfiguration] :param configs:- Return type:
IDofthe new custom model version.
- class datarobot.models.moderation.nemo_info.GuardNemoInfo
Details of a NeMo Guardrails moderation guard.
- class datarobot.models.moderation.overall.OverallModerationConfig
Details of overall moderation configuration for a model.
- classmethod find(entity_id, entity_type)
Find overall configuration by entity ID and entity type. Each entity (such as a customModelVersion) may have at most 1 overall moderation configuration.
Added in version v3.6.
- Parameters:
entity_id (
str) – ID of the entity.entity_type (
str) – Type of the entity.
- Returns:
an OverallModerationConfig or None
- Return type:
Optional[OverallModerationConfig]- Raises:
datarobot.errors.ClientError – If the server responded with 4xx status.
datarobot.errors.ServerError – If the server responded with 5xx status.
- classmethod locate(entity_id, entity_type)
Find overall configuration by entity ID and entity type. This version of find() expects the object to exist. Its return type is not optional.
Added in version v3.6.
- Parameters:
entity_id (
str) – ID of the entity.entity_type (
str) – Type of the entity.
- Returns:
a list of OverallModerationConfig
- Return type:
List[OverallModerationConfig]- Raises:
datarobot.errors.ClientError – If the server responded with 4xx status.
datarobot.errors.ServerError – If the server responded with 5xx status.
- classmethod create(timeout_sec, timeout_action, entity_id, entity_type)
Create an OverallModerationConfig.
Added in version v3.6.
- Parameters:
timeout_sec (
int) – How long to wait for all moderation tasks in a phase to complete.timeout_action (
ModerationTimeoutActionType) – What to do if moderation times out.entity_id (
str) – Entity, such as customModelVersion, that this configuration applies to.entity_type (
ModerationGuardEntityType) – Type of the entity defined byentity_id.
- Returns:
created OverallModerationConfig
- Return type:
- Raises:
datarobot.errors.ClientError – If the server responded with 4xx status.
datarobot.errors.ServerError – If the server responded with 5xx status.
- update(timeout_sec, timeout_action, entity_id, entity_type)
Update an OverallModerationConfig.
Added in version v3.6.
- Parameters:
timeout_sec (
int) – How long to wait for all moderation tasks in a phase to complete.timeout_action (
ModerationTimeoutActionType) – What to do if moderation times out.entity_id (
str) – Entity, such as customModelVersion, that this configuration applies to.entity_type (
ModerationGuardEntityType) – Type of the entity defined byentity_id.
- Returns:
created OverallModerationConfig
- Return type:
- Raises:
datarobot.errors.ClientError – If the server responded with 4xx status.
datarobot.errors.ServerError – If the server responded with 5xx status.
- refresh()
Updates the overall moderation configuration with the latest data from server.
Added in version v3.6.
- Raises:
datarobot.errors.ClientError – If the server responded with 4xx status.
datarobot.errors.ServerError – If the server responded with 5xx status.
- Return type:
None
- class datarobot.models.moderation.template.ModerationTemplate
A DataRobot Moderation Template.
Added in version v3.6.
- Variables:
id (
str) – The ID of the template.name (
str) – The name of the template.
- classmethod get(template_id)
Returns the template by ID.
Added in version v3.6.
- Parameters:
template_id (
str) – The ID of the template.- Returns:
The retrieved template.
- Return type:
- Raises:
datarobot.errors.ClientError – If the server responded with 4xx status.
datarobot.errors.ServerError – If the server responded with 5xx status.
- classmethod list(include_agentic=None, is_agentic=None, for_playground=None, for_production=None, name=None)
Returns a list of templates.
Added in version v3.6.
- Parameters:
yet (none)
- Returns:
A list of templates.
- Return type:
List[ModerationTemplate]- Raises:
datarobot.errors.ClientError – If the server responded with 4xx status.
datarobot.errors.ServerError – If the server responded with 5xx status.
- classmethod find(name)
Finds the template by name.
Added in version v3.6.
- Parameters:
name (
str) – The name of the template.- Returns:
The matching template, or
Noneif no template is found.- Return type:
- Raises:
datarobot.errors.ClientError – If the server responded with 4xx status.
datarobot.errors.ServerError – If the server responded with 5xx status.
- classmethod create(name, description, type, allowed_stages, intervention=None, ootb_type=None, llm_type=None, model_info=None, nemo_info=None)
Creates a template.
Added in version v3.6.
- Parameters:
name (
str) – The name of the template.description (
str) – The description of the template.type (
GuardType) – The type of the template.allowed_stages (
List[ModerationGuardStage]) – The stages of moderation where this guard may be used.ootb_type (
ModerationGuardOotbType) – For guards of typeootb, the specific Out of the Box metric type.llm_type (
Optional[ModerationGuardLlmType]) – The backing LLM this guard uses.nemo_info (
Optional[GuardNemoInfo]) – Additional configuration for NeMo Guardrails guards.model_info (
Optional[GuardModelInfo]) – Additional configuration for guards using a deployed model.intervention (
Optional[GuardInterventionForTemplate]) – The assessment conditions and action the guard should take if conditions are met.
- Returns:
The created template.
- Return type:
- Raises:
datarobot.errors.ClientError – If the server responded with 4xx status.
datarobot.errors.ServerError – If the server responded with 5xx status.
- update(name=None, description=None, type=None, allowed_stages=None, intervention=None, ootb_type=None, llm_type=None, model_info=None, nemo_info=None)
Updates the template. All fields are optional, and omitted fields are left unchanged.
Added in version v3.6.
- Parameters:
name (
str) – The name of the template.description (
str) – The description of the template.type (
GuardType) – The type of the template.allowed_stages (
List[ModerationGuardStage]) – The stages of moderation where this guard may be used.ootb_type (
ModerationGuardOotbType) – For guards of typeootb, the specific Out of the Box metric type.llm_type (
Optional[ModerationGuardLlmType]) – The backing LLM this guard uses.nemo_info (
Optional[GuardNemoInfo]) – Additional configuration for NeMo Guardrails guards.model_info (
Optional[GuardModelInfo]) – Additional configuration for guards using a deployed model.intervention (
Optional[GuardInterventionForTemplate]) – The assessment conditions and action the guard should take if conditions are met.
- Raises:
datarobot.errors.ClientError – If the server responded with 4xx status.
datarobot.errors.ServerError – If the server responded with 5xx status.
- Return type:
None
- refresh()
Updates the template with the latest data from the server.
Added in version v3.6.
- Raises:
datarobot.errors.ClientError – If the server responded with 4xx status.
datarobot.errors.ServerError – If the server responded with 5xx status.
- Return type:
None
- delete()
Deletes the template.
Added in version v3.6.
- Raises:
datarobot.errors.ClientError – If the server responded with 4xx status.
datarobot.errors.ServerError – If the server responded with 5xx status.
- Return type:
None
- class datarobot.enums.ModerationGuardOotbType
Defines the available OOTB guards.