2026-04-10 16:24:49 +08:00
|
|
|
package graphs
|
|
|
|
|
|
2026-06-03 09:36:33 +08:00
|
|
|
import (
|
|
|
|
|
"strings"
|
|
|
|
|
|
2026-08-21 00:41:07 +08:00
|
|
|
"code.tczkiot.com/wlw/ai-agent/internal/pkg/i18nx"
|
2026-06-03 09:36:33 +08:00
|
|
|
)
|
2026-04-10 16:24:49 +08:00
|
|
|
|
|
|
|
|
const (
|
2026-08-28 22:23:13 +08:00
|
|
|
InterruptTypeHandoffConfirmation = "handoff_confirmation"
|
2026-06-03 09:36:33 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
|
ConfirmOrCancelPrompt = i18nx.Get("graph.confirmOrCancel")
|
|
|
|
|
NeedExplicitConfirmationPrompt = i18nx.Get("graph.needExplicitConfirmation")
|
|
|
|
|
ConfirmationExpiredReply = i18nx.Get("graph.confirmationExpired")
|
|
|
|
|
CancelHandoffReply = i18nx.Get("graph.cancelHandoff")
|
2026-04-10 16:24:49 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type ConfirmationDecision string
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
ConfirmationDecisionConfirm ConfirmationDecision = "confirm"
|
|
|
|
|
ConfirmationDecisionCancel ConfirmationDecision = "cancel"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func ParseConfirmationDecision(value string) ConfirmationDecision {
|
|
|
|
|
value = strings.ToLower(strings.TrimSpace(value))
|
|
|
|
|
if value == "" {
|
|
|
|
|
return ""
|
|
|
|
|
}
|
2026-08-28 22:23:13 +08:00
|
|
|
cancelWords := []string{
|
|
|
|
|
"不确认", "取消", "不用", "不需要", "算了", "no", "cancel",
|
|
|
|
|
"不提交", "不要提交", "暂不提交", "不办理", "不要办理", "不执行", "不要执行",
|
2026-04-10 16:24:49 +08:00
|
|
|
}
|
|
|
|
|
for _, item := range cancelWords {
|
|
|
|
|
if strings.Contains(value, item) {
|
|
|
|
|
return ConfirmationDecisionCancel
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-08-28 22:23:13 +08:00
|
|
|
confirmWords := []string{
|
|
|
|
|
"确认", "是", "好的", "可以", "ok", "yes", "continue", "confirm", "继续", "同意",
|
|
|
|
|
"提交", "确定", "办理", "执行",
|
|
|
|
|
}
|
|
|
|
|
for _, item := range confirmWords {
|
|
|
|
|
if strings.Contains(value, item) {
|
|
|
|
|
return ConfirmationDecisionConfirm
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-04-10 16:24:49 +08:00
|
|
|
return ""
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func IsCancellationReply(replyText string) bool {
|
|
|
|
|
replyText = strings.TrimSpace(replyText)
|
2026-08-28 22:23:13 +08:00
|
|
|
return strings.Contains(replyText, CancelHandoffReply) ||
|
|
|
|
|
strings.Contains(replyText, "已取消本次转人工。") ||
|
|
|
|
|
strings.Contains(replyText, "操作已取消。")
|
2026-04-10 16:24:49 +08:00
|
|
|
}
|