diff --git a/apps/application/flow/step_node/search_dataset_node/impl/base_search_dataset_node.py b/apps/application/flow/step_node/search_dataset_node/impl/base_search_dataset_node.py index 26975e4b8..cf652b54c 100644 --- a/apps/application/flow/step_node/search_dataset_node/impl/base_search_dataset_node.py +++ b/apps/application/flow/step_node/search_dataset_node/impl/base_search_dataset_node.py @@ -40,7 +40,11 @@ class BaseSearchDatasetNode(ISearchDatasetStepNode): paragraph_list = self.list_paragraph(embedding_list, vector) result = [self.reset_paragraph(paragraph, embedding_list) for paragraph in paragraph_list] return NodeResult({'paragraph_list': result, - 'is_hit_handling_method_list': [row.get('is_hit_handling_method') for row in result]}, {}) + 'is_hit_handling_method_list': [row for row in result if row.get('is_hit_handling_method')], + 'data': '\n'.join([paragraph.get('content') for paragraph in paragraph_list]), + 'directly_return': '\n'.join([paragraph.get('content') for paragraph in paragraph_list if + paragraph.get('is_hit_handling_method')])}, + {}) @staticmethod def reset_paragraph(paragraph: Dict, embedding_list: List): diff --git a/apps/application/flow/workflow_manage.py b/apps/application/flow/workflow_manage.py index ae3b6fde1..314cfc787 100644 --- a/apps/application/flow/workflow_manage.py +++ b/apps/application/flow/workflow_manage.py @@ -116,9 +116,16 @@ class WorkflowManage: node = self.get_start_node() node_instance = get_node(node.type)(node, self.params, self.context) return node_instance - for edge in self.flow.edges: - if edge.sourceNodeId == self.current_node.id: - return self.get_node_cls_by_id(edge.targetNodeId) + if self.current_result is not None and self.current_result.is_assertion_result(): + for edge in self.flow.edges: + if (edge.sourceNodeId == self.current_node.id and + f"{edge.sourceNodeId}_{self.current_result.node_variable.get('branch_id')}_right" == edge.sourceAnchorId): + return self.get_node_cls_by_id(edge.targetNodeId) + else: + for edge in self.flow.edges: + if edge.sourceNodeId == self.current_node.id: + return self.get_node_cls_by_id(edge.targetNodeId) + return None def get_reference_field(self, node_id: str, fields: List[str]): @@ -174,500 +181,3 @@ class WorkflowManage: def get_node_reference(self, reference_address: Dict): node = self.get_node_by_id(reference_address.get('node_id')) return node.context[reference_address.get('node_field')] - - -json_str = """ -{ - "nodes": [ - { - "id": "base-node", - "type": "base-node", - "x": 200, - "y": 270, - "properties": { - "height": 200, - "stepName": "基本信息", - "node_data": { - "name": "", - "desc": "", - "prologue": "您好,我是 MaxKB 小助手,您可以向我提出 MaxKB 使用问题。" - } - } - }, - { - "id": "start-node", - "type": "start-node", - "x": 140, - "y": 800, - "properties": { - "height": 200, - "stepName": "开始", - "output": [ - { - "key": "" - } - ], - "fields": [ - { - "label": "用户问题", - "value": "question" - } - ] - } - }, - { - "id": "34902d3d-a3ff-497f-b8e1-0c34a44d7dd5", - "type": "search-dataset-node", - "x": 1490, - "y": 580, - "properties": { - "height": 200, - "stepName": "知识库检索", - "input": [ - { - "key": "输入" - } - ], - "output": [ - { - "key": "输出" - } - ], - "fields": [ - { - "label": "检索结果", - "value": "data" - }, - { - "label": "满足直接回答的分段内容", - "value": "paragraph" - } - ], - "node_data": { - "dataset_id_list": [ - "e750b5f5-247a-11ef-8fc8-a8a1595801ab", - "1e42a226-1bfd-11ef-be5f-a8a1595801ab", - "e3b4ad8d-18f2-11ef-9a18-a8a1595801ab", - "861d1f5c-18f3-11ef-a40e-a8a1595801ab" - ], - "dataset_setting": { - "top_n": 3, - "similarity": 0.6, - "max_paragraph_char_number": 5000, - "search_mode": "embedding" - }, - "question_reference_address": [ - "start-node", - "question" - ] - } - } - }, - { - "id": "34902d3d-a3ff-497f-b8e1-0c34a44d7dd6", - "type": "condition-node", - "x": 1080, - "y": 500, - "properties": { - "height": 200, - "width": 600, - "stepName": "判断器", - "input": [ - { - "key": "输入" - } - ], - "output": [ - { - "key": "9208" - }, - { - "key": "1143" - }, - { - "key": "输出" - } - ], - "node_data": { - "branch": [ - { - "conditions": [ - { - "field": [ - "03597cb0-ed4c-4bcb-b25b-3b358f72b266", - "answer" - ], - "compare": "contain", - "value": "打招呼" - } - ], - "id": "2391", - "type": "IF", - "condition": "and" - }, - { - "conditions": [ - { - "field": [ - "03597cb0-ed4c-4bcb-b25b-3b358f72b266", - "answer" - ], - "compare": "contain", - "value": "售前咨询" - } - ], - "id": "1143", - "type": "IF ELSE 1", - "condition": "and" - }, - { - "conditions": [ - - ], - "id": "9208", - "type": "ELSE", - "condition": "and" - } - ] - } - } - }, - { - "id": "03597cb0-ed4c-4bcb-b25b-3b358f72b266", - "type": "ai-chat-node", - "x": 580, - "y": 400, - "properties": { - "height": "", - "stepName": "AI 对话", - "input": [ - { - "key": "输入" - } - ], - "output": [ - { - "key": "输出" - } - ], - "node_data": { - "model_id": "9bdd1ab3-135b-11ef-b688-a8a1595801ab", - "system": "你是问题分析大师", - "prompt": "请直接返回所属的问题分类,不要说推理过程。用户问题为:{{context['start-node'].question}} 问题分类是:打招呼 售前咨询 售后咨询其他咨询", - "dialogue_number": 1 - } - } - }, - { - "id": "6649ee86-348c-4d68-9cad-71f0612beb05", - "type": "ai-chat-node", - "x": 2030, - "y": 500, - "properties": { - "height": "", - "stepName": "AI 对话", - "input": [ - { - "key": "输入" - } - ], - "output": [ - { - "key": "输出" - } - ], - "node_data": { - "model_id": "9bdd1ab3-135b-11ef-b688-a8a1595801ab", - "system": "你是售前咨询工程师", - "prompt": "已知信息:{{context['34902d3d-a3ff-497f-b8e1-0c34a44d7dd5'].data}}回答用户问题:{{context['start-node'].question}}", - "dialogue_number": 0 - } - } - }, - { - "id": "0004a9c9-e2fa-40ac-9215-2e1ad04f09c5", - "type": "ai-chat-node", - "x": 1360, - "y": 1300, - "properties": { - "height": "", - "stepName": "AI 对话", - "input": [ - { - "key": "输入" - } - ], - "output": [ - { - "key": "输出" - } - ], - "node_data": { - "model_id": "9bdd1ab3-135b-11ef-b688-a8a1595801ab", - "system": "你是售后咨询工程师", - "prompt": "{{context['start-node'].question}}", - "dialogue_number": 0 - } - } - }, - { - "id": "30c16d31-3881-48cd-991e-da3f99c45681", - "type": "reply-node", - "x": 1690, - "y": 170, - "properties": { - "height": "", - "stepName": "指定回复", - "input": [ - { - "key": "" - } - ], - "output": [ - { - "key": "" - } - ], - "node_data": { - "reply_type": "content", - "content": "你好,有什么需要帮助的吗", - "fields": [ - - ] - } - } - } - ], - "edges": [ - { - "id": "214aa478-78ce-4c95-89aa-11f821bc65d2", - "type": "app-edge", - "sourceNodeId": "start-node", - "targetNodeId": "03597cb0-ed4c-4bcb-b25b-3b358f72b266", - "startPoint": { - "x": 300, - "y": 865.3335000000001 - }, - "endPoint": { - "x": 420, - "y": 677 - }, - "properties": { - - }, - "pointsList": [ - { - "x": 300, - "y": 865.3335000000001 - }, - { - "x": 410, - "y": 865.3335000000001 - }, - { - "x": 310, - "y": 677 - }, - { - "x": 420, - "y": 677 - } - ], - "sourceAnchorId": "start-node__right", - "targetAnchorId": "03597cb0-ed4c-4bcb-b25b-3b358f72b266_输入_left" - }, - { - "id": "d56fb64a-4fc0-4779-911b-283a2238ef7b", - "type": "app-edge", - "sourceNodeId": "03597cb0-ed4c-4bcb-b25b-3b358f72b266", - "targetNodeId": "34902d3d-a3ff-497f-b8e1-0c34a44d7dd6", - "startPoint": { - "x": 740, - "y": 672 - }, - "endPoint": { - "x": 790, - "y": 678.6665 - }, - "properties": { - - }, - "pointsList": [ - { - "x": 740, - "y": 672 - }, - { - "x": 850, - "y": 672 - }, - { - "x": 680, - "y": 678.6665 - }, - { - "x": 790, - "y": 678.6665 - } - ], - "sourceAnchorId": "03597cb0-ed4c-4bcb-b25b-3b358f72b266_输出_right", - "targetAnchorId": "34902d3d-a3ff-497f-b8e1-0c34a44d7dd6_输入_left" - }, - { - "id": "26fe01d6-8d41-4025-a637-e09f41c9b2c8", - "type": "app-edge", - "sourceNodeId": "34902d3d-a3ff-497f-b8e1-0c34a44d7dd6", - "targetNodeId": "30c16d31-3881-48cd-991e-da3f99c45681", - "startPoint": { - "x": 1370, - "y": 673.6665 - }, - "endPoint": { - "x": 1530, - "y": 286 - }, - "properties": { - - }, - "pointsList": [ - { - "x": 1370, - "y": 673.6665 - }, - { - "x": 1480, - "y": 673.6665 - }, - { - "x": 1420, - "y": 286 - }, - { - "x": 1530, - "y": 286 - } - ], - "sourceAnchorId": "34902d3d-a3ff-497f-b8e1-0c34a44d7dd6_9208_right", - "targetAnchorId": "30c16d31-3881-48cd-991e-da3f99c45681__left" - }, - { - "id": "5c85d2bb-cb27-44ed-9e05-505f702381f6", - "type": "app-edge", - "sourceNodeId": "34902d3d-a3ff-497f-b8e1-0c34a44d7dd6", - "targetNodeId": "34902d3d-a3ff-497f-b8e1-0c34a44d7dd5", - "startPoint": { - "x": 1370, - "y": 697.6665 - }, - "endPoint": { - "x": 1330, - "y": 898.889 - }, - "properties": { - - }, - "pointsList": [ - { - "x": 1370, - "y": 697.6665 - }, - { - "x": 1480, - "y": 697.6665 - }, - { - "x": 1220, - "y": 898.889 - }, - { - "x": 1330, - "y": 898.889 - } - ], - "sourceAnchorId": "34902d3d-a3ff-497f-b8e1-0c34a44d7dd6_1143_right", - "targetAnchorId": "34902d3d-a3ff-497f-b8e1-0c34a44d7dd5_输入_left" - }, - { - "id": "4d4b5740-910e-48b0-badd-8b9ce10e6e4e", - "type": "app-edge", - "sourceNodeId": "34902d3d-a3ff-497f-b8e1-0c34a44d7dd5", - "targetNodeId": "6649ee86-348c-4d68-9cad-71f0612beb05", - "startPoint": { - "x": 1650, - "y": 893.889 - }, - "endPoint": { - "x": 1870, - "y": 777 - }, - "properties": { - - }, - "pointsList": [ - { - "x": 1650, - "y": 893.889 - }, - { - "x": 1760, - "y": 893.889 - }, - { - "x": 1760, - "y": 777 - }, - { - "x": 1870, - "y": 777 - } - ], - "sourceAnchorId": "34902d3d-a3ff-497f-b8e1-0c34a44d7dd5_输出_right", - "targetAnchorId": "6649ee86-348c-4d68-9cad-71f0612beb05_输入_left" - }, - { - "id": "9c446d4d-e500-4867-8d47-ed99f80b9b48", - "type": "app-edge", - "sourceNodeId": "34902d3d-a3ff-497f-b8e1-0c34a44d7dd6", - "targetNodeId": "0004a9c9-e2fa-40ac-9215-2e1ad04f09c5", - "startPoint": { - "x": 1370, - "y": 721.6665 - }, - "endPoint": { - "x": 1200, - "y": 1577 - }, - "properties": { - - }, - "pointsList": [ - { - "x": 1370, - "y": 721.6665 - }, - { - "x": 1480, - "y": 721.6665 - }, - { - "x": 1090, - "y": 1577 - }, - { - "x": 1200, - "y": 1577 - } - ], - "sourceAnchorId": "34902d3d-a3ff-497f-b8e1-0c34a44d7dd6_2391_right", - "targetAnchorId": "0004a9c9-e2fa-40ac-9215-2e1ad04f09c5_输入_left" - } - ] -} -""" -f = Flow.new_instance(json.loads(json_str)) -_id = str(uuid.uuid1()) -w_manage = WorkflowManage(flow=f, - params={"history_chat_record": [], "question": "有企业版吗", "chat_id": _id, - "chat_record_id": _id, - "stream": True, "client_id": _id, "client_type": "xxxx"}) -w_manage.run() diff --git a/apps/smartdoc/wsgi.py b/apps/smartdoc/wsgi.py index 29adeb29f..e04ec5274 100644 --- a/apps/smartdoc/wsgi.py +++ b/apps/smartdoc/wsgi.py @@ -25,9 +25,3 @@ def post_handler(): post_handler() - - -def run(): - from application.flow.workflow_manage import WorkflowManage - - diff --git a/ui/src/workflow/common/app-node.ts b/ui/src/workflow/common/app-node.ts index 37ac06de9..cb8e34339 100644 --- a/ui/src/workflow/common/app-node.ts +++ b/ui/src/workflow/common/app-node.ts @@ -99,17 +99,20 @@ class AppNodeModel extends HtmlNodeModel { getDefaultAnchor() { const { id, x, y, width } = this const anchors: any = [] - anchors.push({ - x: x - width / 2 + 10, - y: y, - id: `${id}`, - edgeAddable: false, - type: 'left' - }) + if (this.type !== 'start-node') { + anchors.push({ + x: x - width / 2 + 10, + y: y, + id: `${id}_left`, + edgeAddable: false, + type: 'left' + }) + } + anchors.push({ x: x + width / 2 - 10, y: y, - id: `${id}`, + id: `${id}_right`, type: 'right' }) diff --git a/ui/src/workflow/common/data.ts b/ui/src/workflow/common/data.ts index 19578c560..3887bebe1 100644 --- a/ui/src/workflow/common/data.ts +++ b/ui/src/workflow/common/data.ts @@ -27,7 +27,6 @@ export const baseNodes = [ properties: { height: 200, stepName: '开始', - output: [{ key: '' }], fields: [ { label: '用户问题', @@ -47,20 +46,10 @@ export const menuNodes = [ properties: { height: '', stepName: 'AI 对话', - input: [ - { - key: '' - } - ], - output: [ - { - key: '' - } - ], fields: [ { label: 'AI 回答内容', - value: 'content' + value: 'answer' } ] } @@ -73,24 +62,16 @@ export const menuNodes = [ properties: { height: '', stepName: '知识库检索', - input: [ - { - key: '输入' - } - ], - output: [ - { - key: '输出' - } - ], fields: [ + { label: '段落列表', value: 'paragraph_list' }, + { label: '满足直接回答的段落列表', value: 'is_hit_handling_method_list' }, { label: '检索结果', value: 'data' }, { label: '满足直接回答的分段内容', - value: 'paragraph' + value: 'directly_return' } ] } @@ -103,20 +84,10 @@ export const menuNodes = [ properties: { height: '', stepName: '问题优化', - input: [ - { - key: '' - } - ], - output: [ - { - key: '' - } - ], fields: [ { - label: '用户问题', - value: 'question' + label: '问题优化结果', + value: 'answer' } ] } @@ -128,17 +99,7 @@ export const menuNodes = [ icon: 'condition-node-icon', properties: { width: 600, - stepName: '判断器', - input: [ - { - key: '输入' - } - ], - output: [ - { - key: '输出' - } - ] + stepName: '判断器' } }, { @@ -148,17 +109,7 @@ export const menuNodes = [ icon: 'reply-node-icon', properties: { height: '', - stepName: '指定回复', - input: [ - { - key: '' - } - ], - output: [ - { - key: '' - } - ] + stepName: '指定回复' } } ] diff --git a/ui/src/workflow/index.vue b/ui/src/workflow/index.vue index dceabf452..74aee0b8a 100644 --- a/ui/src/workflow/index.vue +++ b/ui/src/workflow/index.vue @@ -31,113 +31,462 @@ const graphData = { nodes: [ ...baseNodes, { - id: '34902d3d-a3ff-497f-b8e1-0c34a44d7dd5', - type: 'search-dataset-node', + id: 'e781559d-e54b-45d8-bcea-d2d426fd58a3', + type: 'ai-chat-node', x: 600, - y: 250, + y: 560, properties: { - height: 200, + height: '', + stepName: 'AI 对话', + fields: [{ label: 'AI 回答内容', value: 'answer' }], + node_data: { + model_id: '9bdd1ab3-135b-11ef-b688-a8a1595801ab', + system: '你是问题分类大师', + prompt: + "请直接返回所属的问题分类,不要说推理过程。\n用户问题为:{{context['start-node'].question}}\n问题分类是:\n打招呼 \n售前咨询\n售后咨询\n其他咨询", + dialogue_number: 0 + } + } + }, + { + id: 'c94a8bfb-34b0-4b1b-8456-0a164870d382', + type: 'condition-node', + x: 1140, + y: 284, + properties: { + width: 600, + stepName: '判断器', + node_data: { + branch: [ + { + conditions: [ + { + field: ['e781559d-e54b-45d8-bcea-d2d426fd58a3', 'answer'], + compare: 'contain', + value: '打招呼 ' + } + ], + id: '5675', + type: 'IF', + condition: 'and' + }, + { + conditions: [ + { + field: ['e781559d-e54b-45d8-bcea-d2d426fd58a3', 'answer'], + compare: 'contain', + value: '售前咨询' + } + ], + type: 'ELSE IF 1', + id: '9947', + condition: 'and' + }, + { + conditions: [ + { + field: ['e781559d-e54b-45d8-bcea-d2d426fd58a3', 'answer'], + compare: 'contain', + value: '售后咨询' + } + ], + type: 'ELSE IF 2', + id: '5048', + condition: 'and' + }, + { conditions: [], id: '6750', type: 'ELSE', condition: 'and' } + ] + }, + barnch_condition_list: [ + { index: 0, height: 115.778, id: '5675' }, + { index: 1, height: 115.778, id: '9947' }, + { index: 2, height: 115.778, id: '5048' }, + { index: 3, height: 40, id: '6750' } + ] + } + }, + { + id: 'ec6f5581-fef3-45a1-8dbe-6611a8c9ccfc', + type: 'reply-node', + x: 1830, + y: -220, + properties: { + height: '', + stepName: '指定回复', + node_data: { + reply_type: 'content', + content: '你好我是ai只能机器人,很高兴为你服务', + fields: [] + } + } + }, + { + id: '2ac57a56-9150-4f04-a7b9-6390bdaade19', + type: 'search-dataset-node', + x: 1810, + y: 290, + properties: { + height: '', stepName: '知识库检索', - input: [{ key: '输入' }], - output: [{ key: '输出' }], fields: [ + { label: '段落列表', value: 'paragraph_list' }, + { label: '满足直接回答的段落列表', value: 'is_hit_handling_method_list' }, { label: '检索结果', value: 'data' }, - { label: '满足直接回答的分段内容', value: 'paragraph' } + { label: '满足直接回答的分段内容', value: 'directly_return' } ], node_data: { - dataset_id_list: [], + dataset_id_list: ['8ba47817-28a1-11ef-90fd-a8a1595801ab'], dataset_setting: { top_n: 3, similarity: 0.6, max_paragraph_char_number: 5000, search_mode: 'embedding' }, - question_reference_address: [] + question_reference_address: ['start-node', 'question'] } } }, { - id: '34902d3d-a3ff-497f-b8e1-0c34a44d7dd6', - type: 'condition-node', - x: 810, - y: 760, - + id: 'bd9dd852-d749-4b42-9b95-80f25b9a606d', + type: 'ai-chat-node', + x: 2430, + y: 310, + properties: { + height: '', + stepName: 'AI 对话', + fields: [{ label: 'AI 回答内容', value: 'answer' }], + node_data: { + model_id: '9bdd1ab3-135b-11ef-b688-a8a1595801ab', + system: '你是售前咨询知识库', + prompt: + "已知信息:\n{{context['2ac57a56-9150-4f04-a7b9-6390bdaade19'].data}}\n问题:\n{{context['start-node'].question}}", + dialogue_number: 0 + } + } + }, + { + id: '1cd54877-bfff-4791-b8f5-08c49f8bdf66', + type: 'search-dataset-node', + x: 1770, + y: 840, + properties: { + height: '', + stepName: '知识库检索', + fields: [ + { label: '段落列表', value: 'paragraph_list' }, + { label: '满足直接回答的段落列表', value: 'is_hit_handling_method_list' }, + { label: '检索结果', value: 'data' }, + { label: '满足直接回答的分段内容', value: 'directly_return' } + ], + node_data: { + dataset_id_list: ['188c3fa1-28a3-11ef-99e8-a8a1595801ab'], + dataset_setting: { + top_n: 3, + similarity: 0.6, + max_paragraph_char_number: 5000, + search_mode: 'embedding' + }, + question_reference_address: ['start-node', 'question'] + } + } + }, + { + id: 'e99869b2-251f-47a7-9966-c54ffb59b381', + type: 'condition-node', + x: 2310, + y: 930, properties: { - height: 200, width: 600, stepName: '判断器', - input: [{ key: '输入' }], - output: [{ key: '9208' }, { key: '1143' }, { key: '输出' }] - } - }, - { - id: '03597cb0-ed4c-4bcb-b25b-3b358f72b266', - type: 'ai-chat-node', - x: 1330, - y: 690, - properties: { - height: '', - stepName: 'AI 对话', - input: [{ key: '输入' }], - output: [{ key: '输出' }], node_data: { - model_id: '', - system: '', - prompt: - '已知信息:\n{data}\n回答要求:\n- 请使用简洁且专业的语言来回答用户的问题。\n- 如果你不知道答案,请回答“没有在知识库中查找到相关信息,建议咨询相关技术支持或参考官方文档进行操作”。\n- 避免提及你是从已知信息中获得的知识。\n- 请保证答案与已知信息中描述的一致。\n- 请使用 Markdown 语法优化答案的格式。\n- 已知信息中的图片、链接地址和脚本语言请直接返回。\n- 请使用与问题相同的语言来回答。\n问题:\n{question}', - dialogue_number: 1 - } + branch: [ + { + conditions: [ + { + field: ['1cd54877-bfff-4791-b8f5-08c49f8bdf66', 'is_hit_handling_method_list'], + compare: 'ge', + value: '1' + } + ], + id: '3014', + type: 'IF', + condition: 'and' + }, + { + conditions: [ + { + field: ['1cd54877-bfff-4791-b8f5-08c49f8bdf66', 'paragraph_list'], + compare: 'ge', + value: '1' + } + ], + type: 'ELSE IF 1', + id: '4658', + condition: 'and' + }, + { conditions: [], id: '8871', type: 'ELSE', condition: 'and' } + ] + }, + barnch_condition_list: [ + { index: 0, height: 115.778, id: '3014' }, + { index: 1, height: 115.778, id: '4658' }, + { index: 2, height: 40, id: '8871' } + ] } }, { - id: '6649ee86-348c-4d68-9cad-71f0612beb05', - type: 'ai-chat-node', - x: 1320, - y: 990, - properties: { - height: '', - stepName: 'AI 对话', - node_data: { - model_id: '', - system: '', - prompt: - '已知信息:\n{data}\n回答要求:\n- 请使用简洁且专业的语言来回答用户的问题。\n- 如果你不知道答案,请回答“没有在知识库中查找到相关信息,建议咨询相关技术支持或参考官方文档进行操作”。\n- 避免提及你是从已知信息中获得的知识。\n- 请保证答案与已知信息中描述的一致。\n- 请使用 Markdown 语法优化答案的格式。\n- 已知信息中的图片、链接地址和脚本语言请直接返回。\n- 请使用与问题相同的语言来回答。\n问题:\n{question}', - dialogue_number: 1 - } - } - }, - { - id: '0004a9c9-e2fa-40ac-9215-2e1ad04f09c5', - type: 'ai-chat-node', - x: 1360, - y: 1300, - properties: { - height: '', - stepName: 'AI 对话', - node_data: { - model_id: '', - system: '', - prompt: - '已知信息:\n{data}\n回答要求:\n- 请使用简洁且专业的语言来回答用户的问题。\n- 如果你不知道答案,请回答“没有在知识库中查找到相关信息,建议咨询相关技术支持或参考官方文档进行操作”。\n- 避免提及你是从已知信息中获得的知识。\n- 请保证答案与已知信息中描述的一致。\n- 请使用 Markdown 语法优化答案的格式。\n- 已知信息中的图片、链接地址和脚本语言请直接返回。\n- 请使用与问题相同的语言来回答。\n问题:\n{question}', - dialogue_number: 1 - } - } - }, - { - id: '30c16d31-3881-48cd-991e-da3f99c45681', + id: '62ab766b-b218-4bea-895f-b7e83614c8b7', type: 'reply-node', - x: 990, - y: 300, + x: 2940, + y: 530, properties: { height: '', stepName: '指定回复', - input: [{ key: '' }], - output: [{ key: '' }] + node_data: { + reply_type: 'referencing', + content: '', + fields: ['1cd54877-bfff-4791-b8f5-08c49f8bdf66', 'directly_return'] + } + } + }, + { + id: '04837361-30ea-41bd-96bc-768ee58d69d6', + type: 'ai-chat-node', + x: 2930, + y: 1000, + properties: { + height: '', + stepName: 'AI 对话', + fields: [{ label: 'AI 回答内容', value: 'answer' }], + node_data: { + model_id: '9bdd1ab3-135b-11ef-b688-a8a1595801ab', + system: '你是售后工程师', + prompt: + "已知信息:\n{{context['1cd54877-bfff-4791-b8f5-08c49f8bdf66'].data}}\n问题:\n{{context['start-node'].question}}", + dialogue_number: 0 + } + } + }, + { + id: 'fe4d14fd-9aeb-40ad-b7e0-3d88bf1c5933', + type: 'reply-node', + x: 2960, + y: 1470, + properties: { + height: '', + stepName: '指定回复', + node_data: { reply_type: 'content', content: '未找到相关内容', fields: [] } + } + }, + { + id: 'c9b74adb-e219-4d2b-8fd5-ecc2bac8786e', + type: 'ai-chat-node', + x: 1740, + y: 1470, + properties: { + height: '', + stepName: 'AI 对话', + fields: [{ label: 'AI 回答内容', value: 'answer' }], + node_data: { + model_id: '9bdd1ab3-135b-11ef-b688-a8a1595801ab', + system: '', + prompt: "{{context['start-node'].question}}", + dialogue_number: 0 + } } } ], - edges: [] + edges: [ + { + id: '21096f2c-d89f-4fb3-bdbe-61484b0686d4', + type: 'app-edge', + sourceNodeId: 'start-node', + targetNodeId: 'e781559d-e54b-45d8-bcea-d2d426fd58a3', + startPoint: { x: 340, y: 720 }, + endPoint: { x: 440, y: 560 }, + properties: {}, + pointsList: [ + { x: 340, y: 720 }, + { x: 450, y: 720 }, + { x: 330, y: 560 }, + { x: 440, y: 560 } + ], + sourceAnchorId: 'start-node_right', + targetAnchorId: 'e781559d-e54b-45d8-bcea-d2d426fd58a3_left' + }, + { + id: '6019001b-f9e8-4081-9538-ef1e717eac7b', + type: 'app-edge', + sourceNodeId: 'e781559d-e54b-45d8-bcea-d2d426fd58a3', + targetNodeId: 'c94a8bfb-34b0-4b1b-8456-0a164870d382', + startPoint: { x: 760, y: 560 }, + endPoint: { x: 850, y: 284 }, + properties: {}, + pointsList: [ + { x: 760, y: 560 }, + { x: 870, y: 560 }, + { x: 740, y: 284 }, + { x: 850, y: 284 } + ], + sourceAnchorId: 'e781559d-e54b-45d8-bcea-d2d426fd58a3_right', + targetAnchorId: 'c94a8bfb-34b0-4b1b-8456-0a164870d382_left' + }, + { + id: '6dba7e71-c14c-427e-b7de-09f3b1064291', + type: 'app-edge', + sourceNodeId: 'c94a8bfb-34b0-4b1b-8456-0a164870d382', + targetNodeId: 'ec6f5581-fef3-45a1-8dbe-6611a8c9ccfc', + startPoint: { x: 1430, y: 127.33350000000002 }, + endPoint: { x: 1670, y: -220 }, + properties: {}, + pointsList: [ + { x: 1430, y: 127.33350000000002 }, + { x: 1540, y: 127.33350000000002 }, + { x: 1560, y: -220 }, + { x: 1670, y: -220 } + ], + sourceAnchorId: 'c94a8bfb-34b0-4b1b-8456-0a164870d382_5675_right', + targetAnchorId: 'ec6f5581-fef3-45a1-8dbe-6611a8c9ccfc_left' + }, + { + id: '45a83361-1dfe-499e-8407-8c1670386b04', + type: 'app-edge', + sourceNodeId: 'c94a8bfb-34b0-4b1b-8456-0a164870d382', + targetNodeId: '2ac57a56-9150-4f04-a7b9-6390bdaade19', + startPoint: { x: 1430, y: 251.11150000000004 }, + endPoint: { x: 1650, y: 290 }, + properties: {}, + pointsList: [ + { x: 1430, y: 251.11150000000004 }, + { x: 1540, y: 251.11150000000004 }, + { x: 1540, y: 290 }, + { x: 1650, y: 290 } + ], + sourceAnchorId: 'c94a8bfb-34b0-4b1b-8456-0a164870d382_9947_right', + targetAnchorId: '2ac57a56-9150-4f04-a7b9-6390bdaade19_left' + }, + { + id: 'b18a10f9-df1a-415b-b419-cf44229b3345', + type: 'app-edge', + sourceNodeId: '2ac57a56-9150-4f04-a7b9-6390bdaade19', + targetNodeId: 'bd9dd852-d749-4b42-9b95-80f25b9a606d', + startPoint: { x: 1970, y: 290 }, + endPoint: { x: 2270, y: 310 }, + properties: {}, + pointsList: [ + { x: 1970, y: 290 }, + { x: 2080, y: 290 }, + { x: 2160, y: 310 }, + { x: 2270, y: 310 } + ], + sourceAnchorId: '2ac57a56-9150-4f04-a7b9-6390bdaade19_right', + targetAnchorId: 'bd9dd852-d749-4b42-9b95-80f25b9a606d_left' + }, + { + id: 'd9b31737-a480-48e5-84b6-a8556d1d68a5', + type: 'app-edge', + sourceNodeId: 'c94a8bfb-34b0-4b1b-8456-0a164870d382', + targetNodeId: '1cd54877-bfff-4791-b8f5-08c49f8bdf66', + startPoint: { x: 1430, y: 374.8895 }, + endPoint: { x: 1610, y: 840 }, + properties: {}, + pointsList: [ + { x: 1430, y: 374.8895 }, + { x: 1540, y: 374.8895 }, + { x: 1500, y: 840 }, + { x: 1610, y: 840 } + ], + sourceAnchorId: 'c94a8bfb-34b0-4b1b-8456-0a164870d382_5048_right', + targetAnchorId: '1cd54877-bfff-4791-b8f5-08c49f8bdf66_left' + }, + { + id: '32d36445-b2b8-4472-9c86-3a9c147ceea2', + type: 'app-edge', + sourceNodeId: '1cd54877-bfff-4791-b8f5-08c49f8bdf66', + targetNodeId: 'e99869b2-251f-47a7-9966-c54ffb59b381', + startPoint: { x: 1930, y: 840 }, + endPoint: { x: 2020, y: 930 }, + properties: {}, + pointsList: [ + { x: 1930, y: 840 }, + { x: 2040, y: 840 }, + { x: 1910, y: 930 }, + { x: 2020, y: 930 } + ], + sourceAnchorId: '1cd54877-bfff-4791-b8f5-08c49f8bdf66_right', + targetAnchorId: 'e99869b2-251f-47a7-9966-c54ffb59b381_left' + }, + { + id: '98c9014f-0bfc-4595-9c79-48ea785dc6cd', + type: 'app-edge', + sourceNodeId: 'e99869b2-251f-47a7-9966-c54ffb59b381', + targetNodeId: '62ab766b-b218-4bea-895f-b7e83614c8b7', + startPoint: { x: 2600, y: 835.2225 }, + endPoint: { x: 2780, y: 530 }, + properties: {}, + pointsList: [ + { x: 2600, y: 835.2225 }, + { x: 2710, y: 835.2225 }, + { x: 2670, y: 530 }, + { x: 2780, y: 530 } + ], + sourceAnchorId: 'e99869b2-251f-47a7-9966-c54ffb59b381_3014_right', + targetAnchorId: '62ab766b-b218-4bea-895f-b7e83614c8b7_left' + }, + { + id: '57e76e75-5c7f-42cb-a120-cc890243bb17', + type: 'app-edge', + sourceNodeId: 'e99869b2-251f-47a7-9966-c54ffb59b381', + targetNodeId: '04837361-30ea-41bd-96bc-768ee58d69d6', + startPoint: { x: 2600, y: 959.0005 }, + endPoint: { x: 2770, y: 1000 }, + properties: {}, + pointsList: [ + { x: 2600, y: 959.0005 }, + { x: 2710, y: 959.0005 }, + { x: 2660, y: 1000 }, + { x: 2770, y: 1000 } + ], + sourceAnchorId: 'e99869b2-251f-47a7-9966-c54ffb59b381_4658_right', + targetAnchorId: '04837361-30ea-41bd-96bc-768ee58d69d6_left' + }, + { + id: '8becdf8e-243a-482a-bdf6-22e947aa9bd2', + type: 'app-edge', + sourceNodeId: 'e99869b2-251f-47a7-9966-c54ffb59b381', + targetNodeId: 'fe4d14fd-9aeb-40ad-b7e0-3d88bf1c5933', + startPoint: { x: 2600, y: 1044.8895 }, + endPoint: { x: 2800, y: 1470 }, + properties: {}, + pointsList: [ + { x: 2600, y: 1044.8895 }, + { x: 2710, y: 1044.8895 }, + { x: 2690, y: 1470 }, + { x: 2800, y: 1470 } + ], + sourceAnchorId: 'e99869b2-251f-47a7-9966-c54ffb59b381_8871_right', + targetAnchorId: 'fe4d14fd-9aeb-40ad-b7e0-3d88bf1c5933_left' + }, + { + id: 'f0277552-0d5a-4642-838f-989e59afe350', + type: 'app-edge', + sourceNodeId: 'c94a8bfb-34b0-4b1b-8456-0a164870d382', + targetNodeId: 'c9b74adb-e219-4d2b-8fd5-ecc2bac8786e', + startPoint: { x: 1430, y: 460.7785 }, + endPoint: { x: 1580, y: 1470 }, + properties: {}, + pointsList: [ + { x: 1430, y: 460.7785 }, + { x: 1540, y: 460.7785 }, + { x: 1470, y: 1470 }, + { x: 1580, y: 1470 } + ], + sourceAnchorId: 'c94a8bfb-34b0-4b1b-8456-0a164870d382_6750_right', + targetAnchorId: 'c9b74adb-e219-4d2b-8fd5-ecc2bac8786e_left' + } + ] } + const lf = ref() onMounted(() => { diff --git a/ui/src/workflow/nodes/condition-node/index.ts b/ui/src/workflow/nodes/condition-node/index.ts index b3cf5fea6..bcb21b91f 100644 --- a/ui/src/workflow/nodes/condition-node/index.ts +++ b/ui/src/workflow/nodes/condition-node/index.ts @@ -41,7 +41,7 @@ class ConditionModel extends AppNodeModel { anchors.push({ x: x - width / 2 + 10, y: y, - id: `${id}`, + id: `${id}_left`, edgeAddable: false, type: 'left' })