ZeldaFan0225/AI_Horde_Discord

Feature request: allow blacklist to be a regex

Closed this issue · 2 comments

I'd like to blacklist certain words without it mattering whether or not they're using exact case or doubling letters or adding accents. The easiest way to do this is to allow regexes in the blacklist. I've implemented this like so:

if(ctx.client.config.advanced_generate?.blacklisted_regexes?.some(w => new RegExp(w,'i').test(prompt.normalize("NFD").replace(/[\u0300-\u036f]/g, "")))) return ctx.error({error: "Your prompt included one or more blacklisted words"})

I tried adding the regex directly in the config, but couldn't figure out how to add a regex in the schema in types.ts (stuff I found online didn't work), but this also just seems easier.

This can also control if certain words are only allowed in positive or negative prompt: "sad.?###|###.?happy" to disallow sad images.

the input of slash commands is already kinda normalized,

image

it already gives it as plaintext or rather handles it as plaintext

this has been implemented