Skip to content

Commit 3c7e5ff

Browse files
perf: Variable aggregation node adds sorting and modifies some styling issues
1 parent ebb3c74 commit 3c7e5ff

File tree

9 files changed

+104
-71
lines changed

9 files changed

+104
-71
lines changed

ui/src/layout/layout-header/avatar/APIKeyDialog.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ function changeState(bool: boolean, row: any) {
126126
const obj = {
127127
is_active: bool,
128128
}
129-
const str = bool ? t('common.enabled') : t('common.disabled')
129+
const str = bool ? t('common.status.enabled') : t('common.status.disabled')
130130
systemKeyApi.putAPIKey(row.id, obj, loading).then((res) => {
131131
MsgSuccess(str)
132132
getApiKeyList()

ui/src/locales/lang/en-US/views/application-workflow.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ You are a master of problem optimization, adept at accurately inferring user int
259259
},
260260
variableAggregationNode: {
261261
label: 'Variable Aggregation',
262-
text: 'Perform aggregation processing on the outputs of multiple branches',
262+
text: 'Aggregate variables of each group according to the aggregation strategy',
263263
Strategy: 'Aggregation Strategy',
264264
placeholder: 'Return the first non-null value of each group',
265265
placeholder1: 'Return the set of variables for each group',

ui/src/locales/lang/zh-CN/views/application-workflow.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ export default {
260260
},
261261
variableAggregationNode: {
262262
label: '变量聚合',
263-
text: '对多个分支的输出进行聚合处理',
263+
text: '按聚合策略聚合每组的变量',
264264
Strategy: '聚合策略',
265265
placeholder: '返回每组的第一个非空值',
266266
placeholder1: '返回每组变量的集合',

ui/src/locales/lang/zh-Hant/views/application-workflow.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ export default {
259259
},
260260
variableAggregationNode: {
261261
label: '變量聚合',
262-
text: '對多個分支的輸出進行聚合處理',
262+
text: '按聚合策略聚合每組的變量',
263263
Strategy: '聚合策略',
264264
placeholder: '返回每組的第一個非空值',
265265
placeholder1: '返回每組變量的集合',

ui/src/styles/component.scss

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,3 +262,23 @@
262262
padding: 4px 16px 12px 12px;
263263
}
264264
}
265+
// 拖拽排序
266+
.drag-card.no-drag {
267+
.handle {
268+
.handle-img {
269+
display: none;
270+
}
271+
}
272+
}
273+
.drag-card:not(.no-drag) {
274+
.handle {
275+
.handle-img {
276+
display: none;
277+
}
278+
&:hover {
279+
.handle-img {
280+
display: block;
281+
}
282+
}
283+
}
284+
}

ui/src/views/document/tag/TagDrawer.vue

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,18 @@ function editTagValue(row: any) {
259259
}
260260
261261
function delTagValue(row: any) {
262-
loadSharedApi({ type: 'knowledge', systemType: apiType.value })
263-
.delTag(id, row.id, 'one')
262+
MsgConfirm(t('views.document.tag.deleteConfirm') + row.value, t('views.document.tag.deleteTip'), {
263+
confirmButtonText: t('common.delete'),
264+
confirmButtonClass: 'danger',
265+
})
264266
.then(() => {
265-
getList()
267+
loadSharedApi({ type: 'knowledge', systemType: apiType.value })
268+
.delTag(id, row.id, 'one')
269+
.then(() => {
270+
getList()
271+
})
266272
})
273+
.catch(() => {})
267274
}
268275
269276
function getList() {

ui/src/workflow/common/data.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ export const menuNodes = [
636636
},
637637
{
638638
label: t('views.knowledge.title'),
639-
list: [searchKnowledgeNode, searchDocumentNode, rerankerNode],
639+
list: [searchKnowledgeNode, searchDocumentNode, rerankerNode, documentExtractNode],
640640
},
641641
{
642642
label: t('views.applicationWorkflow.nodes.classify.businessLogic'),
@@ -653,7 +653,7 @@ export const menuNodes = [
653653
},
654654
{
655655
label: t('views.applicationWorkflow.nodes.classify.other'),
656-
list: [mcpNode, documentExtractNode, toolNode],
656+
list: [mcpNode, toolNode],
657657
},
658658
]
659659
export const applicationLoopMenuNodes = [
@@ -674,19 +674,24 @@ export const applicationLoopMenuNodes = [
674674
},
675675
{
676676
label: t('views.knowledge.title'),
677-
list: [searchKnowledgeNode, searchDocumentNode, rerankerNode],
677+
list: [searchKnowledgeNode, searchDocumentNode, rerankerNode, documentExtractNode],
678678
},
679679
{
680680
label: t('views.applicationWorkflow.nodes.classify.businessLogic'),
681681
list: [conditionNode, formNode, replyNode, loopContinueNode, loopBreakNode],
682682
},
683683
{
684684
label: t('views.applicationWorkflow.nodes.classify.dataProcessing', '数据处理'),
685-
list: [variableAssignNode, variableSplittingNode, parameterExtractionNode, variableAggregationNode],
685+
list: [
686+
variableAssignNode,
687+
variableSplittingNode,
688+
parameterExtractionNode,
689+
variableAggregationNode,
690+
],
686691
},
687692
{
688693
label: t('views.applicationWorkflow.nodes.classify.other'),
689-
list: [mcpNode, documentExtractNode, toolNode],
694+
list: [mcpNode, toolNode],
690695
},
691696
]
692697

ui/src/workflow/nodes/condition-node/index.vue

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<VueDraggable
1212
ref="el"
1313
v-bind:modelValue="form_data.branch"
14-
:disabled="form_data.branch === 2"
14+
:disabled="form_data.branch.length === 2"
1515
handle=".handle"
1616
:animation="150"
1717
ghostClass="ghost"
@@ -347,23 +347,5 @@ onMounted(() => {
347347
})
348348
</script>
349349
<style lang="scss" scoped>
350-
.drag-card.no-drag {
351-
.handle {
352-
.handle-img {
353-
display: none;
354-
}
355-
}
356-
}
357-
.drag-card:not(.no-drag) {
358-
.handle {
359-
.handle-img {
360-
display: none;
361-
}
362-
&:hover {
363-
.handle-img {
364-
display: block;
365-
}
366-
}
367-
}
368-
}
350+
369351
</style>

ui/src/workflow/nodes/variable-aggregation-node/index.vue

Lines changed: 58 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
<el-card shadow="never" class="card-never" style="--el-card-padding: 12px">
4343
<div class="flex-between mb-12">
4444
<span class="ellipsis" :title="group.label">{{ group.label }}</span>
45-
<div class="flex align-center" style="margin-right: -3px;">
46-
<el-button @click="openAddOrEditDialog(group, gIndex)" link>
45+
<div class="flex align-center" style="margin-right: -3px">
46+
<el-button @click="openAddOrEditDialog(group, gIndex)" link>
4747
<el-icon><EditPen /></el-icon>
4848
</el-button>
4949
<el-button
@@ -55,43 +55,50 @@
5555
</el-button>
5656
</div>
5757
</div>
58-
59-
<div v-for="(item, vIndex) in group.variable_list" :key="item.v_id">
60-
<el-row>
61-
<el-col :span="22">
62-
<el-form-item
63-
:prop="`group_list.${gIndex}.variable_list.${vIndex}.variable`"
64-
:rules="{
65-
type: 'array',
66-
required: true,
67-
message: $t(
68-
'views.applicationWorkflow.variable.placeholder',
69-
),
70-
trigger: 'change',
71-
}"
72-
>
73-
<NodeCascader
74-
ref="nodeCascaderRef"
75-
:nodeModel="nodeModel"
76-
class="w-full"
77-
:placeholder="$t('views.applicationWorkflow.variable.placeholder')"
78-
v-model="item.variable"
79-
/>
80-
</el-form-item>
81-
</el-col>
82-
<el-col :span="2">
83-
<el-button
84-
link
85-
class="mt-4 ml-4"
86-
:disabled="group.variable_list.length <= 1"
87-
@click="deleteVariable(gIndex, vIndex)"
88-
>
89-
<AppIcon iconName="app-delete"></AppIcon>
90-
</el-button>
91-
</el-col>
92-
</el-row>
93-
</div>
94-
58+
<VueDraggable
59+
ref="el"
60+
v-bind:modelValue="group.variable_list"
61+
:disabled="group.variable_list.length === 1"
62+
handle=".handle"
63+
:animation="150"
64+
ghostClass="ghost"
65+
@end="onEnd($event, gIndex)"
66+
>
67+
<div v-for="(item, vIndex) in group.variable_list" :key="item.v_id" class="drag-card">
68+
<el-row class="handle">
69+
<el-col :span="22" class="flex">
70+
<img src="@/assets/sort.svg" alt="" height="15" class="mr-4 mt-8" />
71+
<el-form-item
72+
:prop="`group_list.${gIndex}.variable_list.${vIndex}.variable`"
73+
:rules="{
74+
type: 'array',
75+
required: true,
76+
message: $t('views.applicationWorkflow.variable.placeholder'),
77+
trigger: 'change',
78+
}"
79+
>
80+
<NodeCascader
81+
ref="nodeCascaderRef"
82+
:nodeModel="nodeModel"
83+
style="width: 200px"
84+
:placeholder="$t('views.applicationWorkflow.variable.placeholder')"
85+
v-model="item.variable"
86+
/>
87+
</el-form-item>
88+
</el-col>
89+
<el-col :span="2">
90+
<el-button
91+
link
92+
class="mt-4 ml-4"
93+
:disabled="group.variable_list.length <= 1"
94+
@click="deleteVariable(gIndex, vIndex)"
95+
>
96+
<AppIcon iconName="app-delete"></AppIcon>
97+
</el-button>
98+
</el-col>
99+
</el-row>
100+
</div>
101+
</VueDraggable>
95102
<el-button @click="addVariable(gIndex)" type="primary" size="large" link>
96103
<AppIcon iconName="app-add-outlined" class="mr-4" />
97104
{{ $t('common.add') }}
@@ -116,6 +123,7 @@ import { isLastNode } from '@/workflow/common/data'
116123
import { t } from '@/locales'
117124
import { randomId } from '@/utils/common'
118125
import { MsgError } from '@/utils/message'
126+
import { VueDraggable } from 'vue-draggable-plus'
119127
120128
const props = defineProps<{ nodeModel: any }>()
121129
const VariableAggregationRef = ref()
@@ -241,6 +249,17 @@ const validate = async () => {
241249
})
242250
}
243251
252+
function onEnd(event: any, gIndex: number) {
253+
const { oldIndex, newIndex } = event
254+
if (oldIndex === undefined || newIndex === undefined) return
255+
const list = cloneDeep(props.nodeModel.properties.node_data.group_list[gIndex].variable_list)
256+
const newInstance = { ...list[oldIndex] }
257+
const oldInstance = { ...list[newIndex] }
258+
list[newIndex] = newInstance
259+
list[oldIndex] = oldInstance
260+
set(props.nodeModel.properties.node_data.group_list[gIndex], 'variable_list', list)
261+
}
262+
244263
onMounted(() => {
245264
if (typeof props.nodeModel.properties.node_data?.is_result === 'undefined') {
246265
if (isLastNode(props.nodeModel)) {

0 commit comments

Comments
 (0)