mirror of
https://github.com/koishijs/novelai-bot
synced 2025-01-08 11:17:32 +08:00
fix: fix lower case breaks lora prompt, fix #178
This commit is contained in:
parent
c0c88ff7e9
commit
f1179b999b
@ -369,7 +369,7 @@ export function parseForbidden(input: string) {
|
|||||||
const backslash = /@@__BACKSLASH__@@/g
|
const backslash = /@@__BACKSLASH__@@/g
|
||||||
|
|
||||||
export function parseInput(session: Session, input: string, config: Config, override: boolean): string[] {
|
export function parseInput(session: Session, input: string, config: Config, override: boolean): string[] {
|
||||||
input = input.toLowerCase()
|
input = input
|
||||||
.replace(/\\\\/g, backslash.source)
|
.replace(/\\\\/g, backslash.source)
|
||||||
.replace(/,/g, ',')
|
.replace(/,/g, ',')
|
||||||
.replace(/(/g, '(')
|
.replace(/(/g, '(')
|
||||||
@ -420,7 +420,7 @@ export function parseInput(session: Session, input: string, config: Config, over
|
|||||||
const forbidden = parseForbidden(session.resolve(config.forbidden))
|
const forbidden = parseForbidden(session.resolve(config.forbidden))
|
||||||
const positive = input.split(/,\s*/g).filter((word) => {
|
const positive = input.split(/,\s*/g).filter((word) => {
|
||||||
// eslint-disable-next-line no-control-regex
|
// eslint-disable-next-line no-control-regex
|
||||||
word = word.replace(/[\x00-\x7f]/g, s => s.replace(/[^0-9a-zA-Z]/, ' ')).replace(/\s+/, ' ').trim()
|
word = word.toLowerCase().replace(/[\x00-\x7f]/g, s => s.replace(/[^0-9a-zA-Z]/, ' ')).replace(/\s+/, ' ').trim()
|
||||||
if (!word) return false
|
if (!word) return false
|
||||||
for (const { pattern, strict } of forbidden) {
|
for (const { pattern, strict } of forbidden) {
|
||||||
if (strict && word.split(/\W+/g).includes(pattern)) {
|
if (strict && word.split(/\W+/g).includes(pattern)) {
|
||||||
@ -430,6 +430,9 @@ export function parseInput(session: Session, input: string, config: Config, over
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
}).map((word) => {
|
||||||
|
if (/^<.+>$/.test(word)) return word
|
||||||
|
return word.toLowerCase()
|
||||||
})
|
})
|
||||||
|
|
||||||
if (Math.max(getWordCount(positive), getWordCount(negative)) > (session.resolve(config.maxWords) || Infinity)) {
|
if (Math.max(getWordCount(positive), getWordCount(negative)) > (session.resolve(config.maxWords) || Infinity)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user