feat: enhance event consumption logic and add success reply handling
This commit is contained in:
@@ -82,7 +82,7 @@ func (g *HandoffGraph) Run(ctx context.Context, argumentsInJSON string) (string,
|
||||
if err := services.ConversationService.HandoffByAI(g.conversation.ID, g.aiAgent, state.Reason); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return "已为你转接人工客服,请稍候。", nil
|
||||
return g.buildSuccessReply(), nil
|
||||
case ConfirmationDecisionCancel:
|
||||
return CancelHandoffReply, nil
|
||||
default:
|
||||
@@ -112,6 +112,10 @@ func (g *HandoffGraph) buildConfirmationPrompt(reason string) string {
|
||||
return fmt.Sprintf("我准备为你转接人工客服。\n原因:%s\n请直接回复“确认”或“取消”。", strings.TrimSpace(reason))
|
||||
}
|
||||
|
||||
func (g *HandoffGraph) buildSuccessReply() string {
|
||||
return "已为你转接人工客服,请稍候。,请稍候。"
|
||||
}
|
||||
|
||||
func parseHandoffDecision(value string) ConfirmationDecision {
|
||||
return ParseConfirmationDecision(value)
|
||||
}
|
||||
|
||||
@@ -29,3 +29,13 @@ func TestHandoffGraphBuildReasonFallback(t *testing.T) {
|
||||
t.Fatalf("unexpected fallback reason: %q", reason)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandoffGraphBuildSuccessReply(t *testing.T) {
|
||||
graph := NewHandoffGraph(&models.Conversation{ID: 1}, &models.AIAgent{Name: "AI"})
|
||||
|
||||
got := graph.buildSuccessReply()
|
||||
want := "已为你转接人工客服,请稍候。,请稍候。"
|
||||
if got != want {
|
||||
t.Fatalf("unexpected success reply: %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user