feat: Whether the document support settings of the General Knowledge Base and Feishu Knowledge Base allow downloading (#3924)
parent
64e9a29a60
commit
679453372e
|
|
@ -67,6 +67,14 @@ def get_none_result(question):
|
||||||
'result_list': [], 'result': ''}, {})
|
'result_list': [], 'result': ''}, {})
|
||||||
|
|
||||||
|
|
||||||
|
def reset_metadata(metadata):
|
||||||
|
meta = metadata.get('meta')
|
||||||
|
if isinstance(metadata.get('meta'), dict):
|
||||||
|
if not meta.get('allow_download', False):
|
||||||
|
metadata['meta'] = {'allow_download': False}
|
||||||
|
return metadata
|
||||||
|
|
||||||
|
|
||||||
class BaseRerankerNode(IRerankerNode):
|
class BaseRerankerNode(IRerankerNode):
|
||||||
def save_context(self, details, workflow_manage):
|
def save_context(self, details, workflow_manage):
|
||||||
self.context['document_list'] = details.get('document_list', [])
|
self.context['document_list'] = details.get('document_list', [])
|
||||||
|
|
@ -83,8 +91,9 @@ class BaseRerankerNode(IRerankerNode):
|
||||||
if len(documents) == 0:
|
if len(documents) == 0:
|
||||||
return get_none_result(question)
|
return get_none_result(question)
|
||||||
top_n = reranker_setting.get('top_n', 3)
|
top_n = reranker_setting.get('top_n', 3)
|
||||||
self.context['document_list'] = [{'page_content': document.page_content, 'metadata': document.metadata} for
|
self.context['document_list'] = [
|
||||||
document in documents]
|
{'page_content': document.page_content, 'metadata': reset_metadata(document.metadata)} for
|
||||||
|
document in documents]
|
||||||
self.context['question'] = question
|
self.context['question'] = question
|
||||||
workspace_id = self.workflow_manage.get_body().get('workspace_id')
|
workspace_id = self.workflow_manage.get_body().get('workspace_id')
|
||||||
reranker_model = get_model_instance_by_model_workspace_id(reranker_model_id,
|
reranker_model = get_model_instance_by_model_workspace_id(reranker_model_id,
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,12 @@ def reset_title(title):
|
||||||
return f"#### {title}\n"
|
return f"#### {title}\n"
|
||||||
|
|
||||||
|
|
||||||
|
def reset_meta(meta):
|
||||||
|
if not meta.get('allow_download', False):
|
||||||
|
return {'allow_download': False}
|
||||||
|
return meta
|
||||||
|
|
||||||
|
|
||||||
class BaseSearchKnowledgeNode(ISearchKnowledgeStepNode):
|
class BaseSearchKnowledgeNode(ISearchKnowledgeStepNode):
|
||||||
def save_context(self, details, workflow_manage):
|
def save_context(self, details, workflow_manage):
|
||||||
result = details.get('paragraph_list', [])
|
result = details.get('paragraph_list', [])
|
||||||
|
|
@ -122,7 +128,8 @@ class BaseSearchKnowledgeNode(ISearchKnowledgeStepNode):
|
||||||
'create_time': paragraph.get('create_time').strftime("%Y-%m-%d %H:%M:%S"),
|
'create_time': paragraph.get('create_time').strftime("%Y-%m-%d %H:%M:%S"),
|
||||||
'id': str(paragraph.get('id')),
|
'id': str(paragraph.get('id')),
|
||||||
'knowledge_id': str(paragraph.get('knowledge_id')),
|
'knowledge_id': str(paragraph.get('knowledge_id')),
|
||||||
'document_id': str(paragraph.get('document_id'))
|
'document_id': str(paragraph.get('document_id')),
|
||||||
|
'meta': reset_meta(paragraph.get('meta'))
|
||||||
}
|
}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
<span :title="data?.document_name?.trim()">{{ data?.document_name }}</span>
|
<span :title="data?.document_name?.trim()">{{ data?.document_name }}</span>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div v-else @click="infoMessage">
|
<div v-else @click="infoMessage(data)">
|
||||||
<span class="ellipsis-1 break-all" :title="data?.document_name?.trim()">
|
<span class="ellipsis-1 break-all" :title="data?.document_name?.trim()">
|
||||||
{{ data?.document_name?.trim() }}
|
{{ data?.document_name?.trim() }}
|
||||||
</span>
|
</span>
|
||||||
|
|
@ -87,8 +87,12 @@ const parsedMeta = computed(() => {
|
||||||
})
|
})
|
||||||
|
|
||||||
const meta = computed(() => (isMetaObject.value ? props.data.meta : parsedMeta.value))
|
const meta = computed(() => (isMetaObject.value ? props.data.meta : parsedMeta.value))
|
||||||
function infoMessage() {
|
function infoMessage(data: any) {
|
||||||
MsgInfo(t('chat.noDocument'))
|
if (data?.meta?.allow_download === false) {
|
||||||
|
MsgInfo(t('chat.noPermissionDownload'))
|
||||||
|
} else {
|
||||||
|
MsgInfo(t('chat.noDocument'))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped></style>
|
<style lang="scss" scoped></style>
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@
|
||||||
<span :title="item?.document_name?.trim()">{{ item?.document_name }}</span>
|
<span :title="item?.document_name?.trim()">{{ item?.document_name }}</span>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div v-else @click="infoMessage">
|
<div v-else @click="infoMessage(item)">
|
||||||
<span class="ellipsis-1 break-all" :title="item?.document_name?.trim()">
|
<span class="ellipsis-1 break-all" :title="item?.document_name?.trim()">
|
||||||
{{ item?.document_name?.trim() }}
|
{{ item?.document_name?.trim() }}
|
||||||
</span>
|
</span>
|
||||||
|
|
@ -167,8 +167,12 @@ const currentComponent = shallowRef<any>(null)
|
||||||
const currentChatDetail = ref<any>(null)
|
const currentChatDetail = ref<any>(null)
|
||||||
const dialogType = ref('')
|
const dialogType = ref('')
|
||||||
|
|
||||||
function infoMessage() {
|
function infoMessage(data: any) {
|
||||||
MsgInfo(t('chat.noDocument'))
|
if (data?.meta?.allow_download === false) {
|
||||||
|
MsgInfo(t('chat.noPermissionDownload'))
|
||||||
|
} else {
|
||||||
|
MsgInfo(t('chat.noDocument'))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
function openParagraph(row: any, id?: string) {
|
function openParagraph(row: any, id?: string) {
|
||||||
dialogTitle.value = t('chat.KnowledgeSource.title')
|
dialogTitle.value = t('chat.KnowledgeSource.title')
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ export default {
|
||||||
quote: 'Quote',
|
quote: 'Quote',
|
||||||
download: 'Click to Download',
|
download: 'Click to Download',
|
||||||
noDocument: 'Original Document Not Found',
|
noDocument: 'Original Document Not Found',
|
||||||
|
noPermissionDownload: 'No permission to download',
|
||||||
passwordValidator: {
|
passwordValidator: {
|
||||||
title: 'Enter Password to Access',
|
title: 'Enter Password to Access',
|
||||||
errorMessage1: 'Password cannot be empty',
|
errorMessage1: 'Password cannot be empty',
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ export default {
|
||||||
download: '点击下载文件',
|
download: '点击下载文件',
|
||||||
transcribing: '转文字中',
|
transcribing: '转文字中',
|
||||||
noDocument: '原文档不存在',
|
noDocument: '原文档不存在',
|
||||||
|
noPermissionDownload: '无权限下载',
|
||||||
passwordValidator: {
|
passwordValidator: {
|
||||||
title: '请输入密码打开链接',
|
title: '请输入密码打开链接',
|
||||||
errorMessage1: '密码不能为空',
|
errorMessage1: '密码不能为空',
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ export default {
|
||||||
quote: '引用',
|
quote: '引用',
|
||||||
download: '點擊下載文件',
|
download: '點擊下載文件',
|
||||||
noDocument: '原文檔不存在',
|
noDocument: '原文檔不存在',
|
||||||
|
noPermissionDownload: '無許可權下載',
|
||||||
passwordValidator: {
|
passwordValidator: {
|
||||||
title: '請輸入密碼打開連結',
|
title: '請輸入密碼打開連結',
|
||||||
errorMessage1: '密碼不能為空',
|
errorMessage1: '密碼不能為空',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue