Skip to content

Conversation

@shaohuzhang1
Copy link
Contributor

fix: When the execution fails, the execution details still show as successful in the [Knowledge Base Workflow]

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Dec 11, 2025

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Dec 11, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

def execute(self, model_id, system, prompt, dialogue_number, dialogue_type, history_chat_record, stream,
model_params_setting,
chat_record_id,
image,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are no significant irregularities or potential issues in the provided code. However, there's an additional piece of logic added to handle specific knowledge workflows (KNOWLEDGE and KNOWLEDGE_LOOP) that modifies the execution parameters before calling the _run() method internally:

if [WorkflowMode.KNOWLEDGE, WorkflowMode.KNOWLEDGE_LOOP].__contains__(self.workflow_manage.flow.workflow_mode):
    return self.execute(image=res, **self.node_params_serializer.data, **self.flow_params_serializer.data,
                        **{'history_chat_record': [], 'stream': True,  'chat_record_id': None})
else:
    return self._run()

This addition helps ensure compatibility with other workflow modes while setting default values appropriate for knowledge-related workflows, such as having an empty history record and enabling streaming.

def execute(self, model_id, system, prompt, dialogue_number, dialogue_type, history_chat_record, stream,
model_params_setting,
chat_record_id,
image,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are several issues in this code snippet:

  1. Line Length: The line length exceeds Python's recommended maximum of 80 characters. This can make the code harder to read and maintain.

  2. Variable Naming: The variable names workflow_manage, model_id, stream, image, and chat_record_id should be more descriptive to enhance readability.

  3. Function Signature Complexity: While not incorrect, keeping function signatures concise is generally good practice.

  4. Return Statement: Since there seems to be no explicit return statement at the end of the function, it might be an accidental omission.

Optimizations and Suggestions

  1. Improve Variable Names:

    def save_context(self, conversation_details, workflow_management):
        if conversation_details.get('is_response', False):
            self.answer_text = conversation_details.get('response_content')
  2. Refactor Line Length:
    Break down long lines into more manageable pieces using parentheses or continuation lines with backslashes (\) for continued expressions within parentheses.

  3. Add Return Statement (if needed):
    Add a return statement at the end of the function if necessary. For example:

    def execute(
        self,
        model_identifier=None,
        system_prompt=None,
        user_input=None,
        dialog_number=None,
        dialog_type="text",
        previous_conversation_records=None,
        streaming=False,
        chat_log_id=None,
        attached_image=None
    ):
        # Function implementation here
        
        return None  # Or any specific output depending on context

These changes will improve the readability and usability of the code while maintaining its functionality.

@shaohuzhang1 shaohuzhang1 merged commit 6dc14ae into v2 Dec 11, 2025
3 of 6 checks passed
@shaohuzhang1 shaohuzhang1 deleted the pr@v2@fix_workflow branch December 11, 2025 04:43
liuruibin pushed a commit that referenced this pull request Dec 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants