feat(dingtalk): enable secure multimodal image QA
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package chat
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestBuildLLMMessagesRedactsMultiContentImageURL(t *testing.T) {
|
||||
secret := "TOPSECRETBASE64"
|
||||
messages := buildLLMMessages([]Message{{
|
||||
Role: "user",
|
||||
MultiContent: []MessageContentPart{{
|
||||
Type: "image_url",
|
||||
ImageURL: &ImageURL{URL: "data:image/png;base64," + secret},
|
||||
}},
|
||||
}})
|
||||
if len(messages) != 1 {
|
||||
t.Fatalf("messages length = %d", len(messages))
|
||||
}
|
||||
got := messages[0].Content
|
||||
if strings.Contains(got, secret) || strings.Contains(strings.ToLower(got), "data:image") {
|
||||
t.Fatalf("buildLLMMessages leaked image URL: %q", got)
|
||||
}
|
||||
if !strings.Contains(got, "redacted") {
|
||||
t.Fatalf("buildLLMMessages missing redaction marker: %q", got)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user