-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: Loop node embedding sub application error #4050
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 |
|---|---|---|
|
|
@@ -381,6 +381,7 @@ def hand_event_node_result(self, current_node, node_result_future): | |
| child_node = {} | ||
| node_is_end = False | ||
| view_type = current_node.view_type | ||
| node_type = current_node.type | ||
| if isinstance(r, dict): | ||
| content = r.get('content') | ||
| child_node = {'runtime_node_id': r.get('runtime_node_id'), | ||
|
|
@@ -390,14 +391,16 @@ def hand_event_node_result(self, current_node, node_result_future): | |
| real_node_id = r.get('real_node_id') | ||
| if r.__contains__('node_is_end'): | ||
| node_is_end = r.get('node_is_end') | ||
| if r.__contains__('node_type'): | ||
| node_type = r.get("node_type") | ||
| view_type = r.get('view_type') | ||
| reasoning_content = r.get('reasoning_content') | ||
| chunk = self.base_to_response.to_stream_chunk_response(self.params['chat_id'], | ||
| self.params['chat_record_id'], | ||
| current_node.id, | ||
| current_node.up_node_id_list, | ||
| content, False, 0, 0, | ||
| {'node_type': current_node.type, | ||
| {'node_type': node_type, | ||
| 'runtime_node_id': runtime_node_id, | ||
| 'view_type': view_type, | ||
| 'child_node': child_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. There are several areas where the code can be improved or corrected to enhance readability, maintainability, and potentially optimize performance:
Here's an updated version of the code with some of these improvements: def hand_event_node_result(self, current_node, node_result_future):
child_node = {}
node_is_end = False
# Consistent key usage
view_type = current_node.view_type if current_node.view_type else 'default'
if isinstance(r, dict):
content = r.get('content')
if 'runtime_node_id' in r:
runtime_node_id = r.get('runtime_node_id')
if 'node_is_end' in r:
node_is_end = r['node_is_end']
if 'real_node_id' in r:
real_node_id = r.get('real_node_id')
if 'node_type' in r:
node_type = r.get("node_type", current_node.type) # Default to current_node.type if missing
reasoning_content = r.get('reasoning_content', '')
chunk = self.base_to_response.to_stream_chunk_response(
self.params['chat_id'],
self.params['chat_record_id'],
current_node.id,
current_node.up_node_id_list,
content,
False,
0,
0,
{
"nodeType": node_type,
"runtimeNodeId": runtime_node_id,
"viewType": view_type,
"childNodes": child_node
}
)Key Changes:
These changes help clean up the code while maintaining its functionality. |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -466,9 +466,9 @@ export const loopBodyNode = { | |
| type: WorkflowType.LoopBodyNode, | ||
| text: t('views.applicationWorkflow.nodes.loopBodyNode.text', '循环体'), | ||
| label: t('views.applicationWorkflow.nodes.loopBodyNode.label', '循环体'), | ||
| height: 600, | ||
| height: 1080, | ||
| properties: { | ||
| width: 1800, | ||
| width: 1920, | ||
| stepName: t('views.applicationWorkflow.nodes.loopBodyNode.label', '循环体'), | ||
| config: { | ||
| fields: [], | ||
|
|
@@ -550,11 +550,14 @@ export const applicationLoopMenuNodes = [ | |
| label: t('views.applicationWorkflow.nodes.classify.aiCapability'), | ||
| list: [ | ||
| aiChatNode, | ||
| intentNode, | ||
| questionNode, | ||
| imageGenerateNode, | ||
| imageUnderstandNode, | ||
| textToSpeechNode, | ||
| speechToTextNode, | ||
| textToVideoNode, | ||
| imageToVideoNode, | ||
| ], | ||
| }, | ||
| { label: t('views.knowledge.title'), list: [searchKnowledgeNode, rerankerNode] }, | ||
|
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 an optimized version with these considerations: -- export const loopBodyNode = {
++ export const loopBodyNode = {
type: WorkflowType.LoopBodyNode,
text: t('views.applicationWorkflow.nodes.loopBodyNode.text', '循环体'),
label: t('views.applicationWorkflow.nodes.loopBodyNode.label', '循环体'),
- height: 600,
+ height: 1080,
properties: {
- width: 1800,
+ width: 1920,
stepName: t('views.applicationWorkflow.nodes.loopBodyNode.label', '循环体'),
config: {
// Ensure consistent spacing around fields.
fields: [...], // ... omitted for brevityAnd corresponding updates for -- applicationLoopMenuNodes.push(
++
-- applicationLoopMenuNodes = [ |
||
|
|
||
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 provided code has several improvements to be made:
(response_content.get('content', '') or '')can be simplified toresponse_content.get('content', ''). The double-parentheses create an unnecessary temporary variable.Here's the optimized version:
This change reduces one level of nesting while ensuring that the logic remains correct.