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
3 changes: 2 additions & 1 deletion apps/application/flow/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
from tools.models.tool import Tool

end_nodes = ['ai-chat-node', 'reply-node', 'function-node', 'function-lib-node', 'application-node',
'image-understand-node', 'speech-to-text-node', 'text-to-speech-node', 'image-generate-node']
'image-understand-node', 'speech-to-text-node', 'text-to-speech-node', 'image-generate-node',
'variable-assign-node']


class Answer:
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 Python code snippet is syntactically correct but can be refined for clarity and maintainability. Here are some suggestions:

  1. Variable Name Consistency: The variable end_nodes contains nodes related to "function". It might benefit from more consistent naming if these functions have a common theme or type.

  2. Import Statement:

    • While not necessary in this context, ensure that all imports at the beginning of the file follow PEP 8 guidelines (e.g., single blank line after import statements).
  3. Comments: Add comments explaining what each part does, especially regarding the list comprehension used to filter or categorize node names.

  4. Class Definition:

    • Consider whether the Answer class serves a specific purpose beyond its name. If it's purely decorative or intended for documentation purposes, consider renaming it accordingly.

Here's an improved version of the code with suggested modifications:

from tools.models.tool import Tool

# List of end nodes relevant to AI tasks
end_nodes = [
    'ai-chat-node',
    'reply-node',
    'function-node',
    'function-lib-node',
    'application-node',
    'image-understand-node',
    'speech-to-text-node',
    'text-to-speech-node',
    'image-generate-node',
    'variable-assign-node'
]

class NodeClassifier:
    # Example class for handling classification logic involving nodes
    pass

This revision improves readability and follows standard coding practices for variables and function/class definitions.

Expand Down
7 changes: 4 additions & 3 deletions ui/src/workflow/common/validate.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {WorkflowType, WorkflowMode} from '@/enums/application'
import { WorkflowType, WorkflowMode } from '@/enums/application'

import {t} from '@/locales'
import { t } from '@/locales'

const end_nodes: Array<string> = [
WorkflowType.AiChat,
Expand All @@ -18,7 +18,8 @@ const end_nodes: Array<string> = [
WorkflowType.LoopBodyNode,
WorkflowType.LoopNode,
WorkflowType.LoopBreakNode,
WorkflowType.VideoUnderstandNode
WorkflowType.VideoUnderstandNode,
WorkflowType.VariableAssignNode,
]

const loop_end_nodes: Array<string> = [
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 importing necessary modules and defining variables used in a TypeScript/JavaScript application related to workflows. There are no apparent irregularities or major issues based on the information given. However, here are some minor optimizations and improvements that could enhance readability and maintainability:

  1. Consistent Importing: Ensure consistent style when using import statements by specifying module paths without quotes if they contain valid JavaScript syntax for identifiers.

  2. Variable Declarations:

    • You can consider renaming the variable end_nodes to workflowEndNodes for clarity, especially since it represents workflow end nodes.
    • Similarly, rename loop_end_nodes to workflowLoopEndNodes.
  3. Documentation Comments: Include comments to explain what each section of the array is for to improve code comprehension.

Here's the enhanced version with these suggestions:

// Import necessary enums and functions from their respective locations
import { WorkflowType, WorkflowMode } from '@/enums/application';
import { t } from '@/locales';

const workflowEndNodes: Array<string> = [
  WorkflowType.AiChat,
  WorkflowType.ImageRecognizeNode,
  // Add more end nodes as needed
];

const workflowLoopEndNodes: Array<string> = [
  WorkflowType.LoopBodyNode,
  WorkflowType.LoopNode,
  WorkflowType.LoopBreakNode,
  WorkflowType.VideoUnderstandNode,
  WorkflowType.VariableAssignNode, // Placeholder comment
];

These changes focus on improving naming conventions, making the code cleaner, and adding docstring comments where appropriate to enhance understanding of the intended purpose of the arrays.

Expand Down
Loading