All Products
Search
Document Center

Content Moderation:Create a business scenario

Last Updated:Jul 31, 2023

This topic describes how to use Content Moderation SDK for Python to create a business scenario. You can use the business scenario to customize a policy for machine-assisted moderation for the Content Moderation API.

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.

Submit a task to create a business scenario

Operation

Description

Supported region

CreateBizType

Creates a business scenario.

  • cn-shanghai: China (Shanghai)

  • cn-beijing: China (Beijing)

  • cn-shenzhen: China (Shenzhen)

  • ap-southeast-1: Singapore

Sample code

# coding=utf-8

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

# Note: We recommend that you reuse the instantiated client as much as possible. This improves moderation performance and avoids repeated client connections. 
# Common ways to obtain environment variables:
# Obtain the AccessKey ID of your RAM user: os.environ['ALIBABA_CLOUD_ACCESS_KEY_ID']
# Obtain the AccessKey secret of your RAM user: os.environ['ALIBABA_CLOUD_ACCESS_KEY_SECRET']
clt = client.AcsClient("We recommend that you obtain the AccessKey ID of your RAM user from environment variables", "We recommend that you obtain the AccessKey secret of your RAM user from environment variables", "cn-shanghai")
region_provider.modify_point('Green', "cn-shanghai", 'green.cn-shanghai.aliyuncs.com')
request = CreateBizTypeRequest.CreateBizTypeRequest()
# Set the name of the business scenario that you want to create. 
request.set_BizTypeName("Name of the business scenario")
# Import the configuration of an existing business scenario. This parameter is optional. 
request.set_BizTypeImport("Name of an existing business scenario to be imported")
# Specify whether to import the configuration of an industry template. If you set this parameter to true, you must specify the IndustryInfo parameter. This parameter is optional. 
request.set_CiteTemplate(True)
# Specify the industry classification. This parameter is required if you set the CiteTemplate parameter to true. Valid values: Social-Registration information-Profile picture and Social-Registration information-Nickname. 
request.set_IndustryInfo("Social-Registration information-Profile picture")

request.set_accept_format('JSON')

response = clt.do_action_with_exception(request)
print(response)