fix: search knowledge (#3439)

This commit is contained in:
shaohuzhang1 2025-06-30 21:47:54 +08:00 committed by GitHub
parent b89b950c0d
commit 05f4eb532e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 3 deletions

View File

@ -50,7 +50,7 @@ class ISearchDatasetStep(IBaseChatPipelineStep):
return self.InstanceSerializer
def _run(self, manage: PipelineManage):
paragraph_list = self.execute(**self.context['step_args'])
paragraph_list = self.execute(**self.context['step_args'], manage=manage)
manage.context['paragraph_list'] = paragraph_list
self.context['paragraph_list'] = paragraph_list
@ -59,6 +59,7 @@ class ISearchDatasetStep(IBaseChatPipelineStep):
exclude_paragraph_id_list: list[str], top_n: int, similarity: float, padding_problem_text: str = None,
search_mode: str = None,
workspace_id=None,
manage: PipelineManage = None,
**kwargs) -> List[ParagraphPipelineModel]:
"""
关于 用户和补全问题 说明: 补全问题如果有就使用补全问题去查询 反之就用用户原始问题查询

View File

@ -53,11 +53,12 @@ class BaseSearchDatasetStep(ISearchDatasetStep):
exclude_paragraph_id_list: list[str], top_n: int, similarity: float, padding_problem_text: str = None,
search_mode: str = None,
workspace_id=None,
manage=None,
**kwargs) -> List[ParagraphPipelineModel]:
get_knowledge_list_of_authorized = DatabaseModelManage.get_model('get_knowledge_list_of_authorized')
chat_user_type = self.context.get('chat_user_type')
chat_user_type = manage.context.get('chat_user_type')
if get_knowledge_list_of_authorized is not None and RoleConstants.CHAT_USER.value.name == chat_user_type:
knowledge_id_list = get_knowledge_list_of_authorized(self.context.get('chat_user_id'),
knowledge_id_list = get_knowledge_list_of_authorized(manage.context.get('chat_user_id'),
knowledge_id_list)
if len(knowledge_id_list) == 0:
return []

View File

@ -307,6 +307,7 @@ class ChatSerializers(serializers.Serializer):
raise ChatException(500, _("The application has not been published. Please use it after publishing."))
chat_info = ChatInfo(chat_id, self.data.get('chat_user_id'), self.data.get('chat_user_type'), [], [],
application.id,
application, work_flow_version)
chat_record_list = list(QuerySet(ChatRecord).filter(chat_id=chat_id).order_by('-create_time')[0:5])
chat_record_list.sort(key=lambda r: r.create_time)