Google 致力于为黑人社区推动种族平等。查看具体举措

Analyze Toxicity with Perspective API

Jigsaw
Made by Jigsaw

Analyze the perceived impact a comment might have on a conversation using Perspective API.

此扩展程序的运作方式

Use this extension to get toxicity scores from Perspective API for comments written to a Cloud Firestore collection.

This extension runs Perspective API on the text field and collection you configure. The API uses machine learning models to score the perceived impact a comment might have on a conversation by evaluating that comment across a range of emotional concepts, called attributes. When you install this extension, you will specify the attributes you want to receive scores for. Perspective's main attribute is TOXICITY, defined as "a rude, disrespectful, or unreasonable comment that is likely to make you leave a discussion". See a list of all available attributes on our developer site. Scores are retrieved when a new document is added to your collection or an existing document is modified.

Additional setup

Before you can use this extension, you will need to enable Perspective API. Follow the instructions on our Get Started page to request API access and then enable the API and create an API key.

By default, you're granted quota for 1 query per second (QPS) to Perspective API. For additional QPS, fill out a quota increase request as needed.

Note: If you add or update documents at a rate higher than your allotted QPS, you may exceed quota and the extension will fail to score your documents.

Billing

Perspective API is no-cost for all amounts of quota. However, the extension uses Firebase and Google Cloud Platform services which may have associated charges, including:

  • Cloud Firestore
  • Cloud Functions

When you use Firebase Extensions, you're only charged for the underlying resources that you use. A paid-tier billing plan is only required if the extension uses a service that requires a paid-tier plan, for example calling to a Google Cloud API or making outbound network requests to non-Google services. All Firebase services offer a no-cost tier of usage. Learn more about Firebase billing.

如何安装此扩展程序

使用 Firebase 控制台

要安装和管理扩展程序,您可以使用 Firebase 控制台。

使用控制台安装

使用 Firebase CLI

要安装和管理扩展程序,您还可以使用 Firebase CLI:

步骤 1:运行以下 npm 命令来安装 CLI 或将 CLI 更新到最新版本。

npm install -g firebase-tools
不能运行?请参阅 Firebase CLI 参考文档或者更改您的 npm 权限

第 2 步设置一个新的 Firebase 项目目录或转到现有目录

第 3 步:将此扩展程序添加到扩展程序清单

firebase ext:install jigsaw/firestore-perspective-toxicity --local --project=projectId_or_alias

第 4 步(可选):使用 Firebase Emulator Suite 在本地测试此扩展程序

firebase emulators:start

第 5 步:将清单中的扩展程序部署到项目中

firebase deploy --only extensions --project=projectId_or_alias
支持
Cloud Firestore
作者
许可
Apache-2.0
版本
0.1.5