From 736923169043db6d7384b34a16cb7ccb93b4f195 Mon Sep 17 00:00:00 2001 From: shaohuzhang1 Date: Wed, 13 Nov 2024 16:54:56 +0800 Subject: [PATCH 01/11] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E7=94=BB?= =?UTF-8?q?=E5=B8=83=E4=B8=80=E4=BB=B6=E7=BE=8E=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/package.json | 1 + .../items/table/TableCheckbox.vue | 6 +- ui/src/components/icons/index.ts | 22 ++++++ ui/src/components/markdown/EchartsRander.vue | 7 +- ui/src/components/markdown/FormRander.vue | 14 ++-- ui/src/components/markdown/MdRenderer.vue | 2 +- ui/src/workflow/common/NodeControl.vue | 6 ++ ui/src/workflow/common/app-node.ts | 20 ++++++ ui/src/workflow/index.vue | 4 +- ui/src/workflow/plugins/dagre.ts | 69 +++++++++++++++++++ 10 files changed, 134 insertions(+), 17 deletions(-) create mode 100644 ui/src/workflow/plugins/dagre.ts diff --git a/ui/package.json b/ui/package.json index e6067f69c..3203bd466 100644 --- a/ui/package.json +++ b/ui/package.json @@ -17,6 +17,7 @@ "@ctrl/tinycolor": "^4.1.0", "@logicflow/core": "^1.2.27", "@logicflow/extension": "^1.2.27", + "@antv/layout": "^0.3.1", "@vueuse/core": "^10.9.0", "@wecom/jssdk": "^2.1.0", "axios": "^0.28.0", diff --git a/ui/src/components/dynamics-form/items/table/TableCheckbox.vue b/ui/src/components/dynamics-form/items/table/TableCheckbox.vue index 12db31a49..29641ac24 100644 --- a/ui/src/components/dynamics-form/items/table/TableCheckbox.vue +++ b/ui/src/components/dynamics-form/items/table/TableCheckbox.vue @@ -72,7 +72,7 @@ const props = defineProps<{ modelValue?: Array }>() const rowTemp = ref() -const evalF = (text: string, row: any) => { +const evalF: (text: string, row: any) => string = (text: string, row: any) => { rowTemp.value = row return eval(text) } @@ -167,8 +167,8 @@ watch( const activeText = computed(() => { if (props.modelValue) { - const rows = option_list.value.filter( - (f: any) => props.modelValue?.includes(f[valueField.value]) + const rows = option_list.value.filter((f: any) => + props.modelValue?.includes(f[valueField.value]) ) if (rows) { if (rows.length > 3) { diff --git a/ui/src/components/icons/index.ts b/ui/src/components/icons/index.ts index 35e94fafd..16c337c9b 100644 --- a/ui/src/components/icons/index.ts +++ b/ui/src/components/icons/index.ts @@ -1228,6 +1228,28 @@ export const iconMap: any = { ]) } }, + + 'app-beautify': { + iconReader: () => { + return h('i', [ + h( + 'svg', + { + style: { height: '100%', width: '100%' }, + viewBox: '0 0 1024 1024', + version: '1.1', + xmlns: 'http://www.w3.org/2000/svg' + }, + [ + h('path', { + d: 'M739.6864 689.92l4.2496 3.584 136.4992 135.936a34.1504 34.1504 0 0 1-43.9296 51.968l-4.1984-3.584-136.5504-135.936a34.1504 34.1504 0 0 1 43.9296-51.968zM663.4496 151.552a34.1504 34.1504 0 0 1 51.2512 30.464l-5.9392 216.6272 156.4672 146.1248a34.1504 34.1504 0 0 1-8.6528 55.808l-4.8128 1.792-202.8032 61.0816-87.4496 197.12a34.1504 34.1504 0 0 1-56.32 9.216l-3.2768-4.096-119.5008-178.432-209.9712-24.064a34.1504 34.1504 0 0 1-26.1632-50.176l2.7648-4.3008 129.28-171.7248-42.5472-212.3776a34.1504 34.1504 0 0 1 40.448-40.1408l4.6592 1.3312 198.912 72.3456z m-18.6368 89.7536l-144.5376 83.968a34.1504 34.1504 0 0 1-28.8256 2.56L314.5728 270.592l33.792 167.8848c1.4848 7.68 0.3584 15.5136-3.1744 22.3232l-3.072 4.9152-102.656 136.2944 166.4 19.1488c8.2944 0.9216 15.872 4.864 21.4016 10.9568l3.072 3.9424 93.8496 140.032 68.7104-154.7776a34.1504 34.1504 0 0 1 16.7936-17.0496l4.608-1.792 160.9216-48.4864-124.2624-116.0192a34.1504 34.1504 0 0 1-10.4448-20.0704l-0.3584-5.7856 4.6592-170.9056z', + fill: 'currentColor' + }) + ] + ) + ]) + } + } // 'app-history-outlined': { // iconReader: () => { // return h('i', [ diff --git a/ui/src/components/markdown/EchartsRander.vue b/ui/src/components/markdown/EchartsRander.vue index 6e3d2e87d..f008cdaa0 100644 --- a/ui/src/components/markdown/EchartsRander.vue +++ b/ui/src/components/markdown/EchartsRander.vue @@ -7,12 +7,7 @@ import { onMounted, nextTick, watch, onBeforeUnmount, ref } from 'vue' import * as echarts from 'echarts' const tmp = ref() -const props = defineProps({ - option: { - type: String, - required: true - } -}) +const props = defineProps<{ option: string }>() const chartsRef = ref() const style = ref({ diff --git a/ui/src/components/markdown/FormRander.vue b/ui/src/components/markdown/FormRander.vue index dcff8f512..7bea3c7ed 100644 --- a/ui/src/components/markdown/FormRander.vue +++ b/ui/src/components/markdown/FormRander.vue @@ -20,7 +20,7 @@ import { computed, ref } from 'vue' import DynamicsForm from '@/components/dynamics-form/index.vue' const props = defineProps<{ form_setting: string - sendMessage: (question: string, type: 'old' | 'new', other_params_data?: any) => void + sendMessage?: (question: string, type: 'old' | 'new', other_params_data?: any) => void }>() const form_setting_data = computed(() => { if (props.form_setting) { @@ -68,11 +68,13 @@ const submit = () => { dynamicsFormRef.value?.validate().then(() => { _submit.value = true const setting = JSON.parse(props.form_setting) - props.sendMessage('', 'old', { - runtime_node_id: setting.runtime_node_id, - chat_record_id: setting.chat_record_id, - node_data: form_data.value - }) + if (props.sendMessage) { + props.sendMessage('', 'old', { + runtime_node_id: setting.runtime_node_id, + chat_record_id: setting.chat_record_id, + node_data: form_data.value + }) + } }) } diff --git a/ui/src/components/markdown/MdRenderer.vue b/ui/src/components/markdown/MdRenderer.vue index f8faf3b2d..3843d3b7d 100644 --- a/ui/src/components/markdown/MdRenderer.vue +++ b/ui/src/components/markdown/MdRenderer.vue @@ -15,7 +15,7 @@ :option="item.content" > diff --git a/ui/src/workflow/common/NodeControl.vue b/ui/src/workflow/common/NodeControl.vue index ac142691d..4555dda97 100644 --- a/ui/src/workflow/common/NodeControl.vue +++ b/ui/src/workflow/common/NodeControl.vue @@ -11,6 +11,9 @@ + + + @@ -30,5 +33,8 @@ function fitView() { props.lf?.resetTranslate() props.lf?.fitView() } +const layout = () => { + props.lf?.extension.dagre.layout() +} diff --git a/ui/src/workflow/common/app-node.ts b/ui/src/workflow/common/app-node.ts index f720ad422..3009039a9 100644 --- a/ui/src/workflow/common/app-node.ts +++ b/ui/src/workflow/common/app-node.ts @@ -137,6 +137,26 @@ class AppNode extends HtmlResize.view { } class AppNodeModel extends HtmlResize.model { + refreshDeges() { + // 更新节点连接边的path + this.incoming.edges.forEach((edge: any) => { + // 调用自定义的更新方案 + edge.updatePathByAnchor() + }) + this.outgoing.edges.forEach((edge: any) => { + edge.updatePathByAnchor() + }) + } + set_position(position: { x?: number; y?: number }) { + const { x, y } = position + if (x) { + this.x = x + } + if (y) { + this.y = y + } + this.refreshDeges() + } getResizeOutlineStyle() { const style = super.getResizeOutlineStyle() style.stroke = 'none' diff --git a/ui/src/workflow/index.vue b/ui/src/workflow/index.vue index 3d9daaa22..2ba201cbb 100644 --- a/ui/src/workflow/index.vue +++ b/ui/src/workflow/index.vue @@ -5,13 +5,14 @@ diff --git a/ui/src/workflow/nodes/document-extract-node/index.vue b/ui/src/workflow/nodes/document-extract-node/index.vue index 890b9d129..b888f5052 100644 --- a/ui/src/workflow/nodes/document-extract-node/index.vue +++ b/ui/src/workflow/nodes/document-extract-node/index.vue @@ -10,7 +10,7 @@ label-width="auto" ref="DatasetNodeFormRef" > - @@ -39,7 +39,7 @@ import NodeCascader from '@/workflow/common/NodeCascader.vue' const props = defineProps<{ nodeModel: any }>() const form = { - file_list: [] + document_list: ["start-node", "document"] } From 02e9774c466c92358225c65f501d2735a7dde8ec Mon Sep 17 00:00:00 2001 From: CaptainB Date: Wed, 13 Nov 2024 18:23:00 +0800 Subject: [PATCH 06/11] =?UTF-8?q?feat:=20=E9=AB=98=E7=BA=A7=E7=BC=96?= =?UTF-8?q?=E6=8E=92=E6=94=AF=E6=8C=81=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?(WIP)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/base_document_extract_node.py | 12 ++++++++++-- .../ai-chat/component/chat-input-operate/index.vue | 9 ++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/apps/application/flow/step_node/document_extract_node/impl/base_document_extract_node.py b/apps/application/flow/step_node/document_extract_node/impl/base_document_extract_node.py index 35fc6edff..176230d2d 100644 --- a/apps/application/flow/step_node/document_extract_node/impl/base_document_extract_node.py +++ b/apps/application/flow/step_node/document_extract_node/impl/base_document_extract_node.py @@ -1,16 +1,24 @@ # coding=utf-8 +from django.db.models import QuerySet + from application.flow.i_step_node import NodeResult from application.flow.step_node.document_extract_node.i_document_extract_node import IDocumentExtractNode +from dataset.models import File class BaseDocumentExtractNode(IDocumentExtractNode): def execute(self, document, **kwargs): self.context['document_list'] = document content = '' + spliter = '\n-----------------------------------\n' if len(document) > 0: for doc in document: - content += doc['name'] - content += '\n-----------------------------------\n' + file = QuerySet(File).filter(id=doc['file_id']).first() + file_type = doc['name'].split('.')[-1] + if file_type.lower() in ['txt', 'md', 'csv', 'html']: + content += spliter + doc['name'] + '\n' + file.get_byte().tobytes().decode('utf-8') + + return NodeResult({'content': content}, {}) def get_details(self, index: int, **kwargs): diff --git a/ui/src/components/ai-chat/component/chat-input-operate/index.vue b/ui/src/components/ai-chat/component/chat-input-operate/index.vue index b3bee751a..520621a91 100644 --- a/ui/src/components/ai-chat/component/chat-input-operate/index.vue +++ b/ui/src/components/ai-chat/component/chat-input-operate/index.vue @@ -131,7 +131,7 @@ const localLoading = computed({ const imageExtensions = ['jpg', 'jpeg', 'png', 'gif', 'bmp'] -const documentExtensions = ['pdf', 'docx', 'txt', 'xls', 'xlsx', 'md', 'html'] +const documentExtensions = ['pdf', 'docx', 'txt', 'xls', 'xlsx', 'md', 'html', 'csv'] const videoExtensions = ['mp4', 'avi', 'mov', 'mkv', 'flv'] const audioExtensions = ['mp3', 'wav', 'aac', 'flac'] @@ -185,6 +185,13 @@ const uploadFile = async (file: any, fileList: any) => { file.file_id = f[0].file_id } }) + uploadDocumentList.value.forEach((file: any) => { + const f = response.data.filter((f: any) => f.name === file.name) + if (f.length > 0) { + file.url = f[0].url + file.file_id = f[0].file_id + } + }) console.log(uploadDocumentList.value, uploadImageList.value) }) } From b9d1e3b07d2d4f1b77555af79d9782585a179c08 Mon Sep 17 00:00:00 2001 From: shaohuzhang1 Date: Wed, 13 Nov 2024 19:04:05 +0800 Subject: [PATCH 07/11] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=A6=82?= =?UTF-8?q?=E6=9E=9C=E5=B7=A5=E4=BD=9C=E6=B5=81=E6=9C=AA=E5=93=8D=E5=BA=94?= =?UTF-8?q?=E6=95=B0=E6=8D=AE,=E5=93=8D=E5=BA=94=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/ai-chat/component/answer-content/index.vue | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ui/src/components/ai-chat/component/answer-content/index.vue b/ui/src/components/ai-chat/component/answer-content/index.vue index bc6519cf3..e6456f3e7 100644 --- a/ui/src/components/ai-chat/component/answer-content/index.vue +++ b/ui/src/components/ai-chat/component/answer-content/index.vue @@ -8,7 +8,11 @@
+ From ac37e92ab94b84b07c0d72b67128fdd422d1ed28 Mon Sep 17 00:00:00 2001 From: maninhill <41712985+maninhill@users.noreply.github.com> Date: Wed, 13 Nov 2024 19:15:08 +0800 Subject: [PATCH 08/11] chore: Update README.md (#1624) --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 93bc7ae81..372803d56 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,8 @@ docker run -d --name=maxkb --restart=always -p 8080:8080 -v C:/maxkb:/var/lib/po - 你也可以通过 [1Panel 应用商店](https://apps.fit2cloud.com/1panel) 快速部署 MaxKB; - 如果是内网环境,推荐使用 [离线安装包](https://community.fit2cloud.com/#/products/maxkb/downloads) 进行安装部署; -- MaxKB 产品版本分为社区版和专业版,详情请参见:[MaxKB 产品版本对比](https://maxkb.cn/pricing.html)。 +- MaxKB 产品版本分为社区版和专业版,详情请参见:[MaxKB 产品版本对比](https://maxkb.cn/pricing.html); +- 如果您需要向团队介绍 MaxKB,可以使用这个 [官方 PPT 材料](https://maxkb.cn/download/introduce-maxkb_202411.pdf)。 如你有更多问题,可以查看使用手册,或者通过论坛与我们交流。 From 89cea4e20a5ad8e9d9dffa0b45d8e26194ed95ee Mon Sep 17 00:00:00 2001 From: shaohuzhang1 Date: Thu, 14 Nov 2024 09:50:21 +0800 Subject: [PATCH 09/11] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dai=E5=AF=B9?= =?UTF-8?q?=E8=AF=9D=E6=A1=86=E6=97=A0=E6=B3=95=E6=AD=A3=E5=B8=B8=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=AF=B9=E8=AF=9D=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/application/flow/workflow_manage.py | 2 +- ui/src/components/ai-chat/component/answer-content/index.vue | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/application/flow/workflow_manage.py b/apps/application/flow/workflow_manage.py index edd21391d..0cd92e8e1 100644 --- a/apps/application/flow/workflow_manage.py +++ b/apps/application/flow/workflow_manage.py @@ -515,7 +515,7 @@ class WorkflowManage: if index == 0: result.append(answer.get('content')) continue - if answer.get('type') != answer_text_list[index - 1]: + if answer.get('type') != answer_text_list[index - 1].get('type'): result.append(answer.get('content')) else: result[-1] += answer.get('content') diff --git a/ui/src/components/ai-chat/component/answer-content/index.vue b/ui/src/components/ai-chat/component/answer-content/index.vue index e6456f3e7..1a75737bb 100644 --- a/ui/src/components/ai-chat/component/answer-content/index.vue +++ b/ui/src/components/ai-chat/component/answer-content/index.vue @@ -8,7 +8,9 @@
Date: Thu, 14 Nov 2024 10:02:58 +0800 Subject: [PATCH 10/11] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=B7=A5?= =?UTF-8?q?=E4=BD=9C=E6=B5=81=E8=8A=82=E7=82=B9=E6=94=B6=E7=BC=A9=E5=90=8E?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E5=8F=91=E5=B8=83=20#1582?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/src/workflow/common/NodeContainer.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/src/workflow/common/NodeContainer.vue b/ui/src/workflow/common/NodeContainer.vue index 59df25c68..ac83fc4d7 100644 --- a/ui/src/workflow/common/NodeContainer.vue +++ b/ui/src/workflow/common/NodeContainer.vue @@ -51,7 +51,7 @@
-
+
Date: Thu, 14 Nov 2024 10:56:59 +0800 Subject: [PATCH 11/11] chore: remove some warning code --- .../migrations/0011_application_model_params_setting.py | 2 +- .../migrations/0017_application_tts_model_params_setting.py | 2 +- .../0019_application_file_upload_enable_and_more.py | 2 +- apps/application/models/application.py | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/application/migrations/0011_application_model_params_setting.py b/apps/application/migrations/0011_application_model_params_setting.py index 440b94df5..656b54775 100644 --- a/apps/application/migrations/0011_application_model_params_setting.py +++ b/apps/application/migrations/0011_application_model_params_setting.py @@ -13,6 +13,6 @@ class Migration(migrations.Migration): migrations.AddField( model_name='application', name='model_params_setting', - field=models.JSONField(default={}, verbose_name='模型参数相关设置'), + field=models.JSONField(default=dict, verbose_name='模型参数相关设置'), ), ] diff --git a/apps/application/migrations/0017_application_tts_model_params_setting.py b/apps/application/migrations/0017_application_tts_model_params_setting.py index 43428841f..3276ca632 100644 --- a/apps/application/migrations/0017_application_tts_model_params_setting.py +++ b/apps/application/migrations/0017_application_tts_model_params_setting.py @@ -13,6 +13,6 @@ class Migration(migrations.Migration): migrations.AddField( model_name='application', name='tts_model_params_setting', - field=models.JSONField(default={}, verbose_name='模型参数相关设置'), + field=models.JSONField(default=dict, verbose_name='模型参数相关设置'), ), ] diff --git a/apps/application/migrations/0019_application_file_upload_enable_and_more.py b/apps/application/migrations/0019_application_file_upload_enable_and_more.py index f59a4990c..f8c33c2c1 100644 --- a/apps/application/migrations/0019_application_file_upload_enable_and_more.py +++ b/apps/application/migrations/0019_application_file_upload_enable_and_more.py @@ -23,7 +23,7 @@ class Migration(migrations.Migration): migrations.AddField( model_name='application', name='file_upload_setting', - field=models.JSONField(default={}, verbose_name='文件上传相关设置'), + field=models.JSONField(default=dict, verbose_name='文件上传相关设置'), ), migrations.AddField( model_name='chatrecord', diff --git a/apps/application/models/application.py b/apps/application/models/application.py index 5df928c4d..c90d1325c 100644 --- a/apps/application/models/application.py +++ b/apps/application/models/application.py @@ -48,8 +48,8 @@ class Application(AppModelMixin): model = models.ForeignKey(Model, on_delete=models.SET_NULL, db_constraint=False, blank=True, null=True) dataset_setting = models.JSONField(verbose_name="数据集参数设置", default=get_dataset_setting_dict) model_setting = models.JSONField(verbose_name="模型参数相关设置", default=get_model_setting_dict) - model_params_setting = models.JSONField(verbose_name="模型参数相关设置", default={}) - tts_model_params_setting = models.JSONField(verbose_name="模型参数相关设置", default={}) + model_params_setting = models.JSONField(verbose_name="模型参数相关设置", default=dict) + tts_model_params_setting = models.JSONField(verbose_name="模型参数相关设置", default=dict) problem_optimization = models.BooleanField(verbose_name="问题优化", default=False) icon = models.CharField(max_length=256, verbose_name="应用icon", default="/ui/favicon.ico") work_flow = models.JSONField(verbose_name="工作流数据", default=dict) @@ -67,7 +67,7 @@ class Application(AppModelMixin): tts_type = models.CharField(verbose_name="语音播放类型", max_length=20, default="BROWSER") clean_time = models.IntegerField(verbose_name="清理时间", default=180) file_upload_enable = models.BooleanField(verbose_name="文件上传是否启用", default=False) - file_upload_setting = models.JSONField(verbose_name="文件上传相关设置", default={}) + file_upload_setting = models.JSONField(verbose_name="文件上传相关设置", default=dict) @staticmethod