Skip to content

Conversation

@shaohuzhang1
Copy link
Contributor

fix: After enabling identity authentication in the application, the knowledge base retrieves the reference document list variable, but there is no content retrieved when asking questions on the application dialogue page

…nowledge base retrieves the reference document list variable, but there is no content retrieved when asking questions on the application dialogue page
@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Oct 29, 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.

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 Oct 29, 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.

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

).distinct()]

get_knowledge_list_of_authorized = DatabaseModelManage.get_model('get_knowledge_list_of_authorized')
chat_user_type = self.workflow_manage.get_body().get('chat_user_type')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This code snippet seems to be part of a Django application for querying knowledge data based on specified parameters. However, there are some improvements and corrections that can be made:

  1. List Comprehension: When converting document_id_list from a queryset into a list of strings using [str(k) for k in ...], it might lead to unnecessary memory usage if document_id_list is already a list of ids.

  2. Distinct Method: The .distinct() method should not typically include any arguments when used with values lists, so you can remove (flat=True) since the default behavior is to return unique elements.

  3. Consistency: Ensure consistency between variable names and their types within the function to improve readability and prevent typos.

Here's the corrected version:

def execute(self, knowledge_id_list, knowledge_setting, question, show_knowledge):
    search_scope_reference = workflow_manage.build_search_scope(knowledge_id_list, knowledge_setting)
    
    document_id_list = []
    if isinstance(search_scope_reference, Document):  # 文案库中的文档id数组
        document_id_list.append(search_scope_reference.id)
    elif isinstance(search_scope_reference, ReferenceContentBase):  # 虚拟知识集(参考内容)
        reference_content_base = search_scope_reference
        reference_document_ids = query_set(ReferenceDocumentInfo).filter(reference_content=reference_content_base.reference_id).values_list('info_id', flat=True)
        
        if len(reference_document_ids) == 0:
            knowledge_id_list = [
                str(doc.knowledge_id)
                for doc in database_model.manage.get_model(get_knowledge_list_of_authorized, {}).order_by('-createdate').all()
            ]
        else:
            knowledge_id_list.extend([doc.knowledge_id for doc in query_set(Document).filter(id__in=reference_document_ids).values_list('knowledge_id', flat=True)])
    else:  # 搜索范围为其他类型的数据结构需要进一步处理...

# Note: Ensure proper formatting and adherence to Python best practices throughout the project.

These changes ensure better performance and maintainability of the code while aligning with Django ORM conventions.

@shaohuzhang1 shaohuzhang1 merged commit 2298bf6 into v2 Oct 29, 2025
4 of 5 checks passed
@shaohuzhang1 shaohuzhang1 deleted the pr@v2@fix_workflow branch October 29, 2025 07:53
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