Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.
Go agentagenticaichatbotdsh-pluginembeddingsevaluationgenerative-aigolangknowledge-basellmmulti-tenantollamaopenaiquestion-answeringragrerankingsemantic-searchvector-searchwiki
feat(im): add markdown replies for QQBot
YS-zdckcb5e59b917f0
diff --git a/internal/im/qqbot/adapter_test.go b/internal/im/qqbot/adapter_test.goindex f2902d23d..08e929735 100644--- a/internal/im/qqbot/adapter_test.go+++ b/internal/im/qqbot/adapter_test.go@@ -108,3 +108,30 @@ func TestNewClientAllowsWhitelistedPrivateDeployment(t *testing.T) {t.Fatalf("expected whitelisted private qqbot endpoints to pass: %v", err)}}++func TestSendMessageRequestUsesMarkdownMessage(t *testing.T) {+ req := sendMessageRequest{+ Content: "fallback",+ MsgType: 2,+ Markdown: &markdownMessage{Content: "# title\n**answer**"},+ MsgID: "msg-1",+ MsgSeq: 1,+ }++ raw, err := json.Marshal(req)+ if err != nil {+ t.Fatal(err)+ }++ var payload map[string]any+ if err := json.Unmarshal(raw, &payload); err != nil {+ t.Fatal(err)+ }+ if payload["msg_type"] != float64(2) {+ t.Fatalf("msg_type = %v, want 2", payload["msg_type"])+ }+ markdown, ok := payload["markdown"].(map[string]any)+ if !ok || markdown["content"] != "# title\n**answer**" {+ t.Fatalf("markdown payload = %#v", payload["markdown"])+ }+}diff --git a/internal/im/qqbot/client.go b/internal/im/qqbot/client.goindex ce8c41b58..9f6243ea0 100644--- a/internal/im/qqbot/client.go+++ b/internal/im/qqbot/client.go@@ -123,10 +123,10 @@ func (c *Client) SendGroupMessage(ctx context.Context, groupOpenID, content, msgfunc (c *Client) sendText(ctx context.Context, path, content, msgID string) error {body := sendMessageRequest{- Content: content,- MsgType: 0,- MsgID: msgID,- MsgSeq: 1,+ MsgType: 2,+ Markdown: &markdownMessage{Content: content},+ MsgID: msgID,+ MsgSeq: 1,}return c.doJSON(ctx, http.MethodPost, c.apiBaseURL+path, body, nil)}diff --git a/internal/im/qqbot/types.go b/internal/im/qqbot/types.goindex 0697ecfc5..5a3149885 100644--- a/internal/im/qqbot/types.go+++ b/internal/im/qqbot/types.go@@ -76,8 +76,13 @@ type qqAttachment struct {}type sendMessageRequest struct {- Content string `json:"content"`- MsgType int `json:"msg_type"`- MsgID string `json:"msg_id,omitempty"`- MsgSeq int `json:"msg_seq,omitempty"`+ Content string `json:"content,omitempty"`+ MsgType int `json:"msg_type"`+ Markdown *markdownMessage `json:"markdown,omitempty"`+ MsgID string `json:"msg_id,omitempty"`+ MsgSeq int `json:"msg_seq,omitempty"`+}++type markdownMessage struct {+ Content string `json:"content,omitempty"`}