feat(dingtalk): add reasoning mode and support evidence

This commit is contained in:
姚章浩
2026-09-10 16:24:56 +08:00
parent 0798a2dac7
commit bfa1b1b25f
45 changed files with 2713 additions and 102 deletions
+33 -1
View File
@@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"strconv"
"strings"
"time"
)
@@ -28,6 +29,8 @@ type SettingInput struct{ TenantKey, Channel, StaffID, UnionID, DisplayName, Dep
type ControllerRepository interface {
IsAdministrator(context.Context, string, string) (bool, error)
SetPreference(context.Context, string, string, string, string) error
SetReasoningMaxRounds(context.Context, string, string, string, int, time.Time) error
SetReasoningHintEnabled(context.Context, string, string, string, bool, time.Time) error
SaveBinding(context.Context, ResourceBinding) error
TestAndActivateSupportGroup(context.Context, ResourceBinding) error
DetectBootstrapCandidate(context.Context, BootstrapCandidate) error
@@ -109,6 +112,32 @@ func (c *Controller) Handle(ctx context.Context, in SettingInput) (string, error
}
return "✅ 回答语言已设置为 " + args[1] + "。", nil
}
if action == "rounds" {
if len(args) != 2 {
return "智能推理自动关闭轮数必须是1-50之间的整数。", nil
}
rounds, parseErr := strconv.Atoi(args[1])
if parseErr != nil || rounds < 1 || rounds > 50 {
return "智能推理自动关闭轮数必须是1-50之间的整数。", nil
}
if err := c.repo.SetReasoningMaxRounds(ctx, in.TenantKey, defaultChannel(in.Channel), in.StaffID, rounds, c.now()); err != nil {
return "", err
}
return fmt.Sprintf("✅ 智能推理将在%d轮对话后自动关闭。", rounds), nil
}
if action == "hint" {
if len(args) != 2 || (args[1] != "on" && args[1] != "off") {
return "用法:/setting hint <on|off>。", nil
}
enabled := args[1] == "on"
if err := c.repo.SetReasoningHintEnabled(ctx, in.TenantKey, defaultChannel(in.Channel), in.StaffID, enabled, c.now()); err != nil {
return "", err
}
if enabled {
return "✅ 智能推理剩余轮次提醒已开启。", nil
}
return "✅ 智能推理剩余轮次提醒已关闭。", nil
}
admin, err := c.repo.IsAdministrator(ctx, in.TenantKey, in.StaffID)
if err != nil {
return "", err
@@ -164,7 +193,10 @@ func settingMenu(admin, _ bool) string {
"- auto:跟随当前提问语言(推荐)\n" +
"- zh-CN:简体中文\n" +
"- en / ja / ko / es:英语 / 日语 / 韩语 / 西班牙语\n" +
"例如:/setting language en"
"例如:/setting language en\n\n" +
"智能推理自动关闭轮数:/setting rounds <1-50>\n" +
"例如:/setting rounds 15\n" +
"剩余轮次提醒:/setting hint <on|off>"
if !admin {
return menu
}