Skip to content

Conversation

@shaohuzhang1
Copy link
Contributor

fix: Application The reference segmentation of the knowledge base retrieval node in the loop body is displayed as 0

…rieval node in the loop body is displayed as 0
@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Dec 8, 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 8, 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

*ApplicationChatRecordQuerySerializers.get_loop_workflow_node(chat_record.details)]:
if item.get('type') == 'search-knowledge-node' and item.get('show_knowledge', False):
paragraph_list = paragraph_list + (item.get(
'paragraph_list') or [])
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 a few optimizations and improvements that can be made to enhance the code's performance and readability:

  1. Avoid Reversing Loop Order: In get_loop_workflow_node, reversing the loops (outer for -> inner for) is unnecessary. This should not affect the output but might make it harder to understand.

  2. Use Set instead of List for Result Accumulation: If you expect duplicates in loop_node_data, using a set could reduce memory usage compared to a list, although this doesn't make sense in this specific context where order does matter.

  3. Consistent Naming Conventions: Ensure consistent naming conventions throughout the codebase. The use of single underscores (_) for local variables and class methods might improve readability, especially when working in larger projects.

  4. Remove Redundant Code from Serializer Creation:

    # Remove redundant line
    # return query_set.filter(chat_id=self.data.get('chat_id')).order_by(order_by)).all()
    
  5. Optimize Query Construction:

Optimized version of fetching chat records

def list(self, with_valid=True):
qs = (
ChatRecord.objects
.filter(chat_id=self.data.get('chat_id'))
.order_by(order_by)
)
if not with_valid:
qs = qs.exclude(is_valid=False)
return [ChatRecordSerializerModel(rec).data for rec in qs]

This changes the logic to avoid querying more data than necessary by directly filtering based on `with_valid`.

These suggestions focus on improving efficiency and clarity while maintaining the original functionality.

@shaohuzhang1 shaohuzhang1 merged commit eb41ddf into v2 Dec 8, 2025
3 of 6 checks passed
@shaohuzhang1 shaohuzhang1 deleted the pr@v2@fix_application_chat_record branch December 8, 2025 10:19
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