nemoguardrails.library.gcp_moderate_text.actions

View as Markdown

Module Contents

Functions

NameDescription
_gcp_text_moderation_outcome-
_gcp_text_simple_blocked-
_gcp_text_triggered_violation-
call_gcp_text_moderation_apiApplication Default Credentials (ADC) is a strategy used by the GCP authentication libraries to automatically

Data

GCP_TEXT_DETAILED_THRESHOLDS

log

API

nemoguardrails.library.gcp_moderate_text.actions._gcp_text_moderation_outcome(
max_risk_score: float,
violations: dict[str, float],
threshold_mode: typing.Literal['simple', 'detailed'] = 'simple'
) -> nemoguardrails.actions.rail_outcome.RailOutcome
nemoguardrails.library.gcp_moderate_text.actions._gcp_text_simple_blocked(
max_risk_score: float
) -> bool
nemoguardrails.library.gcp_moderate_text.actions._gcp_text_triggered_violation(
violations: dict[str, float]
) -> typing.Optional[str]
nemoguardrails.library.gcp_moderate_text.actions.call_gcp_text_moderation_api(
context: typing.Optional[dict] = None,
user_message: typing.Optional[str] = None,
threshold_mode: typing.Literal['simple', 'detailed'] = 'simple',
kwargs = {}
) -> nemoguardrails.actions.rail_outcome.RailOutcome
async

Application Default Credentials (ADC) is a strategy used by the GCP authentication libraries to automatically find credentials based on the application environment. ADC searches for credentials in the following locations (Search order):

  1. GOOGLE_APPLICATION_CREDENTIALS environment variable
  2. User credentials set up by using the Google Cloud CLI
  3. The attached service account, returned by the metadata server

For more information check https://cloud.google.com/docs/authentication/application-default-credentials

nemoguardrails.library.gcp_moderate_text.actions.GCP_TEXT_DETAILED_THRESHOLDS = {'Toxic': 0.8, 'Insult': 0.7, 'Profanity': 0.6, 'Derogatory': 0.4, 'Violent': 0....
nemoguardrails.library.gcp_moderate_text.actions.log = logging.getLogger(__name__)