2026-04-10 16:24:49 +08:00
|
|
|
package graphs
|
|
|
|
|
|
|
|
|
|
import "strings"
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
InterruptTypeTicketCreationConfirmation = "ticket_creation_confirmation"
|
|
|
|
|
InterruptTypeHandoffConfirmation = "handoff_confirmation"
|
2026-05-31 20:06:44 +08:00
|
|
|
ConfirmOrCancelPrompt = `Please reply with "Confirm" or "Cancel".`
|
|
|
|
|
NeedExplicitConfirmationPrompt = `I need your explicit confirmation. Please reply with "Confirm" or "Cancel".`
|
|
|
|
|
ConfirmationExpiredReply = "This confirmation has expired. Please start again."
|
|
|
|
|
CancelCreateTicketReply = "Ticket creation has been cancelled."
|
|
|
|
|
CancelHandoffReply = "Human handoff has been cancelled."
|
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-05-31 20:06:44 +08:00
|
|
|
confirmWords := []string{"确认", "是", "好的", "可以", "ok", "yes", "continue", "confirm", "继续", "同意"}
|
2026-04-10 16:24:49 +08:00
|
|
|
for _, item := range confirmWords {
|
|
|
|
|
if strings.Contains(value, item) {
|
|
|
|
|
return ConfirmationDecisionConfirm
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-05-31 20:06:44 +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
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ""
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func IsCancellationReply(replyText string) bool {
|
|
|
|
|
replyText = strings.TrimSpace(replyText)
|
2026-05-31 20:06:44 +08:00
|
|
|
return strings.Contains(replyText, CancelCreateTicketReply) ||
|
|
|
|
|
strings.Contains(replyText, CancelHandoffReply) ||
|
|
|
|
|
strings.Contains(replyText, "已取消本次工单创建。") ||
|
|
|
|
|
strings.Contains(replyText, "已取消本次转人工。")
|
2026-04-10 16:24:49 +08:00
|
|
|
}
|