From 81958e4cce8f1db3c9873bfd40df1e6c5868be05 Mon Sep 17 00:00:00 2001 From: Abhishek Choudhary Date: Wed, 9 Oct 2024 11:48:29 +0545 Subject: [PATCH] toxicity_level -> moderation_threshold --- apisix/plugins/ai-content-moderation.lua | 4 ++-- docs/en/latest/plugins/ai-content-moderation.md | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apisix/plugins/ai-content-moderation.lua b/apisix/plugins/ai-content-moderation.lua index 232a3e11b576..19029a65348d 100644 --- a/apisix/plugins/ai-content-moderation.lua +++ b/apisix/plugins/ai-content-moderation.lua @@ -73,7 +73,7 @@ local schema = { }, additionalProperties = false }, - toxicity_level = { + moderation_threshold = { type = "number", minimum = 0, maximum = 1, @@ -170,7 +170,7 @@ function _M.rewrite(conf, ctx) end end - if result.Toxicity > conf.toxicity_level then + if result.Toxicity > conf.moderation_threshold then return HTTP_BAD_REQUEST, "request body exceeds toxicity threshold" end end diff --git a/docs/en/latest/plugins/ai-content-moderation.md b/docs/en/latest/plugins/ai-content-moderation.md index 0ae3a0ce3511..781b203d9130 100644 --- a/docs/en/latest/plugins/ai-content-moderation.md +++ b/docs/en/latest/plugins/ai-content-moderation.md @@ -44,7 +44,7 @@ The `ai-content-moderation` plugin processes the request body to check for toxic | provider.aws_comprehend.region | Yes | String | AWS region | | provider.aws_comprehend.endpoint | No | String | AWS Comprehend service endpoint. Must match the pattern `^https?://` | | moderation_categories | No | Object | Key-value pairs of moderation category and their score. In each pair, the key should be one of the `PROFANITY`, `HATE_SPEECH`, `INSULT`, `HARASSMENT_OR_ABUSE`, `SEXUAL`, or `VIOLENCE_OR_THREAT`; and the value should be between 0 and 1 (inclusive). | -| toxicity_level | No | Number | The degree to which content is harmful, offensive, or inappropriate. A higher value indicates more toxic content allowed. Range: 0 - 1. Default: 0.5 | +| moderation_threshold | No | Number | The degree to which content is harmful, offensive, or inappropriate. A higher value indicates more toxic content allowed. Range: 0 - 1. Default: 0.5 | | llm_provider | Yes | String | Name of the LLM provider that this route will proxy requests to. | ## Example usage @@ -208,7 +208,7 @@ curl "http://127.0.0.1:9180/apisix/admin/routes/1" -X PUT \ ``` If none of the `moderation_categories` are configured, request bodies will be moderated on the basis of overall toxicity. -The default `toxicity_level` is 0.5, it can be configured like so. +The default `moderation_threshold` is 0.5, it can be configured like so. ```shell curl "http://127.0.0.1:9180/apisix/admin/routes/1" -X PUT \ @@ -224,7 +224,7 @@ curl "http://127.0.0.1:9180/apisix/admin/routes/1" -X PUT \ "region": "us-east-1" } }, - "toxicity_level": 0.7, + "moderation_threshold": 0.7, "llm_provider": "openai" }, "ai-proxy": {