fix moderation key handling and key UI
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"fmt"
|
||||
"math/big"
|
||||
"strings"
|
||||
|
||||
"github.com/tidwall/gjson"
|
||||
@@ -291,6 +293,17 @@ func normalizeModerationImages(images []string) []string {
|
||||
return out
|
||||
}
|
||||
|
||||
func limitContentModerationImages(images []string) []string {
|
||||
if len(images) <= maxContentModerationInputImages {
|
||||
return images
|
||||
}
|
||||
idx, err := rand.Int(rand.Reader, big.NewInt(int64(len(images))))
|
||||
if err != nil {
|
||||
return images[:maxContentModerationInputImages]
|
||||
}
|
||||
return []string{images[int(idx.Int64())]}
|
||||
}
|
||||
|
||||
func addModerationText(parts *[]string, text string) {
|
||||
text = strings.TrimSpace(text)
|
||||
if text == "" {
|
||||
|
||||
Reference in New Issue
Block a user