config.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435
  1. package dingtalk
  2. import "context"
  3. // DingtalkQAParams 钉钉卡片链路完成一次问答后的落库参数(由 BotConfig.OnDingtalkQA 消费)
  4. type DingtalkQAParams struct {
  5. Question string
  6. Answer string
  7. SenderStaffId string // 钉钉 staffId,写入 chat_message.user_id
  8. }
  9. // BotConfig 每个机器人独立配置(一个 robot_config 一份)
  10. type BotConfig struct {
  11. // 业务侧标识,便于日志与按 ID 检索
  12. RobotConfigID string `json:"robot_config_id"` // 本地 robot_config.RecordID
  13. Name string `json:"name"` // 机器人名称(仅日志展示)
  14. // 钉钉机器人凭证
  15. ClientID string `json:"client_id"` // AppKey / Client ID
  16. ClientSecret string `json:"client_secret"` // AppSecret / Client Secret
  17. RobotCode string `json:"robot_code"` // 机器人 robotCode,企业内部应用一般等同于 ClientID
  18. CardTemplateId string `json:"card_template_id"` // AI 卡片模板 ID
  19. // RAGFlow 真实 ID(注意:是 ragflow 侧 id,不是本地 record_id)
  20. RagChatId string `json:"rag_chat_id"` // RAGFlow chat id(来自 chat_assistant.rag_chat_id)
  21. RagSessionId string `json:"rag_session_id"` // RAGFlow session id(来自 chat_session.rag_session_id)
  22. // 与 chat_message 表关联的本地业务 ID(由 bll 在 buildBotConfig 时注入)
  23. AssistantId string `json:"assistant_id"` // chat_assistant.record_id
  24. SessionId string `json:"session_id"` // chat_session.record_id
  25. CreatorId string `json:"creator_id"` // robot_config.creator_id → chat_message.creator_id
  26. // OnDingtalkQA RAG 成功且卡片最终更新成功后写入 chat_message(可为 nil)
  27. OnDingtalkQA func(ctx context.Context, p DingtalkQAParams) error `json:"-"`
  28. }