From a0101a3f6390a87715d45b010931053d11a6fb54 Mon Sep 17 00:00:00 2001 From: shaohuzhang1 Date: Tue, 3 Nov 2026 17:51:21 +0800 Subject: [PATCH] feat: Simple Application Dialogue --- apps/chat/template/agent_simple.py | 328 ++++++---- .../components/header/simple-debug/index.vue | 28 + .../components/history-popover/index.vue | 128 ++++ .../view/simple-debug/index.vue | 164 +++++ ui/src/styles/STYLE_README.md | 4 +- ui/src/views/VIEW_README.md | 10 +- .../application-detail/setting/index.vue | 597 +++++++++--------- 7 files changed, 846 insertions(+), 413 deletions(-) create mode 100644 ui/src/conversation-panel/components/header/simple-debug/index.vue create mode 100644 ui/src/conversation-panel/components/history-popover/index.vue create mode 100644 ui/src/conversation-panel/view/simple-debug/index.vue diff --git a/apps/chat/template/agent_simple.py b/apps/chat/template/agent_simple.py index 45db39983e4..2393171b9a5 100644 --- a/apps/chat/template/agent_simple.py +++ b/apps/chat/template/agent_simple.py @@ -1,3 +1,6 @@ +import copy +import json + from django.db.models import QuerySet template = { @@ -5,15 +8,15 @@ { "id": "6a8d23d9-5179-424e-80c2-f08d37cdb8d4", "type": "app-edge", - "endPoint": {"x": 2760, "y": 1054.125}, + "endPoint": {"x": 2750, "y": 1029.0625}, "pointsList": [ - {"x": 2620, "y": 1054.125}, - {"x": 2730, "y": 1054.125}, - {"x": 2650, "y": 1054.125}, - {"x": 2760, "y": 1054.125}, + {"x": 2567.520767922439, "y": 1060.5442998886515}, + {"x": 2667.520767922439, "y": 1060.5442998886515}, + {"x": 2650, "y": 1029.0625}, + {"x": 2750, "y": 1029.0625}, ], "properties": {}, - "startPoint": {"x": 2620, "y": 1054.125}, + "startPoint": {"x": 2567.520767922439, "y": 1060.5442998886515}, "sourceNodeId": "fd0324fc-f5e4-4fa6-a2d9-cb251b467605", "targetNodeId": "420a6e4f-44ff-4847-bb81-0923630846b5", "sourceAnchorId": "fd0324fc-f5e4-4fa6-a2d9-cb251b467605_right", @@ -22,15 +25,15 @@ { "id": "56006748-d9fe-491b-a14b-04fd568cac08", "type": "app-edge", - "endPoint": {"x": 3610, "y": 149.25}, + "endPoint": {"x": 3610, "y": 140.9375}, "pointsList": [ - {"x": 3340, "y": 913.75}, - {"x": 3450, "y": 913.75}, - {"x": 3500, "y": 149.25}, - {"x": 3610, "y": 149.25}, + {"x": 3350, "y": 897.0625}, + {"x": 3450, "y": 897.0625}, + {"x": 3510, "y": 140.9375}, + {"x": 3610, "y": 140.9375}, ], "properties": {}, - "startPoint": {"x": 3340, "y": 913.75}, + "startPoint": {"x": 3350, "y": 897.0625}, "sourceNodeId": "420a6e4f-44ff-4847-bb81-0923630846b5", "targetNodeId": "36a440a9-5b00-4d82-b13a-8e7819112918", "sourceAnchorId": "420a6e4f-44ff-4847-bb81-0923630846b5_7887_right", @@ -39,15 +42,15 @@ { "id": "9bc8721b-07aa-4730-9347-910ed64e26b9", "type": "app-edge", - "endPoint": {"x": 3610, "y": 1054.125}, + "endPoint": {"x": 3610, "y": 1018.9375}, "pointsList": [ - {"x": 3340, "y": 1043.125}, - {"x": 3450, "y": 1043.125}, - {"x": 3500, "y": 1054.125}, - {"x": 3610, "y": 1054.125}, + {"x": 3350, "y": 1023.0625}, + {"x": 3450, "y": 1023.0625}, + {"x": 3510, "y": 1018.9375}, + {"x": 3610, "y": 1018.9375}, ], "properties": {}, - "startPoint": {"x": 3340, "y": 1043.125}, + "startPoint": {"x": 3350, "y": 1023.0625}, "sourceNodeId": "420a6e4f-44ff-4847-bb81-0923630846b5", "targetNodeId": "f7c3b4a2-cb80-4e47-b050-7fef0315daaf", "sourceAnchorId": "420a6e4f-44ff-4847-bb81-0923630846b5_6847_right", @@ -56,15 +59,15 @@ { "id": "e4b4bb4e-35ed-40a4-b4e7-b86f77131d92", "type": "app-edge", - "endPoint": {"x": 550, "y": 1054.125}, + "endPoint": {"x": 540, "y": 1030.75}, "pointsList": [ - {"x": 280, "y": 1054.125}, - {"x": 390, "y": 1054.125}, - {"x": 440, "y": 1054.125}, - {"x": 550, "y": 1054.125}, + {"x": 280, "y": 1008.125}, + {"x": 380, "y": 1008.125}, + {"x": 440, "y": 1030.75}, + {"x": 540, "y": 1030.75}, ], "properties": {}, - "startPoint": {"x": 280, "y": 1054.125}, + "startPoint": {"x": 280, "y": 1008.125}, "sourceNodeId": "start-node", "targetNodeId": "b4dd9d45-25f0-4b01-9ec3-557a46a97d94", "sourceAnchorId": "start-node_right", @@ -73,15 +76,15 @@ { "id": "0ea723ab-bebd-4058-98af-74b6c5f03260", "type": "app-edge", - "endPoint": {"x": 1270, "y": 1054.125}, + "endPoint": {"x": 1245.7315831103328, "y": 482.0191225666973}, "pointsList": [ - {"x": 1130, "y": 978.4375}, - {"x": 1240, "y": 978.4375}, - {"x": 1160, "y": 1054.125}, - {"x": 1270, "y": 1054.125}, + {"x": 1140, "y": 961.75}, + {"x": 1240, "y": 961.75}, + {"x": 1145.7315831103328, "y": 482.0191225666973}, + {"x": 1245.7315831103328, "y": 482.0191225666973}, ], "properties": {}, - "startPoint": {"x": 1130, "y": 978.4375}, + "startPoint": {"x": 1140, "y": 961.75}, "sourceNodeId": "b4dd9d45-25f0-4b01-9ec3-557a46a97d94", "targetNodeId": "a0089772-3821-474f-bb4f-9bfe32c1d95f", "sourceAnchorId": "b4dd9d45-25f0-4b01-9ec3-557a46a97d94_gWldyeZ3CMPKS9teLWQeI_right", @@ -90,15 +93,15 @@ { "id": "c0c675d3-cb0b-4b67-8009-16951303791d", "type": "app-edge", - "endPoint": {"x": 1730, "y": 1054.125}, + "endPoint": {"x": 1709.9423019523076, "y": 1073.1353016256758}, "pointsList": [ - {"x": 1130, "y": 1069.125}, - {"x": 1240, "y": 1069.125}, - {"x": 1620, "y": 1054.125}, - {"x": 1730, "y": 1054.125}, + {"x": 1140, "y": 1052.75}, + {"x": 1240, "y": 1052.75}, + {"x": 1609.9423019523076, "y": 1073.1353016256758}, + {"x": 1709.9423019523076, "y": 1073.1353016256758}, ], "properties": {}, - "startPoint": {"x": 1130, "y": 1069.125}, + "startPoint": {"x": 1140, "y": 1052.75}, "sourceNodeId": "b4dd9d45-25f0-4b01-9ec3-557a46a97d94", "targetNodeId": "124fe8a0-70fa-42cb-b854-4b6c02ebb836", "sourceAnchorId": "b4dd9d45-25f0-4b01-9ec3-557a46a97d94_TvdY3NQkSdYbC8A15VrId_right", @@ -107,15 +110,15 @@ { "id": "0c1d5fc1-6ab2-431e-afdc-9f332ce8b466", "type": "app-edge", - "endPoint": {"x": 1730, "y": 1054.125}, + "endPoint": {"x": 1709.9423019523076, "y": 1073.1353016256758}, "pointsList": [ - {"x": 1590, "y": 1054.125}, - {"x": 1700, "y": 1054.125}, - {"x": 1620, "y": 1054.125}, - {"x": 1730, "y": 1054.125}, + {"x": 1565.7315831103328, "y": 482.0191225666973}, + {"x": 1665.7315831103328, "y": 482.0191225666973}, + {"x": 1609.9423019523076, "y": 1073.1353016256758}, + {"x": 1709.9423019523076, "y": 1073.1353016256758}, ], "properties": {}, - "startPoint": {"x": 1590, "y": 1054.125}, + "startPoint": {"x": 1565.7315831103328, "y": 482.0191225666973}, "sourceNodeId": "a0089772-3821-474f-bb4f-9bfe32c1d95f", "targetNodeId": "124fe8a0-70fa-42cb-b854-4b6c02ebb836", "sourceAnchorId": "a0089772-3821-474f-bb4f-9bfe32c1d95f_right", @@ -124,15 +127,15 @@ { "id": "422564a4-2b0a-469b-be86-ded4204e7742", "type": "app-edge", - "endPoint": {"x": 2300, "y": 1054.125}, + "endPoint": {"x": 2247.520767922439, "y": 1060.5442998886515}, "pointsList": [ - {"x": 2160, "y": 1054.125}, - {"x": 2270, "y": 1054.125}, - {"x": 2190, "y": 1054.125}, - {"x": 2300, "y": 1054.125}, + {"x": 2164.942301952309, "y": 1073.1353016256758}, + {"x": 2264.942301952309, "y": 1073.1353016256758}, + {"x": 2147.520767922439, "y": 1060.5442998886515}, + {"x": 2247.520767922439, "y": 1060.5442998886515}, ], "properties": {}, - "startPoint": {"x": 2160, "y": 1054.125}, + "startPoint": {"x": 2164.942301952309, "y": 1073.1353016256758}, "sourceNodeId": "124fe8a0-70fa-42cb-b854-4b6c02ebb836", "targetNodeId": "fd0324fc-f5e4-4fa6-a2d9-cb251b467605", "sourceAnchorId": "124fe8a0-70fa-42cb-b854-4b6c02ebb836_right", @@ -141,15 +144,15 @@ { "id": "a0cee2ac-4d0d-4b68-8cb2-ca2cb39993e9", "type": "app-edge", - "endPoint": {"x": 3480, "y": 1973.375}, + "endPoint": {"x": 3470, "y": 1950}, "pointsList": [ - {"x": 3340, "y": 1133.8125}, - {"x": 3450, "y": 1133.8125}, - {"x": 3370, "y": 1973.375}, - {"x": 3480, "y": 1973.375}, + {"x": 3350, "y": 1114.0625}, + {"x": 3450, "y": 1114.0625}, + {"x": 3370, "y": 1950}, + {"x": 3470, "y": 1950}, ], "properties": {}, - "startPoint": {"x": 3340, "y": 1133.8125}, + "startPoint": {"x": 3350, "y": 1114.0625}, "sourceNodeId": "420a6e4f-44ff-4847-bb81-0923630846b5", "targetNodeId": "f9ae6300-5b07-4244-9b88-2a5e7329e1d4", "sourceAnchorId": "420a6e4f-44ff-4847-bb81-0923630846b5_2794_right", @@ -158,15 +161,15 @@ { "id": "cd66759a-bcb9-4d61-806b-7bde23ae4582", "type": "app-edge", - "endPoint": {"x": 4200, "y": 1001.5}, + "endPoint": {"x": 4200, "y": 958.3125}, "pointsList": [ - {"x": 4060, "y": 1897.6875}, - {"x": 4170, "y": 1897.6875}, - {"x": 4090, "y": 1001.5}, - {"x": 4200, "y": 1001.5}, + {"x": 4070, "y": 1881}, + {"x": 4170, "y": 1881}, + {"x": 4100, "y": 958.3125}, + {"x": 4200, "y": 958.3125}, ], "properties": {}, - "startPoint": {"x": 4060, "y": 1897.6875}, + "startPoint": {"x": 4070, "y": 1881}, "sourceNodeId": "f9ae6300-5b07-4244-9b88-2a5e7329e1d4", "targetNodeId": "dd02a0d8-0ea1-41c4-8b64-0cb7d8963fd9", "sourceAnchorId": "f9ae6300-5b07-4244-9b88-2a5e7329e1d4_Iu8b0BMQU9xXWy5JbcTnz_right", @@ -175,15 +178,15 @@ { "id": "7113c5b7-d9d6-4f49-a030-24eaeee00e7d", "type": "app-edge", - "endPoint": {"x": 4200, "y": 1973.375}, + "endPoint": {"x": 4200, "y": 1955.0625}, "pointsList": [ - {"x": 4060, "y": 1988.375}, - {"x": 4170, "y": 1988.375}, - {"x": 4090, "y": 1973.375}, - {"x": 4200, "y": 1973.375}, + {"x": 4070, "y": 1972}, + {"x": 4170, "y": 1972}, + {"x": 4100, "y": 1955.0625}, + {"x": 4200, "y": 1955.0625}, ], "properties": {}, - "startPoint": {"x": 4060, "y": 1988.375}, + "startPoint": {"x": 4070, "y": 1972}, "sourceNodeId": "f9ae6300-5b07-4244-9b88-2a5e7329e1d4", "targetNodeId": "04dd6c1e-95f9-4757-bb3e-134d503fce54", "sourceAnchorId": "f9ae6300-5b07-4244-9b88-2a5e7329e1d4_s-groW06vt6a7B-aqDqnX_right", @@ -193,21 +196,48 @@ "nodes": [ { "x": 120, - "y": 120, + "y": 47.25, "id": "base-node", "type": "base-node", "properties": { + "width": 600, "config": {}, - "height": 984.25, + "height": 838.75, "showNode": True, "stepName": "基本信息", "node_data": { "desc": "www", "name": "www", - "prologue": "您好,我是 XXX 小助手,您可以向我提出 XXX 使用问题。\n- XXX 主要功能有什么?\n- XXX 如何收费?\n- 需要转人工服务", + "prologue": "", "tts_type": "BROWSER", + "stt_autosend": False, + "stt_model_id": "", + "tts_autoplay": False, + "tts_model_id": "", + "long_term_enable": False, + "stt_model_enable": False, + "tts_model_enable": False, "stt_model_id_type": "default", + "file_upload_enable": False, + "long_term_model_id": "", + "file_upload_setting": { + "audio": False, + "image": False, + "other": False, + "video": False, + "document": True, + "maxFiles": 3, + "fileLimit": 50, + "url_upload": False, + "local_upload": True, + "otherExtensions": ["PPT", "DOC"], + }, + "long_term_trigger_type": "ROUND", "long_term_model_id_type": "default", + "stt_model_params_setting": {}, + "tts_model_params_setting": {}, + "long_term_trigger_setting": {"rounds": 10}, + "long_term_model_params_setting": {}, }, "enableException": False, "input_field_list": [], @@ -262,10 +292,11 @@ }, { "x": 120, - "y": 1054.125, + "y": 1008.125, "id": "start-node", "type": "start-node", "properties": { + "width": 320, "config": { "fields": [{"label": "用户问题", "value": "question"}], "chatFields": [], @@ -282,7 +313,7 @@ ], }, "fields": [{"label": "用户问题", "value": "question"}], - "height": 644, + "height": 552, "showNode": True, "stepName": "开始", "globalFields": [{"label": "当前时间", "value": "time"}], @@ -290,11 +321,12 @@ }, }, { - "x": 2460, - "y": 1054.125, + "x": 2407.520767922439, + "y": 1060.5442998886515, "id": "fd0324fc-f5e4-4fa6-a2d9-cb251b467605", "type": "search-knowledge-node", "properties": { + "width": 320, "config": { "fields": [ {"label": "检索结果的分段列表", "value": "paragraph_list"}, @@ -303,11 +335,12 @@ {"label": "满足直接回答的分段内容", "value": "directly_return"}, ] }, - "height": 806.375, + "height": 816, "showNode": True, "stepName": "知识库检索", "condition": "AND", "node_data": { + "image_list": [], "knowledge_list": [], "show_knowledge": True, "knowledge_id_list": [], @@ -320,6 +353,7 @@ "search_scope_type": "custom", "search_scope_source": "knowledge", "all_knowledge_id_list": [], + "search_scope_reference": [], "question_reference_address": ["124fe8a0-70fa-42cb-b854-4b6c02ebb836", "Group1"], "no_permission_knowledge_id_list": [], }, @@ -328,13 +362,13 @@ }, { "x": 3050, - "y": 1054.125, + "y": 1029.0625, "id": "420a6e4f-44ff-4847-bb81-0923630846b5", "type": "condition-node", "properties": { "width": 600, "config": {"fields": [{"label": "分支名称", "value": "branch_name"}]}, - "height": 552.125, + "height": 502, "showNode": True, "stepName": "判断器", "condition": "AND", @@ -348,7 +382,7 @@ { "field": ["fd0324fc-f5e4-4fa6-a2d9-cb251b467605", "is_hit_handling_method_list"], "value": 1, - "compare": "is_not_None", + "compare": "is_not_null", } ], }, @@ -360,7 +394,7 @@ { "field": ["fd0324fc-f5e4-4fa6-a2d9-cb251b467605", "paragraph_list"], "value": 1, - "compare": "is_not_None", + "compare": "is_not_null", } ], }, @@ -369,20 +403,21 @@ }, "enableException": False, "branch_condition_list": [ - {"id": "7887", "index": 0, "height": 121.375}, - {"id": "6847", "index": 1, "height": 121.375}, - {"id": "2794", "index": 2, "height": 44}, + {"id": "7887", "index": 0, "height": 118}, + {"id": "6847", "index": 1, "height": 118}, + {"id": "2794", "index": 2, "height": 48}, ], }, }, { "x": 3770, - "y": 149.25, + "y": 140.9375, "id": "36a440a9-5b00-4d82-b13a-8e7819112918", "type": "reply-node", "properties": { + "width": 320, "config": {"fields": [{"label": "内容", "value": "answer"}]}, - "height": 394, + "height": 377.375, "showNode": True, "stepName": "指定回复", "condition": "AND", @@ -391,16 +426,18 @@ "content": "", "is_result": True, "reply_type": "referencing", + "content_type": "TEXT", }, "enableException": False, }, }, { "x": 3770, - "y": 1054.125, + "y": 1018.9375, "id": "f7c3b4a2-cb80-4e47-b050-7fef0315daaf", "type": "ai-chat-node", "properties": { + "width": 320, "config": { "fields": [ {"label": "AI 回答内容", "value": "answer"}, @@ -408,17 +445,24 @@ {"label": "历史聊天记录", "value": "history_message"}, ] }, - "height": 1175.75, + "height": 1105.375, "showNode": True, "stepName": "AI 对话", "condition": "AND", "node_data": { - "prompt": "已知信息:\n{{知识库检索.data}}\n问题:\n{{开始.question}}", + "prompt": "", "system": "", + "vision": False, "model_id": "", + "tool_ids": [], "is_result": True, + "image_list": [], "max_tokens": None, + "mcp_source": "referencing", + "video_list": [], + "mcp_servers": "", "temperature": None, + "mcp_tool_ids": [], "dialogue_type": "WORKFLOW", "model_id_type": "custom", "model_setting": { @@ -426,21 +470,25 @@ "reasoning_content_start": "", "reasoning_content_enable": False, }, + "skill_tool_ids": [], + "application_ids": [], "dialogue_number": 1, "mcp_output_enable": True, "model_id_reference": [], + "model_params_setting": {}, }, "enableException": False, }, }, { "x": 4360, - "y": 1973.375, + "y": 1955.0625, "id": "04dd6c1e-95f9-4757-bb3e-134d503fce54", "type": "reply-node", "properties": { + "width": 320, "config": {"fields": [{"label": "内容", "value": "answer"}]}, - "height": 512, + "height": 475.375, "showNode": True, "stepName": "指定回复1", "condition": "AND", @@ -449,19 +497,20 @@ "content": "抱歉,没有在知识库查询到相关内容,请提供更详细的信息。", "is_result": True, "reply_type": "content", + "content_type": "TEXT", }, "enableException": False, }, }, { "x": 840, - "y": 1054.125, + "y": 1030.75, "id": "b4dd9d45-25f0-4b01-9ec3-557a46a97d94", "type": "condition-node", "properties": { "width": 600, "config": {"fields": [{"label": "分支名称", "value": "branch_name"}]}, - "height": 422.75, + "height": 376, "showNode": True, "stepName": "判断器1", "condition": "AND", @@ -472,7 +521,7 @@ "type": "IF", "condition": "and", "conditions": [ - {"field": ["global", "problem_optimization"], "value": 1, "compare": "is_True"} + {"field": ["global", "problem_optimization"], "value": 1, "compare": "is_true"} ], }, {"id": "TvdY3NQkSdYbC8A15VrId", "type": "ELSE", "condition": "and", "conditions": []}, @@ -480,47 +529,51 @@ }, "enableException": False, "branch_condition_list": [ - {"id": "gWldyeZ3CMPKS9teLWQeI", "index": 0, "height": 121.375}, - {"id": "TvdY3NQkSdYbC8A15VrId", "index": 1, "height": 44}, + {"id": "gWldyeZ3CMPKS9teLWQeI", "index": 0, "height": 118}, + {"id": "TvdY3NQkSdYbC8A15VrId", "index": 1, "height": 48}, ], }, }, { - "x": 1430, - "y": 1054.125, + "x": 1405.7315831103328, + "y": 482.0191225666973, "id": "a0089772-3821-474f-bb4f-9bfe32c1d95f", "type": "question-node", "properties": { + "width": 320, "config": {"fields": [{"label": "问题优化结果", "value": "answer"}]}, - "height": 842, + "height": 761.375, "showNode": True, "stepName": "问题优化", "condition": "AND", "node_data": { "prompt": "{{开始.question}}", - "system": "# 角色\n你是一位问题优化大师,擅长根据上下文精准揣测用户意图,并对用户提出的问题进行优化。\n\n## 技能\n### 技能 1: 优化问题\n2. 接收用户输入的问题。\n3. 依据上下文仔细分析问题含义。\n4. 输出优化后的问题。\n\n## 限制:\n- 仅返回优化后的问题,不进行额外解释或说明。\n- 确保优化后的问题准确反映原始问题意图,不得改变原意。", + "system": "# 角色\n你是一位问题优化大师,擅长根据上下文精准揣测用户意图,并对用户提出的问题进行优化。\n## 技能\n### 技能 1: 优化问题\n2. 接收用户输入的问题。\n3. 依据上下文仔细分析问题含义。\n4. 输出优化后的问题。\n\n## 限制:\n- 仅返回优化后的问题,不进行额外解释或说明。\n- 确保优化后的问题准确反映原始问题意图,不得改变原意。", "model_id": "", "is_result": False, + "dialogue_type": "NODE", "model_id_type": "default", "dialogue_number": 0, "model_id_reference": [], + "model_params_setting": {}, }, "enableException": False, }, }, { - "x": 1945, - "y": 1054.125, + "x": 1937.4423019523076, + "y": 1073.1353016256758, "id": "124fe8a0-70fa-42cb-b854-4b6c02ebb836", "type": "variable-aggregation-node", "properties": { + "width": 455, "config": {"fields": [{"label": "Group1", "value": "Group1"}]}, - "height": 530.75, + "height": 492, "showNode": True, "stepName": "变量聚合", - "condition": "AND", + "condition": "OR", "node_data": { - "strategy": "first_non_None", + "strategy": "first_non_null", "is_result": True, "group_list": [ { @@ -542,10 +595,11 @@ }, { "x": 4360, - "y": 1001.5, + "y": 958.3125, "id": "dd02a0d8-0ea1-41c4-8b64-0cb7d8963fd9", "type": "ai-chat-node", "properties": { + "width": 320, "config": { "fields": [ {"label": "AI 回答内容", "value": "answer"}, @@ -553,17 +607,24 @@ {"label": "历史聊天记录", "value": "history_message"}, ] }, - "height": 1191.75, + "height": 1105.375, "showNode": True, "stepName": "AI 对话1", "condition": "AND", "node_data": { "prompt": "{{开始.question}}", "system": "", + "vision": False, "model_id": "", + "tool_ids": [], "is_result": True, + "image_list": [], "max_tokens": None, + "mcp_source": "referencing", + "video_list": [], + "mcp_servers": "", "temperature": None, + "mcp_tool_ids": [], "dialogue_type": "WORKFLOW", "model_id_type": "custom", "model_setting": { @@ -571,22 +632,25 @@ "reasoning_content_start": "", "reasoning_content_enable": False, }, + "skill_tool_ids": [], + "application_ids": [], "dialogue_number": 0, "mcp_output_enable": True, "model_id_reference": [], + "model_params_setting": {}, }, "enableException": False, }, }, { "x": 3770, - "y": 1973.375, + "y": 1950, "id": "f9ae6300-5b07-4244-9b88-2a5e7329e1d4", "type": "condition-node", "properties": { "width": 600, "config": {"fields": [{"label": "分支名称", "value": "branch_name"}]}, - "height": 422.75, + "height": 376, "showNode": True, "stepName": "判断器2", "condition": "AND", @@ -596,15 +660,15 @@ "id": "Iu8b0BMQU9xXWy5JbcTnz", "type": "IF", "condition": "and", - "conditions": [{"field": ["global", "ai_questioning"], "value": 1, "compare": "is_True"}], + "conditions": [{"field": ["global", "ai_questioning"], "value": 1, "compare": "is_true"}], }, {"id": "s-groW06vt6a7B-aqDqnX", "type": "ELSE", "condition": "and", "conditions": []}, ] }, "enableException": False, "branch_condition_list": [ - {"id": "Iu8b0BMQU9xXWy5JbcTnz", "index": 0, "height": 121.375}, - {"id": "s-groW06vt6a7B-aqDqnX", "index": 1, "height": 44}, + {"id": "Iu8b0BMQU9xXWy5JbcTnz", "index": 0, "height": 118}, + {"id": "s-groW06vt6a7B-aqDqnX", "index": 1, "height": 48}, ], }, }, @@ -613,24 +677,32 @@ def build_workflow(application): + from application.models import ApplicationVersion from system_manage.models.resource_mapping import ResourceMapping, ResourceType - data = template.copy() - if application.knowledge_ids: + # 深拷贝模板,避免修改模块级模板导致请求之间串配置 + data = copy.deepcopy(template) + knowledge_setting = application.knowledge_setting or {} + no_references_setting = knowledge_setting.get("no_references_setting") or {} + model_setting = application.model_setting or {} + # 发布版本使用发布时的知识库快照;调试使用 Application 本体,从资源映射读取 + if isinstance(application, ApplicationVersion): knowledge_ids = application.knowledge_ids else: - knowledge_ids = ( - QuerySet(ResourceMapping) + knowledge_ids = [ + str(target_id) + for target_id in QuerySet(ResourceMapping) .filter(source_type=ResourceType.APPLICATION, source_id=application.id, target_type=ResourceType.KNOWLEDGE) .values_list("target_id", flat=True) - ) + ] data["nodes"][0]["properties"]["user_input_field_list"][0]["default_value"] = application.problem_optimization data["nodes"][0]["properties"]["user_input_field_list"][1]["default_value"] = ( - application.knowledge_setting.no_references_setting.status == "ai_questioning" + no_references_setting.get("status") == "ai_questioning" ) - model_id = application.model + # Application 的外键与 ApplicationVersion 的字段都提供 model_id + model_id = str(application.model_id) if application.model_id else "" model_params_setting = application.model_params_setting or {} ## 问题优化设置 data["nodes"][8]["properties"]["node_data"]["model_id"] = model_id @@ -640,16 +712,32 @@ def build_workflow(application): data["nodes"][8]["properties"]["node_data"]["model_params_setting"] = model_params_setting ## 知识库检索 data["nodes"][2]["properties"]["node_data"]["knowledge_id_list"] = knowledge_ids - data["nodes"][2]["properties"]["node_data"]["knowledge_setting"] = application.knowledge_setting + data["nodes"][2]["properties"]["node_data"]["knowledge_setting"] = knowledge_setting ## ai对话 data["nodes"][5]["properties"]["node_data"]["model_id"] = model_id data["nodes"][5]["properties"]["node_data"]["model_params_setting"] = model_params_setting - data["nodes"][5]["properties"]["node_data"]["prompt"] = application.model_setting.prompt + data["nodes"][5]["properties"]["node_data"]["prompt"] = ( + (model_setting.get("prompt") or "") + .replace("{question}", "{{开始.question}}") + .replace("{data}", "{{知识库检索.data}}") + ) + data["nodes"][5]["properties"]["node_data"]["system"] = model_setting.get("system") + data["nodes"][5]["properties"]["node_data"]["mcp_tool_ids"] = application.mcp_tool_ids + data["nodes"][5]["properties"]["node_data"]["mcp_servers"] = application.mcp_servers + data["nodes"][5]["properties"]["node_data"]["application_ids"] = application.application_ids + data["nodes"][5]["properties"]["node_data"]["tool_ids"] = application.tool_ids ## 未查询到知识库ai 回复 data["nodes"][10]["properties"]["node_data"]["model_id"] = model_id data["nodes"][10]["properties"]["node_data"]["model_params_setting"] = model_params_setting + data["nodes"][10]["properties"]["node_data"]["prompt"] = model_setting.get("no_references_prompt").replace( + "{question}", "{{开始.question}}" + ) + data["nodes"][10]["properties"]["node_data"]["mcp_tool_ids"] = application.mcp_tool_ids + data["nodes"][10]["properties"]["node_data"]["mcp_servers"] = application.mcp_servers + data["nodes"][10]["properties"]["node_data"]["application_ids"] = application.application_ids + data["nodes"][10]["properties"]["node_data"]["tool_ids"] = application.tool_ids ## 未查询到知识库指定回复 - if application.knowledge_setting.no_references_setting.status == "designated_answer": - data["nodes"][6]["properties"]["node_data"]["content"] = application.knowledge_setting.value + if no_references_setting.get("status") == "designated_answer": + data["nodes"][6]["properties"]["node_data"]["content"] = no_references_setting.get("value") return data diff --git a/ui/src/conversation-panel/components/header/simple-debug/index.vue b/ui/src/conversation-panel/components/header/simple-debug/index.vue new file mode 100644 index 00000000000..75464387c94 --- /dev/null +++ b/ui/src/conversation-panel/components/header/simple-debug/index.vue @@ -0,0 +1,28 @@ + + + diff --git a/ui/src/conversation-panel/components/history-popover/index.vue b/ui/src/conversation-panel/components/history-popover/index.vue new file mode 100644 index 00000000000..568f2ab3b1c --- /dev/null +++ b/ui/src/conversation-panel/components/history-popover/index.vue @@ -0,0 +1,128 @@ + + + diff --git a/ui/src/conversation-panel/view/simple-debug/index.vue b/ui/src/conversation-panel/view/simple-debug/index.vue new file mode 100644 index 00000000000..848671009f0 --- /dev/null +++ b/ui/src/conversation-panel/view/simple-debug/index.vue @@ -0,0 +1,164 @@ + + + + + diff --git a/ui/src/styles/STYLE_README.md b/ui/src/styles/STYLE_README.md index db89e53ccdd..9b77c6257d3 100644 --- a/ui/src/styles/STYLE_README.md +++ b/ui/src/styles/STYLE_README.md @@ -22,8 +22,8 @@ Element Plus 覆盖、主题变量和应用样式。Chat 入口还显式引入 E ## 对话模块公共样式 -`src/conversation-panel/index.scss` 是对话模块公共样式入口,由模块内的 -`view/chat/index.vue` 和 `view/debug/index.vue` 在 `