feat: add recommended action, risk level, and ticket draft readiness to AgentRunLogResponse and related components
This commit is contained in:
@@ -3,6 +3,7 @@ package builders
|
|||||||
import (
|
import (
|
||||||
"cs-agent/internal/models"
|
"cs-agent/internal/models"
|
||||||
"cs-agent/internal/pkg/dto/response"
|
"cs-agent/internal/pkg/dto/response"
|
||||||
|
"encoding/json"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -11,38 +12,65 @@ func BuildAgentRunLog(item *models.AgentRunLog) response.AgentRunLogResponse {
|
|||||||
return response.AgentRunLogResponse{}
|
return response.AgentRunLogResponse{}
|
||||||
}
|
}
|
||||||
hitlStatus, hitlStatusName, hitlSummary := resolveAgentRunLogHITL(item)
|
hitlStatus, hitlStatusName, hitlSummary := resolveAgentRunLogHITL(item)
|
||||||
|
recommendedAction, riskLevel, ticketDraftReady := resolveGraphOutcome(item.GraphToolTrace)
|
||||||
return response.AgentRunLogResponse{
|
return response.AgentRunLogResponse{
|
||||||
ID: item.ID,
|
ID: item.ID,
|
||||||
ConversationID: item.ConversationID,
|
ConversationID: item.ConversationID,
|
||||||
MessageID: item.MessageID,
|
MessageID: item.MessageID,
|
||||||
AIAgentID: item.AIAgentID,
|
AIAgentID: item.AIAgentID,
|
||||||
AIConfigID: item.AIConfigID,
|
AIConfigID: item.AIConfigID,
|
||||||
UserMessage: item.UserMessage,
|
UserMessage: item.UserMessage,
|
||||||
PlannedAction: item.PlannedAction,
|
PlannedAction: item.PlannedAction,
|
||||||
PlannedSkillCode: item.PlannedSkillCode,
|
PlannedSkillCode: item.PlannedSkillCode,
|
||||||
PlannedSkillName: item.PlannedSkillName,
|
PlannedSkillName: item.PlannedSkillName,
|
||||||
SkillRouteTrace: item.SkillRouteTrace,
|
SkillRouteTrace: item.SkillRouteTrace,
|
||||||
ToolSearchTrace: item.ToolSearchTrace,
|
ToolSearchTrace: item.ToolSearchTrace,
|
||||||
GraphToolTrace: item.GraphToolTrace,
|
GraphToolTrace: item.GraphToolTrace,
|
||||||
GraphToolCode: item.GraphToolCode,
|
GraphToolCode: item.GraphToolCode,
|
||||||
HandoffReason: item.HandoffReason,
|
RecommendedAction: recommendedAction,
|
||||||
PlannedToolCode: item.PlannedToolCode,
|
RiskLevel: riskLevel,
|
||||||
PlanReason: item.PlanReason,
|
TicketDraftReady: ticketDraftReady,
|
||||||
InterruptType: item.InterruptType,
|
HandoffReason: item.HandoffReason,
|
||||||
ResumeSource: item.ResumeSource,
|
PlannedToolCode: item.PlannedToolCode,
|
||||||
HitlStatus: hitlStatus,
|
PlanReason: item.PlanReason,
|
||||||
HitlStatusName: hitlStatusName,
|
InterruptType: item.InterruptType,
|
||||||
HitlSummary: hitlSummary,
|
ResumeSource: item.ResumeSource,
|
||||||
FinalAction: item.FinalAction,
|
HitlStatus: hitlStatus,
|
||||||
FinalStatus: item.FinalStatus,
|
HitlStatusName: hitlStatusName,
|
||||||
ReplyText: item.ReplyText,
|
HitlSummary: hitlSummary,
|
||||||
ErrorMessage: item.ErrorMessage,
|
FinalAction: item.FinalAction,
|
||||||
LatencyMs: item.LatencyMs,
|
FinalStatus: item.FinalStatus,
|
||||||
TraceData: item.TraceData,
|
ReplyText: item.ReplyText,
|
||||||
CreatedAt: item.CreatedAt.Format("2006-01-02 15:04:05"),
|
ErrorMessage: item.ErrorMessage,
|
||||||
|
LatencyMs: item.LatencyMs,
|
||||||
|
TraceData: item.TraceData,
|
||||||
|
CreatedAt: item.CreatedAt.Format("2006-01-02 15:04:05"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func resolveGraphOutcome(raw string) (recommendedAction, riskLevel string, ticketDraftReady bool) {
|
||||||
|
raw = strings.TrimSpace(raw)
|
||||||
|
if raw == "" {
|
||||||
|
return "", "", false
|
||||||
|
}
|
||||||
|
var payload struct {
|
||||||
|
Items []struct {
|
||||||
|
RecommendedAction string `json:"recommendedAction"`
|
||||||
|
RiskLevel string `json:"riskLevel"`
|
||||||
|
TicketDraftReady bool `json:"ticketDraftReady"`
|
||||||
|
} `json:"items"`
|
||||||
|
}
|
||||||
|
if err := json.Unmarshal([]byte(raw), &payload); err != nil {
|
||||||
|
return "", "", false
|
||||||
|
}
|
||||||
|
for _, item := range payload.Items {
|
||||||
|
if strings.TrimSpace(item.RecommendedAction) != "" || strings.TrimSpace(item.RiskLevel) != "" || item.TicketDraftReady {
|
||||||
|
return strings.TrimSpace(item.RecommendedAction), strings.TrimSpace(item.RiskLevel), item.TicketDraftReady
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "", "", false
|
||||||
|
}
|
||||||
|
|
||||||
func resolveAgentRunLogHITL(item *models.AgentRunLog) (status, statusName, summary string) {
|
func resolveAgentRunLogHITL(item *models.AgentRunLog) (status, statusName, summary string) {
|
||||||
if item == nil {
|
if item == nil {
|
||||||
return "", "", ""
|
return "", "", ""
|
||||||
|
|||||||
@@ -42,34 +42,37 @@ type SkillDebugRunResponse struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type AgentRunLogResponse struct {
|
type AgentRunLogResponse struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
ConversationID int64 `json:"conversationId"`
|
ConversationID int64 `json:"conversationId"`
|
||||||
MessageID int64 `json:"messageId"`
|
MessageID int64 `json:"messageId"`
|
||||||
AIAgentID int64 `json:"aiAgentId"`
|
AIAgentID int64 `json:"aiAgentId"`
|
||||||
AIConfigID int64 `json:"aiConfigId"`
|
AIConfigID int64 `json:"aiConfigId"`
|
||||||
UserMessage string `json:"userMessage"`
|
UserMessage string `json:"userMessage"`
|
||||||
PlannedAction string `json:"plannedAction"`
|
PlannedAction string `json:"plannedAction"`
|
||||||
PlannedSkillCode string `json:"plannedSkillCode"`
|
PlannedSkillCode string `json:"plannedSkillCode"`
|
||||||
PlannedSkillName string `json:"plannedSkillName"`
|
PlannedSkillName string `json:"plannedSkillName"`
|
||||||
SkillRouteTrace string `json:"skillRouteTrace"`
|
SkillRouteTrace string `json:"skillRouteTrace"`
|
||||||
ToolSearchTrace string `json:"toolSearchTrace"`
|
ToolSearchTrace string `json:"toolSearchTrace"`
|
||||||
GraphToolTrace string `json:"graphToolTrace"`
|
GraphToolTrace string `json:"graphToolTrace"`
|
||||||
GraphToolCode string `json:"graphToolCode"`
|
GraphToolCode string `json:"graphToolCode"`
|
||||||
HandoffReason string `json:"handoffReason"`
|
RecommendedAction string `json:"recommendedAction"`
|
||||||
PlannedToolCode string `json:"plannedToolCode"`
|
RiskLevel string `json:"riskLevel"`
|
||||||
PlanReason string `json:"planReason"`
|
TicketDraftReady bool `json:"ticketDraftReady"`
|
||||||
InterruptType string `json:"interruptType"`
|
HandoffReason string `json:"handoffReason"`
|
||||||
ResumeSource string `json:"resumeSource"`
|
PlannedToolCode string `json:"plannedToolCode"`
|
||||||
HitlStatus string `json:"hitlStatus"`
|
PlanReason string `json:"planReason"`
|
||||||
HitlStatusName string `json:"hitlStatusName"`
|
InterruptType string `json:"interruptType"`
|
||||||
HitlSummary string `json:"hitlSummary"`
|
ResumeSource string `json:"resumeSource"`
|
||||||
FinalAction string `json:"finalAction"`
|
HitlStatus string `json:"hitlStatus"`
|
||||||
FinalStatus string `json:"finalStatus"`
|
HitlStatusName string `json:"hitlStatusName"`
|
||||||
ReplyText string `json:"replyText"`
|
HitlSummary string `json:"hitlSummary"`
|
||||||
ErrorMessage string `json:"errorMessage"`
|
FinalAction string `json:"finalAction"`
|
||||||
LatencyMs int64 `json:"latencyMs"`
|
FinalStatus string `json:"finalStatus"`
|
||||||
TraceData string `json:"traceData"`
|
ReplyText string `json:"replyText"`
|
||||||
CreatedAt string `json:"createdAt"`
|
ErrorMessage string `json:"errorMessage"`
|
||||||
|
LatencyMs int64 `json:"latencyMs"`
|
||||||
|
TraceData string `json:"traceData"`
|
||||||
|
CreatedAt string `json:"createdAt"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AgentRunGraphSummaryResponse struct {
|
type AgentRunGraphSummaryResponse struct {
|
||||||
|
|||||||
@@ -440,6 +440,13 @@ export default function DashboardAgentRunLogsPage() {
|
|||||||
转人工原因:{item.handoffReason}
|
转人工原因:{item.handoffReason}
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
{item.recommendedAction ? (
|
||||||
|
<div className="line-clamp-1 text-xs text-muted-foreground">
|
||||||
|
分流建议:{item.recommendedAction}
|
||||||
|
{item.riskLevel ? ` / ${item.riskLevel} risk` : ""}
|
||||||
|
{item.ticketDraftReady ? " / 草稿已就绪" : ""}
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
"-"
|
"-"
|
||||||
@@ -529,6 +536,9 @@ export default function DashboardAgentRunLogsPage() {
|
|||||||
`plannedSkillCode: ${activeLog.plannedSkillCode || "-"}`,
|
`plannedSkillCode: ${activeLog.plannedSkillCode || "-"}`,
|
||||||
`plannedSkillName: ${activeLog.plannedSkillName || "-"}`,
|
`plannedSkillName: ${activeLog.plannedSkillName || "-"}`,
|
||||||
`graphToolCode: ${activeLog.graphToolCode || "-"}`,
|
`graphToolCode: ${activeLog.graphToolCode || "-"}`,
|
||||||
|
`recommendedAction: ${activeLog.recommendedAction || "-"}`,
|
||||||
|
`riskLevel: ${activeLog.riskLevel || "-"}`,
|
||||||
|
`ticketDraftReady: ${activeLog.ticketDraftReady ? "true" : "false"}`,
|
||||||
`plannedToolCode: ${activeLog.plannedToolCode || "-"}`,
|
`plannedToolCode: ${activeLog.plannedToolCode || "-"}`,
|
||||||
`planReason: ${activeLog.planReason || "-"}`,
|
`planReason: ${activeLog.planReason || "-"}`,
|
||||||
`handoffReason: ${activeLog.handoffReason || "-"}`,
|
`handoffReason: ${activeLog.handoffReason || "-"}`,
|
||||||
|
|||||||
@@ -399,6 +399,9 @@ export type AgentRunLog = {
|
|||||||
toolSearchTrace: string
|
toolSearchTrace: string
|
||||||
graphToolTrace: string
|
graphToolTrace: string
|
||||||
graphToolCode: string
|
graphToolCode: string
|
||||||
|
recommendedAction: string
|
||||||
|
riskLevel: string
|
||||||
|
ticketDraftReady: boolean
|
||||||
handoffReason: string
|
handoffReason: string
|
||||||
plannedToolCode: string
|
plannedToolCode: string
|
||||||
planReason: string
|
planReason: string
|
||||||
|
|||||||
Reference in New Issue
Block a user