2bbf42b741
Remove Agent Desk users, roles, login sessions, tokens, and local permission persistence. Expose the backend as an embeddable ai-agent module with host-provided subject lookup and operation authorization callbacks, and complete the frontend/backend repository split.
52 lines
1.6 KiB
Go
52 lines
1.6 KiB
Go
package graphs
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"code.tczkiot.com/wlw/ai-agent/internal/models"
|
|
"code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
|
|
)
|
|
|
|
func TestBuildAnalyzeConversationResult_RecommendsHandoffForComplaint(t *testing.T) {
|
|
conversation := models.Conversation{
|
|
LastMessageSummary: "用户反馈被重复扣费,并要求人工处理",
|
|
}
|
|
messages := []models.Message{
|
|
{SenderType: enums.IMSenderTypeCustomer, Content: "你们重复扣费了,我要投诉并转人工"},
|
|
}
|
|
|
|
got := buildAnalyzeConversationResult(conversation, messages, AnalyzeConversationInput{
|
|
NeedHumanHandoff: true,
|
|
})
|
|
|
|
if got.UserIntent != "handoff_request" {
|
|
t.Fatalf("expected handoff_request, got %q", got.UserIntent)
|
|
}
|
|
if got.RiskLevel != "high" {
|
|
t.Fatalf("expected high risk, got %q", got.RiskLevel)
|
|
}
|
|
if got.RecommendedNextAction != "handoff_to_human" {
|
|
t.Fatalf("expected handoff_to_human, got %q", got.RecommendedNextAction)
|
|
}
|
|
}
|
|
|
|
func TestBuildAnalyzeConversationResult_RecommendsPrepareTicket(t *testing.T) {
|
|
conversation := models.Conversation{
|
|
LastMessageSummary: "用户要求登记问题并尽快处理",
|
|
}
|
|
messages := []models.Message{
|
|
{SenderType: enums.IMSenderTypeCustomer, Content: "麻烦帮我建个工单,订单一直支付失败"},
|
|
}
|
|
|
|
got := buildAnalyzeConversationResult(conversation, messages, AnalyzeConversationInput{
|
|
NeedTicket: true,
|
|
})
|
|
|
|
if got.UserIntent != "ticket_request" {
|
|
t.Fatalf("expected ticket_request, got %q", got.UserIntent)
|
|
}
|
|
if got.RecommendedNextAction != "prepare_ticket" {
|
|
t.Fatalf("expected prepare_ticket, got %q", got.RecommendedNextAction)
|
|
}
|
|
}
|