feat(knowledge): implement knowledge item rebuild confirmation dialog and enhance chunk processing options
- Added a confirmation dialog for rebuilding knowledge items in the KnowledgeBase component. - Introduced new state variables to manage the rebuild process and item selection. - Enhanced the processChunks function to support question generation options based on configuration. - Updated the knowledge service to handle question generation settings during document processing.
This commit is contained in:
@@ -167,6 +167,8 @@ const onVisibleChange = (visible: boolean) => {
|
|||||||
let isCardDetails = ref(false);
|
let isCardDetails = ref(false);
|
||||||
let timeout: ReturnType<typeof setInterval> | null = null;
|
let timeout: ReturnType<typeof setInterval> | null = null;
|
||||||
let delDialog = ref(false)
|
let delDialog = ref(false)
|
||||||
|
let rebuildDialog = ref(false)
|
||||||
|
let rebuildKnowledgeItem = ref<KnowledgeCard>({ id: '', parse_status: '' })
|
||||||
let knowledge = ref<KnowledgeCard>({ id: '', parse_status: '' })
|
let knowledge = ref<KnowledgeCard>({ id: '', parse_status: '' })
|
||||||
let knowledgeIndex = ref(-1)
|
let knowledgeIndex = ref(-1)
|
||||||
let knowledgeScroll = ref()
|
let knowledgeScroll = ref()
|
||||||
@@ -1299,7 +1301,7 @@ const handleManualEdit = (index: number, item: KnowledgeCard) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleKnowledgeReparse = async (index: number, item: KnowledgeCard) => {
|
const handleKnowledgeReparse = (index: number, item: KnowledgeCard) => {
|
||||||
if (isFAQ.value) return;
|
if (isFAQ.value) return;
|
||||||
if (!canEdit.value) return;
|
if (!canEdit.value) return;
|
||||||
if (!item?.id) {
|
if (!item?.id) {
|
||||||
@@ -1313,10 +1315,14 @@ const handleKnowledgeReparse = async (index: number, item: KnowledgeCard) => {
|
|||||||
if (cardList.value[index]) {
|
if (cardList.value[index]) {
|
||||||
cardList.value[index].isMore = false;
|
cardList.value[index].isMore = false;
|
||||||
}
|
}
|
||||||
const confirm = window.confirm(
|
rebuildKnowledgeItem.value = item;
|
||||||
t('knowledgeBase.rebuildConfirm', { fileName: item.file_name || item.title || '' }) as string,
|
rebuildDialog.value = true;
|
||||||
);
|
};
|
||||||
if (!confirm) return;
|
|
||||||
|
const rebuildConfirm = async () => {
|
||||||
|
rebuildDialog.value = false;
|
||||||
|
const item = rebuildKnowledgeItem.value;
|
||||||
|
if (!item?.id) return;
|
||||||
try {
|
try {
|
||||||
await reparseKnowledge(item.id);
|
await reparseKnowledge(item.id);
|
||||||
MessagePlugin.success(t('knowledgeBase.rebuildSubmitted'));
|
MessagePlugin.success(t('knowledgeBase.rebuildSubmitted'));
|
||||||
@@ -1736,7 +1742,7 @@ async function createNewSession(value: string): Promise<void> {
|
|||||||
@click.stop="openMore(index)"
|
@click.stop="openMore(index)"
|
||||||
:class="[moreIndex == index ? 'active-more' : '']"
|
:class="[moreIndex == index ? 'active-more' : '']"
|
||||||
>
|
>
|
||||||
<img class="more" src="@/assets/img/more.png" alt="" />
|
<img class="more-icon" src="@/assets/img/more.png" alt="" />
|
||||||
</div>
|
</div>
|
||||||
<template #content>
|
<template #content>
|
||||||
<!-- Normal menu -->
|
<!-- Normal menu -->
|
||||||
@@ -1956,6 +1962,31 @@ async function createNewSession(value: string): Promise<void> {
|
|||||||
</div>
|
</div>
|
||||||
</t-dialog>
|
</t-dialog>
|
||||||
|
|
||||||
|
<!-- 重建知识确认弹窗 -->
|
||||||
|
<t-dialog
|
||||||
|
v-model:visible="rebuildDialog"
|
||||||
|
dialogClassName="del-knowledge"
|
||||||
|
:closeBtn="false"
|
||||||
|
:cancelBtn="null"
|
||||||
|
:confirmBtn="null"
|
||||||
|
>
|
||||||
|
<div class="circle-wrap">
|
||||||
|
<div class="header">
|
||||||
|
<img class="circle-img" src="@/assets/img/circle.png" alt="" />
|
||||||
|
<span class="circle-title">{{ t('knowledgeBase.rebuildDocument') }}</span>
|
||||||
|
</div>
|
||||||
|
<span class="del-circle-txt">
|
||||||
|
{{ t('knowledgeBase.rebuildConfirm', { fileName: rebuildKnowledgeItem.file_name || rebuildKnowledgeItem.title || '' }) }}
|
||||||
|
</span>
|
||||||
|
<div class="circle-btn">
|
||||||
|
<span class="circle-btn-txt" @click="rebuildDialog = false">{{ t('common.cancel') }}</span>
|
||||||
|
<span class="circle-btn-txt confirm" @click="rebuildConfirm">
|
||||||
|
{{ t('common.confirm') }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</t-dialog>
|
||||||
|
|
||||||
<!-- URL 导入对话框 -->
|
<!-- URL 导入对话框 -->
|
||||||
<t-dialog
|
<t-dialog
|
||||||
v-model:visible="urlDialogVisible"
|
v-model:visible="urlDialogVisible"
|
||||||
@@ -3187,7 +3218,7 @@ async function createNewSession(value: string): Promise<void> {
|
|||||||
background: var(--td-component-stroke);
|
background: var(--td-component-stroke);
|
||||||
}
|
}
|
||||||
|
|
||||||
.more {
|
.more-icon {
|
||||||
width: 14px;
|
width: 14px;
|
||||||
height: 14px;
|
height: 14px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1344,7 +1344,15 @@ func (s *knowledgeService) processDocumentFromPassage(ctx context.Context,
|
|||||||
start = end
|
start = end
|
||||||
}
|
}
|
||||||
// Process and store chunks
|
// Process and store chunks
|
||||||
s.processChunks(ctx, kb, knowledge, chunks)
|
var opts ProcessChunksOptions
|
||||||
|
if kb.QuestionGenerationConfig != nil && kb.QuestionGenerationConfig.Enabled {
|
||||||
|
opts.EnableQuestionGeneration = true
|
||||||
|
opts.QuestionCount = kb.QuestionGenerationConfig.QuestionCount
|
||||||
|
if opts.QuestionCount <= 0 {
|
||||||
|
opts.QuestionCount = 3
|
||||||
|
}
|
||||||
|
}
|
||||||
|
s.processChunks(ctx, kb, knowledge, chunks, opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ProcessChunksOptions contains options for processing chunks
|
// ProcessChunksOptions contains options for processing chunks
|
||||||
@@ -6848,6 +6856,13 @@ func (s *knowledgeService) triggerManualProcessing(ctx context.Context,
|
|||||||
EnableMultimodel: kb.IsMultimodalEnabled() && len(resolvedImages) > 0,
|
EnableMultimodel: kb.IsMultimodalEnabled() && len(resolvedImages) > 0,
|
||||||
StoredImages: resolvedImages,
|
StoredImages: resolvedImages,
|
||||||
}
|
}
|
||||||
|
if kb.QuestionGenerationConfig != nil && kb.QuestionGenerationConfig.Enabled {
|
||||||
|
opts.EnableQuestionGeneration = true
|
||||||
|
opts.QuestionCount = kb.QuestionGenerationConfig.QuestionCount
|
||||||
|
if opts.QuestionCount <= 0 {
|
||||||
|
opts.QuestionCount = 3
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if kb.ChunkingConfig.EnableParentChild {
|
if kb.ChunkingConfig.EnableParentChild {
|
||||||
parentCfg, childCfg := buildParentChildConfigs(kb.ChunkingConfig, chunkCfg)
|
parentCfg, childCfg := buildParentChildConfigs(kb.ChunkingConfig, chunkCfg)
|
||||||
@@ -7473,7 +7488,11 @@ func (s *knowledgeService) ProcessDocument(ctx context.Context, t *asynq.Task) e
|
|||||||
})
|
})
|
||||||
start = end
|
start = end
|
||||||
}
|
}
|
||||||
s.processChunks(ctx, kb, knowledge, passageChunks)
|
passageOpts := ProcessChunksOptions{
|
||||||
|
EnableQuestionGeneration: payload.EnableQuestionGeneration,
|
||||||
|
QuestionCount: payload.QuestionCount,
|
||||||
|
}
|
||||||
|
s.processChunks(ctx, kb, knowledge, passageChunks, passageOpts)
|
||||||
return nil
|
return nil
|
||||||
} else {
|
} else {
|
||||||
// File import
|
// File import
|
||||||
|
|||||||
Reference in New Issue
Block a user