File size: 1,067 Bytes
624088c
 
 
 
3ca0269
bcd2d46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39


// unfortunately due to abuse by some users, I have to add this NSFW filter
const secretSalt = `${process.env.SECRET_CENSORSHIP_KEY || ""}`

// TODO the censorship is not implement yet actually

// I don't want to be banned by Replicate because bad actors are asking
// for some naked anime stuff or whatever
// I also want to avoid a PR scandal due to some bad user generated content

const forbiddenWords = [
  // those keywords have been generated by looking at the logs of the AI Comic Factory
  // those are real requests some users tried to attempt.. :|
  "nazi",
  "hitler",
  "boob",
  "boobs",
  "boobies",
  "nipple",
  "nipples",
  "nude",
  "nudes",
  "naked",
  "pee",
  "peeing",
  "erotic",
  "sexy"
]

// temporary utility to make sure Replicate doesn't ban my account 
// because of what users do in their prompt
export const filterOutBadWords = (sentence: string) => {
  const words = sentence.split(" ")
  return words.filter(word => {
    const lowerCase = word.toLocaleLowerCase()
    return !forbiddenWords.includes(lowerCase)
  }).join(" ")
}