diff --git a/apps/application/flow/default_workflow.json b/apps/application/flow/default_workflow.json index 651229da5..890f91f34 100644 --- a/apps/application/flow/default_workflow.json +++ b/apps/application/flow/default_workflow.json @@ -1,202 +1,25 @@ { - "edges": [ - { - "id": "328b53ca-1f8e-402a-accc-5652e3bd7556", - "type": "app-edge", - "endPoint": { - "x": 560, - "y": 220 - }, - "pointsList": [ - { - "x": 260, - "y": 220 - }, - { - "x": 370, - "y": 220 - }, - { - "x": 450, - "y": 220 - }, - { - "x": 560, - "y": 220 - } - ], - "properties": {}, - "startPoint": { - "x": 260, - "y": 220 - }, - "sourceNodeId": "start-node", - "targetNodeId": "c8903650-67e0-42a3-875f-6896b33f8916", - "sourceAnchorId": "start-node_right", - "targetAnchorId": "c8903650-67e0-42a3-875f-6896b33f8916_left" - }, - { - "id": "9979350a-4321-4f94-91e4-0c755db29e0c", - "type": "app-edge", - "endPoint": { - "x": 960, - "y": 220 - }, - "pointsList": [ - { - "x": 880, - "y": 220 - }, - { - "x": 990, - "y": 220 - }, - { - "x": 850, - "y": 220 - }, - { - "x": 960, - "y": 220 - } - ], - "properties": {}, - "startPoint": { - "x": 880, - "y": 220 - }, - "sourceNodeId": "c8903650-67e0-42a3-875f-6896b33f8916", - "targetNodeId": "ce724e9f-c741-4f22-a41c-d43247193629", - "sourceAnchorId": "c8903650-67e0-42a3-875f-6896b33f8916_right", - "targetAnchorId": "ce724e9f-c741-4f22-a41c-d43247193629_left" - }, - { - "id": "3dc74fbf-b4b1-41ab-9d65-b3476d05403c", - "type": "app-edge", - "endPoint": { - "x": 1640, - "y": -330 - }, - "pointsList": [ - { - "x": 1540, - "y": 125.5455 - }, - { - "x": 1650, - "y": 125.5455 - }, - { - "x": 1530, - "y": -330 - }, - { - "x": 1640, - "y": -330 - } - ], - "properties": {}, - "startPoint": { - "x": 1540, - "y": 125.5455 - }, - "sourceNodeId": "ce724e9f-c741-4f22-a41c-d43247193629", - "targetNodeId": "8839b489-3949-4d27-b932-896392d3dff5", - "sourceAnchorId": "ce724e9f-c741-4f22-a41c-d43247193629_6351_right", - "targetAnchorId": "8839b489-3949-4d27-b932-896392d3dff5_left" - }, - { - "id": "2e1229ab-1be7-4e98-8032-db3bbe0e4c01", - "type": "app-edge", - "endPoint": { - "x": 1650, - "y": 250 - }, - "pointsList": [ - { - "x": 1540, - "y": 249.00050000000002 - }, - { - "x": 1650, - "y": 249.00050000000002 - }, - { - "x": 1540, - "y": 250 - }, - { - "x": 1650, - "y": 250 - } - ], - "properties": {}, - "startPoint": { - "x": 1540, - "y": 249.00050000000002 - }, - "sourceNodeId": "ce724e9f-c741-4f22-a41c-d43247193629", - "targetNodeId": "bf0e1bca-d19a-4bb3-b269-b37f9fa1bd91", - "sourceAnchorId": "ce724e9f-c741-4f22-a41c-d43247193629_5186_right", - "targetAnchorId": "bf0e1bca-d19a-4bb3-b269-b37f9fa1bd91_left" - }, - { - "id": "f689d923-641f-4039-b307-645bd3fbdf4a", - "type": "app-edge", - "endPoint": { - "x": 1650, - "y": 860 - }, - "pointsList": [ - { - "x": 1540, - "y": 334.728 - }, - { - "x": 1650, - "y": 334.728 - }, - { - "x": 1540, - "y": 860 - }, - { - "x": 1650, - "y": 860 - } - ], - "properties": {}, - "startPoint": { - "x": 1540, - "y": 334.728 - }, - "sourceNodeId": "ce724e9f-c741-4f22-a41c-d43247193629", - "targetNodeId": "f9cfacd9-2301-431d-a6ea-876717ccaffc", - "sourceAnchorId": "ce724e9f-c741-4f22-a41c-d43247193629_7119_right", - "targetAnchorId": "f9cfacd9-2301-431d-a6ea-876717ccaffc_left" - } - ], "nodes": [ { - "x": 130, - "y": -230, "id": "base-node", "type": "base-node", + "x": 240, + "y": 40, "properties": { "height": 200, "stepName": "基本信息", "node_data": { - "desc": "test", - "name": "test111", + "desc": "", + "name": "test", "prologue": "您好,我是 MaxKB 小助手,您可以向我提出 MaxKB 使用问题。\n- MaxKB 主要功能有什么?\n- MaxKB 支持哪些大语言模型?\n- MaxKB 支持哪些文档类型?" } } }, { - "x": 100, - "y": 220, "id": "start-node", "type": "start-node", + "x": 240, + "y": 420, "properties": { "fields": [ { @@ -211,10 +34,10 @@ } }, { - "x": 720, - "y": 220, "id": "c8903650-67e0-42a3-875f-6896b33f8916", "type": "search-dataset-node", + "x": 670, + "y": 150, "properties": { "fields": [ { @@ -259,10 +82,10 @@ } }, { - "x": 1250, - "y": 220, "id": "ce724e9f-c741-4f22-a41c-d43247193629", "type": "condition-node", + "x": 1170, + "y": 150, "properties": { "width": 600, "stepName": "判断器", @@ -308,28 +131,28 @@ }, "branch_condition_list": [ { - "id": "6351", "index": 0, - "height": 115.455 + "height": 115.455, + "id": "6351" }, { - "id": "5186", "index": 1, - "height": 115.455 + "height": 115.455, + "id": "5186" }, { - "id": "7119", "index": 2, - "height": 40 + "height": 40, + "id": "7119" } ] } }, { - "x": 1800, - "y": -330, "id": "8839b489-3949-4d27-b932-896392d3dff5", "type": "reply-node", + "x": 1820, + "y": -280, "properties": { "stepName": "指定回复", "node_data": { @@ -343,10 +166,10 @@ } }, { - "x": 1810, - "y": 250, "id": "bf0e1bca-d19a-4bb3-b269-b37f9fa1bd91", "type": "ai-chat-node", + "x": 1820, + "y": 180, "properties": { "fields": [ { @@ -360,24 +183,208 @@ "node_data": { "prompt": "已知信息:\n{{知识库检索.data}}\n问题:\n{{开始.question}}", "system": "", - "model_id": "", "dialogue_number": 0 } } }, { - "x": 1810, - "y": 860, - "id": "f9cfacd9-2301-431d-a6ea-876717ccaffc", - "type": "reply-node", + "id": "ec021e3e-3cd9-4639-959d-33c928bba3aa", + "type": "ai-chat-node", + "x": 1820, + "y": 840, "properties": { - "stepName": "指定回复1", + "fields": [ + { + "label": "AI 回答内容", + "value": "answer", + "globeLabel": "{{AI 对话1.answer}}", + "globeValue": "{{context['ec021e3e-3cd9-4639-959d-33c928bba3aa'].answer}}" + } + ], + "stepName": "AI 对话1", "node_data": { - "fields": [], - "content": "未找到相关信息", - "reply_type": "content" + "prompt": "{{开始.question}}", + "system": "", + "dialogue_number": 1 } } } + ], + "edges": [ + { + "id": "328b53ca-1f8e-402a-accc-5652e3bd7556", + "type": "app-edge", + "sourceNodeId": "start-node", + "targetNodeId": "c8903650-67e0-42a3-875f-6896b33f8916", + "startPoint": { + "x": 400, + "y": 420 + }, + "endPoint": { + "x": 510, + "y": 150 + }, + "properties": {}, + "pointsList": [ + { + "x": 400, + "y": 420 + }, + { + "x": 510, + "y": 420 + }, + { + "x": 400, + "y": 150 + }, + { + "x": 510, + "y": 150 + } + ], + "sourceAnchorId": "start-node_right", + "targetAnchorId": "c8903650-67e0-42a3-875f-6896b33f8916_left" + }, + { + "id": "9979350a-4321-4f94-91e4-0c755db29e0c", + "type": "app-edge", + "sourceNodeId": "c8903650-67e0-42a3-875f-6896b33f8916", + "targetNodeId": "ce724e9f-c741-4f22-a41c-d43247193629", + "startPoint": { + "x": 830, + "y": 150 + }, + "endPoint": { + "x": 880, + "y": 150 + }, + "properties": {}, + "pointsList": [ + { + "x": 830, + "y": 150 + }, + { + "x": 940, + "y": 150 + }, + { + "x": 770, + "y": 150 + }, + { + "x": 880, + "y": 150 + } + ], + "sourceAnchorId": "c8903650-67e0-42a3-875f-6896b33f8916_right", + "targetAnchorId": "ce724e9f-c741-4f22-a41c-d43247193629_left" + }, + { + "id": "3dc74fbf-b4b1-41ab-9d65-b3476d05403c", + "type": "app-edge", + "sourceNodeId": "ce724e9f-c741-4f22-a41c-d43247193629", + "targetNodeId": "8839b489-3949-4d27-b932-896392d3dff5", + "startPoint": { + "x": 1460, + "y": 55.54549999999995 + }, + "endPoint": { + "x": 1660, + "y": -280 + }, + "properties": {}, + "pointsList": [ + { + "x": 1460, + "y": 55.54549999999995 + }, + { + "x": 1570, + "y": 55.54549999999995 + }, + { + "x": 1550, + "y": -280 + }, + { + "x": 1660, + "y": -280 + } + ], + "sourceAnchorId": "ce724e9f-c741-4f22-a41c-d43247193629_6351_right", + "targetAnchorId": "8839b489-3949-4d27-b932-896392d3dff5_left" + }, + { + "id": "2e1229ab-1be7-4e98-8032-db3bbe0e4c01", + "type": "app-edge", + "sourceNodeId": "ce724e9f-c741-4f22-a41c-d43247193629", + "targetNodeId": "bf0e1bca-d19a-4bb3-b269-b37f9fa1bd91", + "startPoint": { + "x": 1460, + "y": 179.00050000000002 + }, + "endPoint": { + "x": 1660, + "y": 180 + }, + "properties": {}, + "pointsList": [ + { + "x": 1460, + "y": 179.00050000000002 + }, + { + "x": 1570, + "y": 179.00050000000002 + }, + { + "x": 1550, + "y": 180 + }, + { + "x": 1660, + "y": 180 + } + ], + "sourceAnchorId": "ce724e9f-c741-4f22-a41c-d43247193629_5186_right", + "targetAnchorId": "bf0e1bca-d19a-4bb3-b269-b37f9fa1bd91_left" + }, + { + "id": "50a3ec05-c127-4703-85cd-757dc1650882", + "type": "app-edge", + "sourceNodeId": "ce724e9f-c741-4f22-a41c-d43247193629", + "targetNodeId": "ec021e3e-3cd9-4639-959d-33c928bba3aa", + "startPoint": { + "x": 1460, + "y": 264.728 + }, + "endPoint": { + "x": 1660, + "y": 840 + }, + "properties": {}, + "pointsList": [ + { + "x": 1460, + "y": 264.728 + }, + { + "x": 1570, + "y": 264.728 + }, + { + "x": 1550, + "y": 840 + }, + { + "x": 1660, + "y": 840 + } + ], + "sourceAnchorId": "ce724e9f-c741-4f22-a41c-d43247193629_7119_right", + "targetAnchorId": "ec021e3e-3cd9-4639-959d-33c928bba3aa_left" + } ] } \ No newline at end of file diff --git a/apps/application/migrations/0009_application_type_application_work_flow.py b/apps/application/migrations/0009_application_type_application_work_flow.py deleted file mode 100644 index bad9e9bec..000000000 --- a/apps/application/migrations/0009_application_type_application_work_flow.py +++ /dev/null @@ -1,23 +0,0 @@ -# Generated by Django 4.1.13 on 2024-06-17 09:41 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('application', '0008_chat_is_deleted'), - ] - - operations = [ - migrations.AddField( - model_name='application', - name='type', - field=models.CharField(choices=[('SIMPLE', '简易'), ('WORK_FLOW', '工作流')], default='SIMPLE', max_length=256, verbose_name='应用类型'), - ), - migrations.AddField( - model_name='application', - name='work_flow', - field=models.JSONField(default=dict, verbose_name='工作流数据'), - ), - ] diff --git a/apps/application/migrations/0011_remove_application_is_ready_workflowversion.py b/apps/application/migrations/0009_application_type_application_work_flow_and_more.py similarity index 66% rename from apps/application/migrations/0011_remove_application_is_ready_workflowversion.py rename to apps/application/migrations/0009_application_type_application_work_flow_and_more.py index 22bbe83ec..5d0bf0c9f 100644 --- a/apps/application/migrations/0011_remove_application_is_ready_workflowversion.py +++ b/apps/application/migrations/0009_application_type_application_work_flow_and_more.py @@ -1,4 +1,4 @@ -# Generated by Django 4.1.13 on 2024-06-18 15:20 +# Generated by Django 4.1.13 on 2024-06-25 16:30 from django.db import migrations, models import django.db.models.deletion @@ -8,13 +8,19 @@ import uuid class Migration(migrations.Migration): dependencies = [ - ('application', '0010_application_is_ready'), + ('application', '0008_chat_is_deleted'), ] operations = [ - migrations.RemoveField( + migrations.AddField( model_name='application', - name='is_ready', + name='type', + field=models.CharField(choices=[('SIMPLE', '简易'), ('WORK_FLOW', '工作流')], default='SIMPLE', max_length=256, verbose_name='应用类型'), + ), + migrations.AddField( + model_name='application', + name='work_flow', + field=models.JSONField(default=dict, verbose_name='工作流数据'), ), migrations.CreateModel( name='WorkFlowVersion', diff --git a/apps/application/migrations/0010_application_is_ready.py b/apps/application/migrations/0010_application_is_ready.py deleted file mode 100644 index d6aba10db..000000000 --- a/apps/application/migrations/0010_application_is_ready.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 4.1.13 on 2024-06-17 16:04 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('application', '0009_application_type_application_work_flow'), - ] - - operations = [ - migrations.AddField( - model_name='application', - name='is_ready', - field=models.BooleanField(default=True, verbose_name='是否就绪'), - ), - ] diff --git a/ui/src/workflow/nodes/ai-chat-node/index.vue b/ui/src/workflow/nodes/ai-chat-node/index.vue index bd64db2d2..86e111a16 100644 --- a/ui/src/workflow/nodes/ai-chat-node/index.vue +++ b/ui/src/workflow/nodes/ai-chat-node/index.vue @@ -154,8 +154,7 @@ const { } = app.config.globalProperties.$route as any // @ts-ignore -const defaultPrompt = - '已知信息:\n{data}\n回答要求:\n- 请使用简洁且专业的语言来回答用户的问题。\n- 如果你不知道答案,请回答“没有在知识库中查找到相关信息,建议咨询相关技术支持或参考官方文档进行操作”。\n- 避免提及你是从已知信息中获得的知识。\n- 请保证答案与已知信息中描述的一致。\n- 请使用 Markdown 语法优化答案的格式。\n- 已知信息中的图片、链接地址和脚本语言请直接返回。\n- 请使用与问题相同的语言来回答。\n问题:\n{question}' +const defaultPrompt = '{{开始.question}}' const form = { model_id: '', system: '', diff --git a/ui/src/workflow/nodes/question-node/index.vue b/ui/src/workflow/nodes/question-node/index.vue index c9895fe23..c3117143e 100644 --- a/ui/src/workflow/nodes/question-node/index.vue +++ b/ui/src/workflow/nodes/question-node/index.vue @@ -153,8 +153,7 @@ const { } = app.config.globalProperties.$route as any // @ts-ignore -const defaultPrompt = - '已知信息:\n{data}\n回答要求:\n- 请使用简洁且专业的语言来回答用户的问题。\n- 如果你不知道答案,请回答“没有在知识库中查找到相关信息,建议咨询相关技术支持或参考官方文档进行操作”。\n- 避免提及你是从已知信息中获得的知识。\n- 请保证答案与已知信息中描述的一致。\n- 请使用 Markdown 语法优化答案的格式。\n- 已知信息中的图片、链接地址和脚本语言请直接返回。\n- 请使用与问题相同的语言来回答。\n问题:\n{question}' +const defaultPrompt = '{{开始.question}}' const form = { model_id: '', system: '',