feat: add DingTalk picture agent QA
This commit is contained in:
@@ -2,6 +2,7 @@ package weknora
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
@@ -63,3 +64,37 @@ func TestParseSSEErrorDominatesPartialAnswer(t *testing.T) {
|
||||
t.Fatalf("expected terminal vision error, got %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAgentChatRequestJSONSerializesImages(t *testing.T) {
|
||||
req := AgentChatRequest{
|
||||
Query: "请描述并分析这张图片。",
|
||||
AgentEnabled: true,
|
||||
AgentID: "agent-1",
|
||||
Channel: "im",
|
||||
Images: []Image{
|
||||
{Data: "data:image/png;base64,iVBORw0KGgo="},
|
||||
},
|
||||
}
|
||||
raw, err := json.Marshal(req)
|
||||
if err != nil {
|
||||
t.Fatalf("marshal: %v", err)
|
||||
}
|
||||
if !strings.Contains(string(raw), `"images":[{"data":"data:image/png;base64,iVBORw0KGgo="}]`) {
|
||||
t.Fatalf("images not serialized correctly: %s", raw)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAgentChatRequestJSONOmitsEmptyImages(t *testing.T) {
|
||||
req := AgentChatRequest{
|
||||
Query: "hello",
|
||||
AgentEnabled: true,
|
||||
AgentID: "agent-1",
|
||||
}
|
||||
raw, err := json.Marshal(req)
|
||||
if err != nil {
|
||||
t.Fatalf("marshal: %v", err)
|
||||
}
|
||||
if strings.Contains(string(raw), `"images"`) {
|
||||
t.Fatalf("empty images should be omitted: %s", raw)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user