-
Notifications
You must be signed in to change notification settings - Fork 2.7k
feat: Tool workflow node #4880
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Tool workflow node #4880
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1038,6 +1038,27 @@ export const toolLibNode = { | |
| }, | ||
| } | ||
|
|
||
| /** | ||
| * 工作流工具配置数据 | ||
| */ | ||
| export const toolWorkflowLibNode = { | ||
| type: WorkflowType.ToolWorkflowLib, | ||
| text: t('workflow.nodes.toolWorlflowNode.text','工作流工具'), | ||
| label: t('workflow.nodes.toolWorlflowNode.label','工作流工具'), | ||
| height: 170, | ||
| properties: { | ||
| stepName: t('workflow.nodes.toolWorlflowNode.label','工作流工具'), | ||
| config: { | ||
| fields: [ | ||
| { | ||
| label: t('common.result'), | ||
| value: 'result', | ||
| }, | ||
| ], | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| export const applicationNode = { | ||
| type: WorkflowType.Application, | ||
| text: t('workflow.nodes.applicationNode.label'), | ||
|
|
@@ -1086,6 +1107,7 @@ export const nodeDict: any = { | |
| [WorkflowType.Start]: startNode, | ||
| [WorkflowType.Reply]: replyNode, | ||
| [WorkflowType.ToolLib]: toolNode, | ||
| [WorkflowType.ToolWorkflowLib]: toolWorkflowLibNode, | ||
| [WorkflowType.ToolLibCustom]: toolNode, | ||
| [WorkflowType.RerankerNode]: rerankerNode, | ||
| [WorkflowType.FormNode]: formNode, | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code seems to be correct for a workflow library in terms of syntax and data structure. However, here are some potential improvements:
Here’s an updated version with added comments: // Define common constants used throughout the codebase
export const WorkflowType = {
Start: 'start',
Reply: 'reply',
ToolLib: 'toollib', // Replaced 'ToolLib' to match existing keys but maintain clarity.
ToolWorkflowLib: 'tool-workflow-lib',
ToolLibCustom: 'custom-tool-lib', // Renamed to avoid confusion with other types.
RerankerNode: 'reranker-node',
FormNode: 'form-node'
};
// Translation utility - Placeholder for actual translation functions.
function t(key) { return key; }
/**
* Base Node Configuration Interface
*/
interface NodeConfigInterface {
type: string;
text?: string;
label?: string;
height?: number;
properties?: {};
}
/**
* Example start node configuration object
*/
const startNode: NodeConfigInterface = {
type: WorkflowType.Start,
text: t('workflow.nodes.startNode.text'), // Assuming this translates to 'Start'
label: t('workflow.nodes.startNode.label') // Assuming this translates to 'Start'
};
/**
* Application node configuration object
*/
const applicationNode: NodeConfigInterface = {
type: WorkflowType.Application,
text: t('workflow.nodes.applicationNode.label')
}
// Dictionary mapping each workflow type to its corresponding node configuration object
const nodeDict: any = {
[WorkflowType.Start]: startNode,
[WorkflowType.Reply]: replyNode,
[WorkflowType.ToolLib]: toolNode,
[WorkflowType.ToolWorkflowLib]: toolWorkflowLibNode,
[WorkflowType.ToolLibCustom]: toolNode, // Mapped back from original naming convention
[WorkflowType.RerankerNode]: rerankerNode,
[WorkflowType.FormNode]: formNode
};These changes enhance the modularity of the code through encapsulation of interfaces, improved variable names, and clearer documentation. Adjustments like renaming variables should only take place when absolutely necessary and after thorough consideration to ensure consistency across components and prevent potential bugs due to name collisions or misinterpretation. |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| <template> | ||
| <el-avatar shape="square" style="background: #34c724"> | ||
| <img src="@/assets/tool/icon_tool_workflow.svg" style="width: 65%" alt="" /> | ||
| </el-avatar> | ||
| </template> | ||
| <script setup lang="ts"></script> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import ToolWorkflowLibNodeVue from './index.vue' | ||
| import { AppNode, AppNodeModel } from '@/workflow/common/app-node' | ||
| class ToolWorkflowLibNode extends AppNode { | ||
| constructor(props: any) { | ||
| super(props, ToolWorkflowLibNodeVue) | ||
| } | ||
| } | ||
| export default { | ||
| type: 'tool-workflow-lib-node', | ||
| model: AppNodeModel, | ||
| view: ToolWorkflowLibNode, | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code appears to be mostly correct syntactically, but there are several areas that could benefit some improvements or corrections:
Variable Redundancy: The
activeNamevalue seems incorrect here since it's not defined anywhere in the snippet provided. You might want to clarify its purpose if needed.Type Annotations: Some variables like
menuItems,currentFolder,isShared,folderId, etc., need type annotations for better clarity and TypeScript support.Destructuring Assignment: Consider destructuring assignments for cleaner syntax when accessing properties of objects.
Simplification of Code: There isn't much structural redundancy in this specific piece of the code, but you might consider simplifying how certain conditions are checked based on the context.
Here’s an improved version with these considerations:
Key Improvements:
activeFolderId.This should help clean up any issues you're encountering while maintaining good readability and maintainability.