69c590d439
- Added a new `setting` package to replace the `constant` package for configuration management, improving code organization and clarity. - Moved various configuration variables such as `ServerAddress`, `PayAddress`, and `SensitiveWords` to the new `setting` package. - Updated references throughout the codebase to use the new `setting` package, ensuring consistent access to configuration values. - Introduced new files for managing chat settings and midjourney settings, enhancing modularity and maintainability of the code.
44 lines
1.0 KiB
Go
44 lines
1.0 KiB
Go
package setting
|
|
|
|
import "strings"
|
|
|
|
var CheckSensitiveEnabled = true
|
|
var CheckSensitiveOnPromptEnabled = true
|
|
|
|
//var CheckSensitiveOnCompletionEnabled = true
|
|
|
|
// StopOnSensitiveEnabled 如果检测到敏感词,是否立刻停止生成,否则替换敏感词
|
|
var StopOnSensitiveEnabled = true
|
|
|
|
// StreamCacheQueueLength 流模式缓存队列长度,0表示无缓存
|
|
var StreamCacheQueueLength = 0
|
|
|
|
// SensitiveWords 敏感词
|
|
// var SensitiveWords []string
|
|
var SensitiveWords = []string{
|
|
"test_sensitive",
|
|
}
|
|
|
|
func SensitiveWordsToString() string {
|
|
return strings.Join(SensitiveWords, "\n")
|
|
}
|
|
|
|
func SensitiveWordsFromString(s string) {
|
|
SensitiveWords = []string{}
|
|
sw := strings.Split(s, "\n")
|
|
for _, w := range sw {
|
|
w = strings.TrimSpace(w)
|
|
if w != "" {
|
|
SensitiveWords = append(SensitiveWords, w)
|
|
}
|
|
}
|
|
}
|
|
|
|
func ShouldCheckPromptSensitive() bool {
|
|
return CheckSensitiveEnabled && CheckSensitiveOnPromptEnabled
|
|
}
|
|
|
|
//func ShouldCheckCompletionSensitive() bool {
|
|
// return CheckSensitiveEnabled && CheckSensitiveOnCompletionEnabled
|
|
//}
|