Moderation (Text)
This section provides an example of how to use Postman to call Moderation (Text), helping you quickly get familiar with the service. The procedure is as follows:
- Subscribe to Moderation (Text) on the Content Moderation console.
- Configure allowlist and blocklist dictionaries.
- Configure an environment. Import the prepared configuration file into the development environment.
- Use a token for authentication. When you call an API, a token is required for authentication.
- Call the service API and view the status code and error code whenever necessary.
- (Optional) View call statistics and call details.
Subscribing to the Service
Subscribe to Moderation (Text) by following the instructions in Subscribing to the Service.
Configuring Custom Dictionaries
You can configure allowlist and blocklist dictionaries for text moderation.
For details, see .
Using a Token for Authentication
- On the Postman page, choose New > Collection, set the name, and click Create to create a collection.
- Right-click the created collection and select Add Request from the shortcut menu. Set the request name and click Save.
- Change the request mode to POST and enter the URL.
For example, if your region is ap-southeast-1, set the URL to https://iam.ap-southeast-1.myhuaweicloud.com/v3/auth/tokens.
- On the Headers page, set KEY to Content-Type and VALUE to application/json.
- Click Body, select raw, and enter the following code in the blank area.
Figure 1 Token-based authentication
Replace username, ******** (login password), domainname, and project name (region where the service is deployed) with the actual values. To obtain the values of these parameters, log in to the management console and click My Credentials.
The region where Content Moderation is deployed must be the same as the region where you call the service. In this example, the region is ap-southeast-1.
{ "auth": { "identity": { "methods": [ "password" ], "password": { "user": { "name": "username", "password": "**********", "domain": { "name": "domainname" } } } }, "scope": { "project": { "name": "ap-southeast-1" } } } }
- Click Send in the upper right corner to send the request. Obtain the token from the returned result. The token is valid for 24 hours.
Calling a Service
- In the Collections directory in the navigation pane of Postman, click the Moderation_text configuration file.
- Click Headers and copy the token value to X-Auth-Token.
Figure 2 Entering the token
- Click Body and enter the text to be checked for the text parameter.
- For details about other parameters in the body, see the Text Moderation API.
Figure 3 Modifying the parameters
- For details about other parameters in the body, see the Text Moderation API.
- Click Send to send the request and obtain the API call results.
{ "request_id": "065561ff4bba1af6dd63a27c5c1371de", "result": { "details": [], "label": "normal", "suggestion": "pass" } }
(Optional) Viewing the Number of Calls
- Log in to the Content Moderation management console.
- In the left navigation pane, choose Content Moderation V3 > Identification Statistics. On the Text Moderation page, you can view the identification statistics. You can set a time range and select a policy (event type) to view the change of the number of API calls within the time range.
- Identification Statistics: total number of calls to Content Moderation, number of rejected calls, number of suspected calls, and number of passed calls within a specified period of time, helping you better learn the calls and moderation status of Content Moderation.
- Total: total number of calls made to Content Moderation
- Rejected: number of calls made to Content Moderation that are rejected because the text contains sensitive information
- Suspected: number of calls made to Content Moderation that require manual review
- Passed: number of calls made to Content Moderation that are approved
- Data Trend: trend of the total number of calls, number of rejected calls, number of suspected calls, and number of passed calls within the specified period of time
- Causes of Rejected Data: proportion of detection scenarios that fail to pass the review within the specified period of time
- Causes of Suspected Data: proportion of detection scenarios that require manual review within the specified period of time
- Identification Statistics: total number of calls to Content Moderation, number of rejected calls, number of suspected calls, and number of passed calls within a specified period of time, helping you better learn the calls and moderation status of Content Moderation.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot