您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

定义和使用审核作业 (REST)Define and use moderation jobs (REST)

裁决作业作为内容审核、工作流和评论功能的一种包装。A moderation job serves as a kind of wrapper for the functionality of content moderation, workflows and reviews. 本指南演示如何使用作业 REST Api 来启动和检查内容审核作业。This guide shows you how to use the job REST APIs to initiate and check content moderation jobs. 了解 Api 的结构后, 可以轻松地将这些调用移植到任何与 REST 兼容的平台。Once you understand the structure of the APIs, you can easily port these calls to any REST-compatible platform.

先决条件Prerequisites

创建作业Create a job

若要创建审核作业, 请打开 "作业-创建API 引用" 页, 然后选择关键区域的按钮 (可在 "查看工具" 的 "凭据" 页上的 "终结点 URL" 中找到此项)。To create a moderation job, go to the Job - Create API reference page and select the button for your key region (you can find this in the Endpoint URL on the Credentials page of the Review tool). 这会启动 API 控制台, 你可以在其中轻松构造和运行 REST API 调用。This starts the API console, where you can easily construct and run REST API calls.

作业-创建页区域选择

输入 REST 调用参数Enter REST call parameters

输入以下值来构造 REST 调用:Enter the following values to construct the REST call:

  • teamName:设置你的审阅工具帐户时创建的团队 ID (在查看工具的凭据屏幕上的 " ID " 字段中)。teamName: The team ID that you created when you set up your Review tool account (found in the Id field on your Review tool's Credentials screen).
  • ContentType:这可以是 "图像"、"文本" 或 "视频"。ContentType: This can be "Image", "Text", or "Video".
  • ContentId:自定义标识符字符串。ContentId: A custom identifier string. 此字符串将传递给 API,并通过回调返回。This string is passed to the API and returned through the callback. 它可用于将内部标识符或元数据与裁决作业的结果关联起来。It is useful for associating internal identifiers or metadata with the results of a moderation job.
  • Workflowname:之前创建的工作流的名称 (对于默认工作流, 则为 "默认值")。Workflowname: The name of the workflow you previously created (or "default" for the default workflow).
  • CallbackEndpoint:可有可无完成评审后接收回调信息的 URL。CallbackEndpoint: (Optional) The URL to receive callback information when the review is completed.
  • Ocp-Apim-Subscription-Key:内容审查器键。Ocp-Apim-Subscription-Key: Your Content Moderator key. 可以在 "查看" 工具的 "设置" 选项卡上找到。You can find this on the Settings tab of the Review tool.

填写请求正文Fill in the request body

REST 调用的正文包含一个字段ContentValueThe body of your REST call contains one field, ContentValue. 如果你是审查文本, 请粘贴原始文本内容; 如果你审查图像/视频, 请输入图像或视频 URL。Paste in the raw text content if you are moderating text, or enter an image or video URL if you're moderating image/video. 可以使用以下示例图像 URL:https://moderatorsampleimages.blob.core.windows.net/samples/sample2.jpgYou can use the following sample image URL: https://moderatorsampleimages.blob.core.windows.net/samples/sample2.jpg

“作业 - 创建”控制台上的“查询参数”、“请求头”和“请求正文”框

提交请求Submit your request

选择“发送”。Select Send. 如果操作成功, 则响应状态200 OK, "响应内容" 框将显示作业的 ID。If the operation succeeds, the Response status is 200 OK, and the Response content box displays an ID for the job. 复制此 ID,然后在以下步骤中使用它。Copy this ID to use in the following steps.

审查 - 创建控制台响应内容框显示审查 ID

获取作业状态Get job status

若要获取正在运行或已完成的作业的状态和详细信息, 请转到作业-获取API 参考页, 然后选择你的区域 (你的密钥的管理区域) 的按钮。To get the status and details of a running or completed job, go to the Job - Get API reference page and select the button for your region (the region in which your key is administered).

作业-获取区域选择

输入 REST 调用参数, 如以上部分所示。Enter the REST call parameters as in the above section. 对于此步骤, JobId是创建作业时收到的唯一 ID 字符串。For this step, JobId is the unique ID string you received when you created the job. 选择“发送”。Select Send. 如果操作成功, 则响应状态200 OK, "响应内容" 框将显示 JSON 格式的作业, 如下所示:If the operation succeeds, the Response status is 200 OK, and the Response content box displays the job in JSON format, like the following:

{  
  "Id":"2018014caceddebfe9446fab29056fd8d31ffe",
  "TeamName":"some team name",
  "Status":"Complete",
  "WorkflowId":"OCR",
  "Type":"Image",
  "CallBackEndpoint":"",
  "ReviewId":"201801i28fc0f7cbf424447846e509af853ea54",
  "ResultMetaData":[  
    {  
      "Key":"hasText",
      "Value":"True"
    },
    {  
      "Key":"ocrText",
      "Value":"IF WE DID \r\nALL \r\nTHE THINGS \r\nWE ARE \r\nCAPABLE \r\nOF DOING, \r\nWE WOULD \r\nLITERALLY \r\nASTOUND \r\nOURSELVE \r\n"
    }
  ],
  "JobExecutionReport":[  
    {  
      "Ts":"2018-01-07T00:38:29.3238715",
      "Msg":"Posted results to the Callbackendpoint: https://requestb.in/vxke1mvx"
    },
    {  
      "Ts":"2018-01-07T00:38:29.2928416",
      "Msg":"Job marked completed and job content has been removed"
    },
    {  
      "Ts":"2018-01-07T00:38:29.0856472",
      "Msg":"Execution Complete"
    },
    {  
      "Ts":"2018-01-07T00:38:26.7714671",
      "Msg":"Successfully got hasText response from Moderator"
    },
    {  
      "Ts":"2018-01-07T00:38:26.4181346",
      "Msg":"Getting hasText from Moderator"
    },
    {  
      "Ts":"2018-01-07T00:38:25.5122828",
      "Msg":"Starting Execution - Try 1"
    }
  ]
}

作业-获取 REST 调用响应

检查新评审Examine the new review(s)

如果内容作业导致创建评审, 则可以在 "查看" 工具中查看它。If your content job resulted in the creation of a review, you can view it in the Review tool. 选择 "查看 > 图像/文本视频/" (取决于你使用的内容)。Select Review > Image/Text/Video (depending on what content you used). 内容应会显示, 可供人工审阅。The content should appear, ready for human review. 在人审查人员检查自动分配的标记和预测数据并提交最终审核决定之后, 作业 API 会将所有此信息提交到指定的回调终结点终结点。After a human moderator reviews the auto-assigned tags and prediction data and submits a final moderation decision, the jobs API submits all of this information to the designated callback endpoint endpoint.

后续步骤Next steps

在本指南中, 您学习了如何使用 REST API 创建和查询内容裁决作业。In this guide, you learned how to create and query content moderation jobs using the REST API. 接下来, 将作业集成到端到端裁决方案, 如电子商务审核教程。Next, integrate jobs into an end-to-end moderation scenario, such as the E-commerce moderation tutorial.