feat: add DingTalk picture agent QA

This commit is contained in:
姚章浩
2026-07-20 17:49:03 +08:00
parent ea262551c0
commit ea54b229ee
17 changed files with 1345 additions and 71 deletions
+35
View File
@@ -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)
}
}