Giter Site home page Giter Site logo

firestore-perspective-toxicity's Introduction

Analyze Comment Toxicity with Perspective API

Author: Jigsaw (https://jigsaw.google.com)

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


🧩 Install this extension

Console

Install this extension in your Firebase project

Firebase CLI

firebase ext:install jigsaw/firestore-perspective-toxicity --project=<your-project-id>

Learn more about installing extensions in the Firebase Extensions documentation: console, CLI


Details: 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 free 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 free tier of usage. Learn more about Firebase billing.

Configuration Parameters:

  • Cloud Functions location: Where do you want to deploy the functions created for this extension? You usually want a location close to your database. For help selecting a location, refer to the location selection guide.

  • Perspective API Key: What is the API key that will be used to call Perspective API?

  • Attributes to receive scores for: The Perspective API predicts the perceived impact a comment may have on a conversation by evaluating that comment across a range of emotional concepts, called attributes. For help selecting which to receive scores for, see the list of available attributes.

  • Collection path: What is the path to the collection that contains the comments you want to analyze?

  • Input field name: What is the name of the field that contains the comment you want to analyze?

  • Output field name: What is the name of the field where you want to store the output attribute scores?

  • doNotStore flag value: Whether or not Perspective API is permitted to store the comment that gets sent in the request (the contents of the input field). Stored comments will be used to improve the API over time. NOTE: This should be set to true if data being submitted is private (i.e. not publicly accessible) or contains content written by someone under 13 years old.

Cloud Functions:

  • fsAnalyzeCommentsOnCreate: Listens for new comments in your specified Cloud Firestore collection, runs toxicity analysis, then writes the results back to the same document.

  • fsAnalyzeCommentsOnUpdate: Listens for updates to comments in your specified Cloud Firestore collection, runs toxicity analysis, then writes the results back to the same document.

Access Required:

This extension will operate with the following project IAM roles:

  • datastore.user (Reason: Allows the extension to write comment analysis results to Cloud Firestore.)

firestore-perspective-toxicity's People

Contributors

asanusi-google avatar dslucas avatar i14h avatar nauthadr avatar reemaka avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.