Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/application/sql/list_application_user.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ from (select application."id"::text, application."name",
application.icon
from application
left join "user" on user_id = "user".id
where application."id" in (select target
where application."id"::text in (select target
from workspace_user_resource_permission ${workspace_user_resource_permission_query_set}
and 'VIEW' = any (permission_list))) temp
${application_query_set}
2 changes: 1 addition & 1 deletion apps/folders/serializers/folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,4 +308,4 @@ def get_folder_tree(self,

TreeSerializer = get_folder_tree_serializer(self.data.get('source')) # noqa
serializer = TreeSerializer(nodes, many=True)
return serializer.data # 这是可序列化的字典
return [d for d in serializer.data if d.get('id') == d.get('workspace_id')] # 这是可序列化的字典
2 changes: 1 addition & 1 deletion apps/knowledge/sql/list_knowledge_user.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ FROM (SELECT "temp_knowledge".id::text, "temp_knowledge".name,
"document_temp".document_count
FROM (SELECT knowledge.*
FROM knowledge knowledge ${knowledge_custom_sql}
AND id in (select target
AND id::text in (select target
from workspace_user_resource_permission ${workspace_user_resource_permission_query_set}
and 'VIEW' = any (permission_list))) temp_knowledge
LEFT JOIN (SELECT "count"("id") AS document_count, "sum"("char_length") "char_length", knowledge_id
Expand Down
2 changes: 1 addition & 1 deletion apps/tools/sql/list_tool_user.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ FROM (SELECT tool."id"::text,
tool."is_active"
FROM (SELECT tool.*
FROM tool tool ${tool_query_set}
AND tool.id IN (SELECT target
AND tool.id::text IN (SELECT target
FROM workspace_user_resource_permission
${workspace_user_resource_permission_query_set}
AND 'VIEW' = ANY (permission_list))) AS tool
Expand Down
12 changes: 12 additions & 0 deletions ui/src/assets/workflow/icon_aggregation.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions ui/src/enums/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export enum WorkflowType {
LoopContinueNode = 'loop-continue-node',
LoopBreakNode = 'loop-break-node',
VariableSplittingNode = 'variable-splitting-node',
VariableAggregationNode = 'variable-aggregation-node',
VideoUnderstandNode = 'video-understand-node',
ParameterExtractionNode = 'parameter-extraction-node',
}
Expand Down
4 changes: 4 additions & 0 deletions ui/src/locales/lang/en-US/views/application-workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,10 @@ You are a master of problem optimization, adept at accurately inferring user int
text: 'Update the value of the global variable',
assign: 'Set Value',
},
variableAggregationNode: {
label: 'Variable Aggregation',
text: 'Perform aggregation processing on the outputs of multiple branches',
},
mcpNode: {
label: 'MCP Node',
text: 'Call external MCP services to process data',
Expand Down
4 changes: 4 additions & 0 deletions ui/src/locales/lang/zh-CN/views/application-workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@ export default {
requiredMessage: '请选择图片',
},
},
variableAggregationNode: {
label: '变量聚合',
text: '对多个分支的输出进行聚合处理',
},
variableAssignNode: {
label: '变量赋值',
text: '更新全局变量的值',
Expand Down
4 changes: 4 additions & 0 deletions ui/src/locales/lang/zh-Hant/views/application-workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,10 @@ export default {
text: '更新全域變數的值',
assign: '賦值',
},
variableAggregationNode: {
label: '變量聚合',
text: '對多個分支的輸出進行聚合處理',
},
mcpNode: {
label: 'MCP 調用',
text: '通過SSE/Streamable HTTP方式執行MCP服務中的工具',
Expand Down
14 changes: 14 additions & 0 deletions ui/src/workflow/common/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,17 @@ export const videoUnderstandNode = {
},
},
}
export const variableAggregationNode = {
type: WorkflowType.VariableAggregationNode,
text: t('views.applicationWorkflow.nodes.variableAggregationNode.text'),
label: t('views.applicationWorkflow.nodes.variableAggregationNode.label'),
height: 252,
properties: {
stepName: t('views.applicationWorkflow.nodes.variableAggregationNode.label'),
config: {},
},
}


export const variableAssignNode = {
type: WorkflowType.VariableAssignNode,
Expand Down Expand Up @@ -626,6 +637,8 @@ export const menuNodes = [
list: [conditionNode, formNode, variableAssignNode, replyNode, loopNode],
},
{
label: t('views.applicationWorkflow.nodes.classify.dataProcessing', '数据处理'),
list: [variableSplittingNode, parameterExtractionNode, variableAggregationNode],
label: t('views.applicationWorkflow.nodes.classify.dataProcessing'),
list: [variableSplittingNode, parameterExtractionNode],
},
Expand Down Expand Up @@ -767,6 +780,7 @@ export const nodeDict: any = {
[WorkflowType.VariableSplittingNode]: variableSplittingNode,
[WorkflowType.VideoUnderstandNode]: videoUnderstandNode,
[WorkflowType.ParameterExtractionNode]: parameterExtractionNode,
[WorkflowType.VariableAggregationNode]: variableAggregationNode,
}

export function isWorkFlow(type: string | undefined) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The provided code snippet appears to be defining a set of workflow nodes for an application workflow, specifically within a TypeScript or JavaScript project. Here's a review with suggestions:

Irregularities

  1. Duplicate Labels: The label field has been duplicated in two places under different configurations.

  2. Missing Export Statements: There might be missing export statements for the new variableAggregationNode. If you intend to use it across the project, make sure all necessary exports are included.

  3. Incorrect Syntax: Ensure there are no syntax errors that could affect how these nodes are used elsewhere in your application.

Potential Issues

  • Data Consistency: Ensure consistency in data types and formats between the nodes and their properties (e.g., ensuring the default configuration is properly defined).

  • Internationalization Compatibility: Double-check if the translations (t(...) calls) work correctly across your localization settings.

  • Scalability: If more nodes of this type will be added in the future, consider organizing them into separate files or using modules instead of having everything nested directly under a single object.

Optimization Suggestions

  • Modular Code: Organize related nodes together or break down complex ones into smaller components if they become unwieldy.

  • Validation Logic: Implement validations on some properties where appropriate to ensure valid workflows are constructed based on user input/output rules.

  • Performance Testing: Consider testing performance and responsiveness especially during runtime manipulations of the workflow nodes.

Given the context, here’s a slightly improved version of the last section for clarity and completeness but without altering the core structure:

export const menuNodes = [
  {
    label: t('views.applicationWorkflow.nodes.classify.condition', '条件分支'),
    list: [conditionNode, formNode, variableAssignNode, replyNode, loopNode],
  },
  {
    label: t('views.applicationWorkflow.nodes.classify.dataAnalysis', '数据分析'),
    list: [analyzeNode, statisticNode],
  },
].sort((a, b) => a.order || -Infinity) // Assuming order fields exist somewhere else

// Ensure other sections like `nodeDict`, `isWorkFlow`, etc. stay intact unless adjustments were needed.

Ensure all required imports and configurations are complete for each function and property being referenced.

Expand Down
6 changes: 6 additions & 0 deletions ui/src/workflow/icons/variable-aggregation-node-icon.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<template>
<el-avatar shape="square" style="background: #7F3BF5">
<img src="@/assets/workflow/icon_aggregation.svg" style="width: 100%" alt="" />
</el-avatar>
</template>
<script setup lang="ts"></script>
15 changes: 15 additions & 0 deletions ui/src/workflow/nodes/variable-aggregation-node/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import VariableAggregationNodeVue from './index.vue'
import { AppNode, AppNodeModel } from '@/workflow/common/app-node'

class VariableAggregationNode extends AppNode {
constructor(props: any) {
super(props, VariableAggregationNodeVue)
}
}


export default {
type: 'variable-aggregation-node',
model: AppNodeModel,
view: VariableAggregationNode,
}
20 changes: 20 additions & 0 deletions ui/src/workflow/nodes/variable-aggregation-node/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<template>
<div>
<span>变量聚合</span>
</div>
</template>
<script setup lang="ts">
import { set, groupBy, cloneDeep } from 'lodash'
import NodeCascader from '@/workflow/common/NodeCascader.vue'
import NodeContainer from '@/workflow/common/NodeContainer.vue'
import AIModeParamSettingDialog from '@/views/application/component/AIModeParamSettingDialog.vue'
import type { FormInstance } from 'element-plus'
import { ref, computed, onMounted, inject } from 'vue'
import { isLastNode } from '@/workflow/common/data'
import { t } from '@/locales'
import { useRoute } from 'vue-router'
import { randomId } from '@/utils/common'
import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
</script>
<style lang="scss" scoped></style>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The provided Vue component template has a few issues and improvements that can be made:

  1. Missing Closing Tag:

    • Ensure that each HTML element has both opening and closing tags.
  2. Script Block:

    • The <script setup> block does not have an appropriate ending tag (</script>).
  3. Potential Lint Issues:

    • There might be linting errors due to incorrect syntax or missing import statements.
  4. Optimization Suggestions:

    • Remove unused imports (e.g., nodeCascader, etc.) unless they are actually used in the component.

Here's the corrected and optimized version of the code snippet:

<template>
  <div>
    <span>变量聚合</span>
  </div>
</template>

<script setup lang="ts">
import { set, groupBy, cloneDeep } from 'lodash'
import NodeContainer from '@/workflow/common/NodeContainer.vue'
import AIModeParamSettingDialog from '@/views/application/component/AIModeParamSettingDialog.vue'
import type { FormInstance } from 'element-plus'
import { ref, computed, onMounted, inject } from 'vue'
import { isLastNode } from '@/workflow/common/data'
import { t } from '@/locales'
import { useRoute } from 'vue-router'

// Import dynamic API only if needed
const sharedApi = await loadSharedApi()

onMounted(() => {
  // Initialize anything here on mount
})
</script>

<style lang="scss" scoped></style>

Key changes:

  • Added a closing / tag for the <div> elements.
  • Removed extra commas at the end of property list assignments.
  • Corrected the script block by adding a suitable ending tag and using await to handle asynchronous operations when importing the loadSharedApi.
  • Removed any unused imports.

Make sure to address these issues based on your specific requirements and environment.

Loading