chck for empty string

This commit is contained in:
Henry 2023-12-28 02:02:49 +00:00
parent c9a6622df7
commit 4f940b0d91
1 changed files with 1 additions and 0 deletions

View File

@ -19,6 +19,7 @@ export class SimplePromptModerationRunner implements Moderation {
if (this.model) { if (this.model) {
const denyArray = this.denyList.split('\n') const denyArray = this.denyList.split('\n')
for (const denyStr of denyArray) { for (const denyStr of denyArray) {
if (!denyStr || denyStr === '') continue
const res = await this.model.invoke( const res = await this.model.invoke(
`Are these two sentences similar to each other? Only return Yes or No.\nFirst sentence: ${input}\nSecond sentence: ${denyStr}` `Are these two sentences similar to each other? Only return Yes or No.\nFirst sentence: ${input}\nSecond sentence: ${denyStr}`
) )