fix: 敏感词库为空时,不检测

This commit is contained in:
CaIon
2024-03-20 22:33:22 +08:00
parent d5e93e788d
commit c7658b70d1
2 changed files with 13 additions and 1 deletions

View File

@@ -23,7 +23,13 @@ func SensitiveWordsToString() string {
}
func SensitiveWordsFromString(s string) {
SensitiveWords = strings.Split(s, "\n")
sw := strings.Split(s, "\n")
for _, w := range sw {
w = strings.TrimSpace(w)
if w != "" {
SensitiveWords = append(SensitiveWords, w)
}
}
}
func ShouldCheckPromptSensitive() bool {