membphis commented on code in PR #11541: URL: https://github.com/apache/apisix/pull/11541#discussion_r1774817443
########## docs/en/latest/plugins/ai-content-moderation.md: ########## @@ -0,0 +1,218 @@ +--- +title: ai-content-moderation +keywords: + - Apache APISIX + - API Gateway + - Plugin + - ai-content-moderation +description: This document contains information about the Apache APISIX ai-content-moderation Plugin. +--- + +<!-- +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +--> + +## Description + +The `ai-content-moderation` plugin processes the request body to check for toxicity and rejects the request if it exceeds the configured threshold. + +**_This plugin must be used in routes that proxy requests to LLMs only._** + +## Plugin Attributes + +| **Field** | **Required** | **Type** | **Description** | +| ----------------------------------------- | ------------ | -------- | ---------------------------------------------------------------------------------------------------------------------------------------- | +| provider.aws_comprehend.access_key_id | Yes | String | AWS access key ID | +| provider.aws_comprehend.secret_access_key | Yes | String | AWS secret access key | +| 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 | Configuration for moderation categories. Must be one of: PROFANITY, HATE_SPEECH, INSULT, HARASSMENT_OR_ABUSE, SEXUAL, VIOLENCE_OR_THREAT | +| toxicity_level | No | Number | Threshold for overall toxicity detection. Range: 0 - 1. Default: 0.5 | +| llm_provider | Yes | String | Name of the LLM provider that this route will proxy requests to. | + +## Example usage + +Create a route with the `ai-content-moderation` and `ai-proxy` plugin like so: + +```shell +curl "http://127.0.0.1:9180/apisix/admin/routes/1" -X PUT \ + -H "X-API-KEY: ${ADMIN_API_KEY}" \ + -d '{ + "uri": "/post", + "plugins": { + "ai-content-moderation": { + "provider": { + "aws_comprehend": { Review Comment: I suggest: we add this in the document, We welcome developers to contribute this kind of features. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
