-
Notifications
You must be signed in to change notification settings - Fork 2.7k
fix: Tool workflow node result #4883
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
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 |
|---|---|---|
|
|
@@ -4,6 +4,9 @@ class ToolWorkflowLibNode extends AppNode { | |
| constructor(props: any) { | ||
| super(props, ToolWorkflowLibNodeVue) | ||
| } | ||
| getConfig(props: any) { | ||
| return props.model.properties.config | ||
| } | ||
| } | ||
| export default { | ||
| type: 'tool-workflow-lib-node', | ||
|
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. Your code is mostly clean and follows best practices. However, here are some minor suggestions for clarity and performance:
Here's the updated code with these improvements: class ToolWorkflowLibNode extends AppNode {
constructor(props: any) {
super(props, ToolWorkflowLibNodeVue);
}
/**
* Retrieves configuration from the tool workflow library node.
*
* @param {any} props - The component.props object containing model and properties.
* @returns {*} The configuration property or undefined if missing.
*/
getConfig(props: any) {
const { model, properties } = props;
return model && properties ? properties.config : undefined;
}
}
export default {
type: 'tool-workflow-lib-node',
};These changes make the function more robust and clear. |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -150,26 +150,21 @@ const update_field = () => { | |
| loadSharedApi({ type: 'tool', systemType: apiType.value }) | ||
| .getToolById(props.nodeModel.properties.node_data.tool_lib_id) | ||
| .then((ok: any) => { | ||
| console.log('ssss', ok.data) | ||
|
|
||
| const workflowNodes = ok.data?.work_flow?.nodes || [] | ||
| const baseNode = workflowNodes.find((n: any) => n.type === 'tool-base-node') | ||
|
|
||
| if (baseNode) { | ||
| const new_input_list = baseNode.properties.user_input_field_list || [] | ||
| const new_output_list = baseNode.properties.user_output_field_list || [] | ||
|
|
||
| let config_field_list: any[] = [] | ||
| if (new_output_list.length > 0) { | ||
| config_field_list = new_output_list.map((item: any) => ({ | ||
| label: item.label, | ||
| value: item.field, | ||
| })) | ||
| } | ||
| const old_config_fields = props.nodeModel.properties.config?.fields || [] | ||
| const config_field_list = new_output_list.map((item: any) => { | ||
| const old = old_config_fields.find((o: any) => o.value === item.field) | ||
| return old ? JSON.parse(JSON.stringify(old)) : { label: item.label, value: item.field } | ||
| }) | ||
|
|
||
| const input_title = baseNode.properties.user_input_config?.title | ||
| const output_title = baseNode.properties.user_output_config?.title | ||
|
|
||
| const old_input_list = props.nodeModel.properties.node_data.input_field_list || [] | ||
| const merged_input_list = new_input_list.map((item: any) => { | ||
| const find_field = old_input_list.find((old_item: any) => old_item.field === item.field) | ||
|
|
@@ -185,11 +180,14 @@ const update_field = () => { | |
| }) | ||
|
|
||
| set(props.nodeModel.properties.node_data, 'input_field_list', merged_input_list) | ||
| set(props.nodeModel.properties.config, 'fields', config_field_list) | ||
| set(props.nodeModel.properties, 'config', { | ||
| fields: config_field_list, | ||
| output_title: output_title, | ||
| }) | ||
| set(props.nodeModel.properties.node_data, 'input_title', input_title) | ||
| set(props.nodeModel.properties.config, 'output_title', output_title) | ||
| } | ||
| set(props.nodeModel.properties, 'status', ok.data.is_active ? 200 : 500) | ||
| props.nodeModel.clear_next_node_field(true) | ||
| }) | ||
| .catch(() => { | ||
| set(props.nodeModel.properties, 'status', 500) | ||
|
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. Here's a concise review of the provided code: General Structure and Logic
Potential Issues/Improvements
Optimizations Suggested
These improvements will enhance the readability, maintainability, and robustness of the code while ensuring it works correctly across different scenarios. |
||
|
|
||
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 snippet is missing some logic related to handling different steps within the
toolWorkflowand its node configuration. This likely indicates that this part of the library was intended to manage specific inputs and outputs for various work flow nodes.However, given that the provided information only contains the definition of a single tool workflow node with a placeholder result field, we cannot fully review or evaluate it comprehensively without additional context. Here's what would be necessary:
Context: Ensure you have access to the full scope of how these tools interact within workflows and any other potential behaviors they might implement.
Interactions: Look at where this node interacts with others (e.g., input/output connections) through parent processes.
Error Handling: Check if there are error checks or fallback mechanisms mentioned in other parts of the codebase to handle issues with this tool workflow node.
Performance: Review if there are any resource-intensive operations within this module that could impact performance.
Without this comprehensive view, I can only offer general observations about an incomplete component. If you provide more details about this functionality within your larger system architecture, we can assess its completeness and suggest improvements further.