This commit is contained in:
Chi Vinh Le
2017-09-06 22:20:19 +07:00
parent a11f149c5a
commit b3fe3afd4c
@@ -14,12 +14,18 @@ module.exports = {
const apiKey = require('./apiKey');
const scores = await perspective.getScores(apiKey, input.body);
if (input.checkToxicity && scores.SEVERE_TOXICITY.summaryScore > TOXICITY_THRESHOLD) {
const isToxic = scores.SEVERE_TOXICITY.summaryScore > TOXICITY_THRESHOLD;
if (input.checkToxicity && isToxic) {
throw ErrToxic;
}
input.metadata = Object.assign({}, input.metadata, {
perspective: scores,
});
if (isToxic) {
// TODO: Flag comment as toxic and put in ?premod?.
}
},
},
},