您现在访问的是微软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:这可以是"Image"、"Text"或"视频"。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:以前创建的工作流 (或"default"的默认工作流) 的名称。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).

作业-Get 区域选择

输入 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 调用响应

检查新 review(s)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.