Skip to content

Commit c67e562

Browse files
docs
1 parent c781c75 commit c67e562

File tree

1 file changed

+27
-33
lines changed

1 file changed

+27
-33
lines changed

docs/en/latest/plugins/ai-aws-content-moderation.md

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
2-
title: ai-content-moderation
2+
title: ai-aws-content-moderation
33
keywords:
44
- Apache APISIX
55
- API Gateway
66
- Plugin
7-
- ai-content-moderation
8-
description: This document contains information about the Apache APISIX ai-content-moderation Plugin.
7+
- ai-aws-content-moderation
8+
description: This document contains information about the Apache APISIX ai-aws-content-moderation Plugin.
99
---
1010

1111
<!--
@@ -29,23 +29,23 @@ description: This document contains information about the Apache APISIX ai-conte
2929

3030
## Description
3131

32-
The `ai-content-moderation` plugin processes the request body to check for toxicity and rejects the request if it exceeds the configured threshold.
32+
The `ai-aws-content-moderation` plugin processes the request body to check for toxicity and rejects the request if it exceeds the configured threshold.
3333

3434
**_This plugin must be used in routes that proxy requests to LLMs only._**
3535

3636
**_As of now, the plugin only supports the integration with [AWS Comprehend](https://aws.amazon.com/comprehend/) for content moderation. PRs for introducing support for other service providers are welcomed._**
3737

3838
## Plugin Attributes
3939

40-
| **Field** | **Required** | **Type** | **Description** |
41-
| ----------------------------------------- | ------------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
42-
| provider.aws_comprehend.access_key_id | Yes | String | AWS access key ID |
43-
| provider.aws_comprehend.secret_access_key | Yes | String | AWS secret access key |
44-
| provider.aws_comprehend.region | Yes | String | AWS region |
45-
| provider.aws_comprehend.endpoint | No | String | AWS Comprehend service endpoint. Must match the pattern `^https?://` |
46-
| 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). |
47-
| 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 |
48-
| llm_provider | Yes | String | Name of the LLM provider that this route will proxy requests to. |
40+
| **Field** | **Required** | **Type** | **Description** |
41+
| ---------------------------- | ------------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
42+
| comprehend.access_key_id | Yes | String | AWS access key ID |
43+
| comprehend.secret_access_key | Yes | String | AWS secret access key |
44+
| comprehend.region | Yes | String | AWS region |
45+
| comprehend.endpoint | No | String | AWS Comprehend service endpoint. Must match the pattern `^https?://` |
46+
| comprehend.ssl_verify | No | String | Enables SSL certificate verification. |
47+
| 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). |
48+
| 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 |
4949

5050
## Example usage
5151

@@ -58,26 +58,23 @@ SECRET_ACCESS_KEY=aws-comprehend-secret-access-key-here
5858
OPENAI_KEY=open-ai-key-here
5959
```
6060

61-
Create a route with the `ai-content-moderation` and `ai-proxy` plugin like so:
61+
Create a route with the `ai-aws-content-moderation` and `ai-proxy` plugin like so:
6262

6363
```shell
6464
curl "http://127.0.0.1:9180/apisix/admin/routes/1" -X PUT \
6565
-H "X-API-KEY: ${ADMIN_API_KEY}" \
6666
-d '{
6767
"uri": "/post",
6868
"plugins": {
69-
"ai-content-moderation": {
70-
"provider": {
71-
"aws_comprehend": {
72-
"access_key_id": "'"$ACCESS_KEY_ID"'",
73-
"secret_access_key": "'"$SECRET_ACCESS_KEY"'",
74-
"region": "us-east-1"
75-
}
69+
"ai-aws-content-moderation": {
70+
"comprehend": {
71+
"access_key_id": "'"$ACCESS_KEY_ID"'",
72+
"secret_access_key": "'"$SECRET_ACCESS_KEY"'",
73+
"region": "us-east-1"
7674
},
7775
"moderation_categories": {
7876
"PROFANITY": 0.5
79-
},
80-
"llm_provider": "openai"
77+
}
8178
},
8279
"ai-proxy": {
8380
"auth": {
@@ -167,15 +164,12 @@ curl "http://127.0.0.1:9180/apisix/admin/routes/1" -X PUT \
167164
-d '{
168165
"uri": "/post",
169166
"plugins": {
170-
"ai-content-moderation": {
171-
"provider": {
172-
"aws_comprehend": {
173-
"access_key_id": "'"$ACCESS_KEY_ID"'",
174-
"secret_access_key": "'"$SECRET_ACCESS_KEY"'",
175-
"region": "us-east-1"
176-
}
167+
"ai-aws-content-moderation": {
168+
"comprehend": {
169+
"access_key_id": "'"$ACCESS_KEY_ID"'",
170+
"secret_access_key": "'"$SECRET_ACCESS_KEY"'",
171+
"region": "us-east-1"
177172
},
178-
"llm_provider": "openai",
179173
"moderation_categories": {
180174
"PROFANITY": 0.5,
181175
"HARASSMENT_OR_ABUSE": 0.7,
@@ -216,9 +210,9 @@ curl "http://127.0.0.1:9180/apisix/admin/routes/1" -X PUT \
216210
-d '{
217211
"uri": "/post",
218212
"plugins": {
219-
"ai-content-moderation": {
213+
"ai-aws-content-moderation": {
220214
"provider": {
221-
"aws_comprehend": {
215+
"comprehend": {
222216
"access_key_id": "'"$ACCESS_KEY_ID"'",
223217
"secret_access_key": "'"$SECRET_ACCESS_KEY"'",
224218
"region": "us-east-1"

0 commit comments

Comments
 (0)