feat: enhance AI workflow with new ticket creation and fallback handling logic
This commit is contained in:
@@ -101,24 +101,134 @@ const emptyDefinition: AIWorkflowDefinition = {
|
||||
id: "start_1",
|
||||
type: "start",
|
||||
name: "开始",
|
||||
position: { x: 0, y: 120 },
|
||||
position: { x: 0, y: 260 },
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
id: "route_intent_1",
|
||||
type: "condition",
|
||||
name: "意图分流",
|
||||
position: { x: 260, y: 260 },
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
id: "handoff_1",
|
||||
type: "handoff_to_human",
|
||||
name: "转人工",
|
||||
position: { x: 560, y: 80 },
|
||||
config: {},
|
||||
inputs: {
|
||||
reason: { nodeId: "start_1", field: "userMessage" },
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "handoff_end_1",
|
||||
type: "end",
|
||||
name: "结束",
|
||||
position: { x: 860, y: 80 },
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
id: "draft_ticket_1",
|
||||
type: "prepare_ticket_draft",
|
||||
name: "整理工单草稿",
|
||||
position: { x: 560, y: 240 },
|
||||
config: {},
|
||||
inputs: {
|
||||
issue: { nodeId: "start_1", field: "userMessage" },
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "ticket_confirm_prompt_1",
|
||||
type: "llm_reply",
|
||||
name: "建单确认文案",
|
||||
position: { x: 860, y: 240 },
|
||||
config: {
|
||||
staticReply: "我已整理工单草稿。请回复“确认”创建工单,或回复“取消”放弃。",
|
||||
},
|
||||
inputs: {
|
||||
userMessage: { nodeId: "start_1", field: "userMessage" },
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "ticket_confirm_1",
|
||||
type: "human_confirm",
|
||||
name: "确认建单",
|
||||
position: { x: 1160, y: 240 },
|
||||
config: {},
|
||||
inputs: {
|
||||
prompt: { nodeId: "ticket_confirm_prompt_1", field: "replyText" },
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "create_ticket_1",
|
||||
type: "create_ticket",
|
||||
name: "创建工单",
|
||||
position: { x: 1460, y: 180 },
|
||||
config: {},
|
||||
inputs: {
|
||||
ticketDraft: { nodeId: "draft_ticket_1", field: "ticketDraft" },
|
||||
confirmed: { nodeId: "ticket_confirm_1", field: "confirmed" },
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "ticket_result_reply_1",
|
||||
type: "send_reply",
|
||||
name: "发送建单结果",
|
||||
position: { x: 1760, y: 180 },
|
||||
config: {},
|
||||
inputs: {
|
||||
replyText: { nodeId: "create_ticket_1", field: "message" },
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "ticket_cancel_reply_1",
|
||||
type: "llm_reply",
|
||||
name: "取消建单提示",
|
||||
position: { x: 1460, y: 320 },
|
||||
config: {
|
||||
staticReply: "已取消创建工单。你可以继续补充问题,我会继续帮你处理。",
|
||||
},
|
||||
inputs: {
|
||||
userMessage: { nodeId: "start_1", field: "userMessage" },
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "send_ticket_cancel_1",
|
||||
type: "send_reply",
|
||||
name: "发送取消提示",
|
||||
position: { x: 1760, y: 320 },
|
||||
config: {},
|
||||
inputs: {
|
||||
replyText: { nodeId: "ticket_cancel_reply_1", field: "replyText" },
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "retrieve_1",
|
||||
type: "knowledge_retrieve",
|
||||
name: "知识检索",
|
||||
position: { x: 260, y: 120 },
|
||||
position: { x: 560, y: 500 },
|
||||
config: {},
|
||||
inputs: {
|
||||
query: { nodeId: "start_1", field: "userMessage" },
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "answerability_1",
|
||||
type: "answerability_gate",
|
||||
name: "可回答判断",
|
||||
position: { x: 860, y: 500 },
|
||||
config: {},
|
||||
inputs: {
|
||||
userMessage: { nodeId: "start_1", field: "userMessage" },
|
||||
knowledgeItems: { nodeId: "retrieve_1", field: "items" },
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "reply_1",
|
||||
type: "llm_reply",
|
||||
name: "AI 回复",
|
||||
position: { x: 520, y: 120 },
|
||||
position: { x: 1160, y: 440 },
|
||||
config: {},
|
||||
inputs: {
|
||||
userMessage: { nodeId: "start_1", field: "userMessage" },
|
||||
@@ -129,25 +239,117 @@ const emptyDefinition: AIWorkflowDefinition = {
|
||||
id: "send_1",
|
||||
type: "send_reply",
|
||||
name: "发送回复",
|
||||
position: { x: 780, y: 120 },
|
||||
position: { x: 1460, y: 440 },
|
||||
config: {},
|
||||
inputs: {
|
||||
replyText: { nodeId: "reply_1", field: "replyText" },
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "fallback_reply_1",
|
||||
type: "llm_reply",
|
||||
name: "兜底追问",
|
||||
position: { x: 1160, y: 600 },
|
||||
config: {},
|
||||
inputs: {
|
||||
userMessage: { nodeId: "start_1", field: "userMessage" },
|
||||
knowledgeItems: { nodeId: "retrieve_1", field: "items" },
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "send_fallback_1",
|
||||
type: "send_reply",
|
||||
name: "发送兜底",
|
||||
position: { x: 1460, y: 600 },
|
||||
config: {},
|
||||
inputs: {
|
||||
replyText: { nodeId: "fallback_reply_1", field: "replyText" },
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "end_1",
|
||||
type: "end",
|
||||
name: "结束",
|
||||
position: { x: 1040, y: 120 },
|
||||
position: { x: 2060, y: 440 },
|
||||
config: {},
|
||||
},
|
||||
],
|
||||
edges: [
|
||||
{ id: "edge_start_retrieve", source: "start_1", target: "retrieve_1" },
|
||||
{ id: "edge_retrieve_reply", source: "retrieve_1", target: "reply_1" },
|
||||
{ id: "edge_start_route_intent", source: "start_1", target: "route_intent_1" },
|
||||
{
|
||||
id: "edge_intent_handoff",
|
||||
source: "route_intent_1",
|
||||
target: "handoff_1",
|
||||
condition: {
|
||||
left: { nodeId: "start_1", field: "userMessage" },
|
||||
operator: "contains",
|
||||
right: "人工",
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "edge_intent_ticket",
|
||||
source: "route_intent_1",
|
||||
target: "draft_ticket_1",
|
||||
condition: {
|
||||
left: { nodeId: "start_1", field: "userMessage" },
|
||||
operator: "contains",
|
||||
right: "工单",
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "edge_intent_complaint",
|
||||
source: "route_intent_1",
|
||||
target: "draft_ticket_1",
|
||||
condition: {
|
||||
left: { nodeId: "start_1", field: "userMessage" },
|
||||
operator: "contains",
|
||||
right: "投诉",
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "edge_intent_incident",
|
||||
source: "route_intent_1",
|
||||
target: "draft_ticket_1",
|
||||
condition: {
|
||||
left: { nodeId: "start_1", field: "userMessage" },
|
||||
operator: "contains",
|
||||
right: "报障",
|
||||
},
|
||||
},
|
||||
{ id: "edge_intent_knowledge_default", source: "route_intent_1", target: "retrieve_1" },
|
||||
{ id: "edge_handoff_end", source: "handoff_1", target: "handoff_end_1" },
|
||||
{ id: "edge_draft_ticket_confirm_prompt", source: "draft_ticket_1", target: "ticket_confirm_prompt_1" },
|
||||
{ id: "edge_ticket_prompt_confirm", source: "ticket_confirm_prompt_1", target: "ticket_confirm_1" },
|
||||
{
|
||||
id: "edge_ticket_confirm_create",
|
||||
source: "ticket_confirm_1",
|
||||
target: "create_ticket_1",
|
||||
condition: {
|
||||
left: { nodeId: "ticket_confirm_1", field: "confirmed" },
|
||||
operator: "is_true",
|
||||
},
|
||||
},
|
||||
{ id: "edge_ticket_confirm_cancel", source: "ticket_confirm_1", target: "ticket_cancel_reply_1" },
|
||||
{ id: "edge_create_ticket_result", source: "create_ticket_1", target: "ticket_result_reply_1" },
|
||||
{ id: "edge_ticket_result_end", source: "ticket_result_reply_1", target: "end_1" },
|
||||
{ id: "edge_ticket_cancel_send", source: "ticket_cancel_reply_1", target: "send_ticket_cancel_1" },
|
||||
{ id: "edge_ticket_cancel_end", source: "send_ticket_cancel_1", target: "end_1" },
|
||||
{ id: "edge_retrieve_answerability", source: "retrieve_1", target: "answerability_1" },
|
||||
{
|
||||
id: "edge_answerability_reply",
|
||||
source: "answerability_1",
|
||||
target: "reply_1",
|
||||
condition: {
|
||||
left: { nodeId: "answerability_1", field: "answerability" },
|
||||
operator: "eq",
|
||||
right: "answerable",
|
||||
},
|
||||
},
|
||||
{ id: "edge_answerability_fallback", source: "answerability_1", target: "fallback_reply_1" },
|
||||
{ id: "edge_reply_send", source: "reply_1", target: "send_1" },
|
||||
{ id: "edge_fallback_send", source: "fallback_reply_1", target: "send_fallback_1" },
|
||||
{ id: "edge_send_end", source: "send_1", target: "end_1" },
|
||||
{ id: "edge_send_fallback_end", source: "send_fallback_1", target: "end_1" },
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
@@ -323,7 +323,10 @@ export type AIWorkflowDefinition = {
|
||||
source: string
|
||||
target: string
|
||||
condition?: {
|
||||
expression: string
|
||||
expression?: string
|
||||
left?: AIWorkflowVariableSelector
|
||||
operator?: string
|
||||
right?: unknown
|
||||
}
|
||||
}[]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user