fix: search knowledge (#3439)
This commit is contained in:
parent
b89b950c0d
commit
05f4eb532e
@ -50,7 +50,7 @@ class ISearchDatasetStep(IBaseChatPipelineStep):
|
|||||||
return self.InstanceSerializer
|
return self.InstanceSerializer
|
||||||
|
|
||||||
def _run(self, manage: PipelineManage):
|
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
|
manage.context['paragraph_list'] = paragraph_list
|
||||||
self.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,
|
exclude_paragraph_id_list: list[str], top_n: int, similarity: float, padding_problem_text: str = None,
|
||||||
search_mode: str = None,
|
search_mode: str = None,
|
||||||
workspace_id=None,
|
workspace_id=None,
|
||||||
|
manage: PipelineManage = None,
|
||||||
**kwargs) -> List[ParagraphPipelineModel]:
|
**kwargs) -> List[ParagraphPipelineModel]:
|
||||||
"""
|
"""
|
||||||
关于 用户和补全问题 说明: 补全问题如果有就使用补全问题去查询 反之就用用户原始问题查询
|
关于 用户和补全问题 说明: 补全问题如果有就使用补全问题去查询 反之就用用户原始问题查询
|
||||||
|
|||||||
@ -53,11 +53,12 @@ class BaseSearchDatasetStep(ISearchDatasetStep):
|
|||||||
exclude_paragraph_id_list: list[str], top_n: int, similarity: float, padding_problem_text: str = None,
|
exclude_paragraph_id_list: list[str], top_n: int, similarity: float, padding_problem_text: str = None,
|
||||||
search_mode: str = None,
|
search_mode: str = None,
|
||||||
workspace_id=None,
|
workspace_id=None,
|
||||||
|
manage=None,
|
||||||
**kwargs) -> List[ParagraphPipelineModel]:
|
**kwargs) -> List[ParagraphPipelineModel]:
|
||||||
get_knowledge_list_of_authorized = DatabaseModelManage.get_model('get_knowledge_list_of_authorized')
|
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:
|
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)
|
knowledge_id_list)
|
||||||
if len(knowledge_id_list) == 0:
|
if len(knowledge_id_list) == 0:
|
||||||
return []
|
return []
|
||||||
|
|||||||
@ -307,6 +307,7 @@ class ChatSerializers(serializers.Serializer):
|
|||||||
raise ChatException(500, _("The application has not been published. Please use it after publishing."))
|
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'), [], [],
|
chat_info = ChatInfo(chat_id, self.data.get('chat_user_id'), self.data.get('chat_user_type'), [], [],
|
||||||
|
application.id,
|
||||||
application, work_flow_version)
|
application, work_flow_version)
|
||||||
chat_record_list = list(QuerySet(ChatRecord).filter(chat_id=chat_id).order_by('-create_time')[0:5])
|
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)
|
chat_record_list.sort(key=lambda r: r.create_time)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user