0.4.4 • Published 10 months ago

@joliegg/moderation v0.4.4

Weekly downloads
-
License
HL3-CL
Repository
-
Last release
10 months ago

Hippocratic License HL3-CL

Chat Moderation

This library uses AWS Rekognition to generate moderation tags for images and Google's Language and Speech libraries to moderate text and audio files.

Installation

yarn add @joliegg/moderation

Initialization

import ModerationClient from '@joliegg/moderation';

const { AWS_REGION, AWS_ACCESS_KEY_ID, AWS_ACCESS_KEY_SECRET, GOOGLE_APPLICATION_CREDENTIALS, GOOGLE_API_KEY } = process.env;

const client = new ModerationClient({
  aws: {
    region: AWS_REGION,
    credentials: {
      accessKeyId: AWS_ACCESS_KEY_ID,
      secretAccessKey: AWS_ACCESS_KEY_SECRET
    },
  },
  google: {
    keyFile: GOOGLE_APPLICATION_CREDENTIALS,
    apiKey: GOOGLE_API_KEY
  },
  banlist: ['some word'],
  urlBlackList: ['someurl.example'],
});

Moderating Text

const textModeration = await client.moderateText('This is some text that might need moderation');

Moderating Images

Since only JPEG and PNG images are natively supported by AWS for moderation, GIF images will be converted into a sprite sheet and WEBP images will be converted to PNG.

const imageModeration = await client.moderateImage('https://example.example/image.png');

Moderating Audios

Currently only OGG files are supported

const audioModeration = await client.moderateAudio('https://example.example/image.ogg', 'en-US');

Moderating Links

Link moderation will use the Google WebRisk API to check links. A Blacklist is also included for known scam urls.

const linkModeration = await client.moderateLink('https://example.example/link');

Link shorteners trigger a warning by default as they are considered non-trustable. If they need to be allowed, set its flag to true.

const linkModeration = await client.moderateLink('https://t.ly/link', true);
0.3.9

11 months ago

0.3.6

11 months ago

0.4.4

10 months ago

0.3.5

11 months ago

0.3.8

11 months ago

0.3.7

11 months ago

0.4.1

10 months ago

0.4.0

11 months ago

0.4.3

10 months ago

0.4.2

10 months ago

0.3.4

1 year ago

0.3.3

1 year ago

0.3.2

1 year ago

0.3.1

1 year ago

0.3.0

1 year ago