This topic describes how to use Content Moderation SDK for Python to query existing and custom business scenarios. This helps you manage business scenarios.

Prerequisites

  • Python dependencies are installed. For more information, see Installation.
    Note You must use the required Python version described in the Installation topic to install the dependencies. Otherwise, subsequent operation calls fail.
  • The Extension.Uploader utility class is downloaded and imported into your project if you want to submit a local image or a binary image stream for image moderation.

Submit a task to query business scenarios

Operation Description Supported region
DescribeUserBizTypes Queries business scenarios.
  • cn-shanghai: China (Shanghai)
  • cn-beijing: China (Beijing)
  • cn-shenzhen: China (Shenzhen)
  • ap-southeast-1: Singapore (Singapore)

Sample code

# coding=utf-8

from aliyunsdkcore import client
from aliyunsdkcore.profile import region_provider
from aliyunsdkgreen.request.v20170823 import DescribeUserBizTypesRequest

# Use the AccessKey ID and AccessKey secret of your Alibaba Cloud account. 
clt = client.AcsClient("Your AccessKey ID", "Your AccessKey secret", "Region ID")


region_provider.modify_point('Green', regionId, 'green.cn-shanghai.aliyuncs.com')
request = DescribeUserBizTypesRequest.DescribeUserBizTypesRequest()

request.set_accept_format('JSON')

response = clt.do_action_with_exception(request)

'''
Response:
{
    # The list of all business scenarios. 
    "BizTypeList":[
        {
            # Indicates whether an industry template was imported. 
            "CiteTemplate":false,
            # The name of the business scenario. 
            "BizType":"mohongtest2",
            # The source of the business scenario. A value of custom indicates a custom business scenario. A value of system indicates the default business scenario of Content Moderation. 
            "Source":"custom",
            # The industry information. 
            "IndustryInfo":""
        }
    ],
    "RequestId":"ADDBDECA-E1B2-4988-AE3B-956BF51573EC",
    # When you create a business scenario, you can import the configuration of an existing business scenario in the list of queried business scenarios. 
    "BizTypeListImport":[
        {
            "CiteTemplate":false,
            "BizType":"mohongtest2",
            "Source":"custom",
            "IndustryInfo":""
        }
    ]
}

'''

print(response)