feat: Implement knowledge tag management and batch updates for FAQ entries
- Added API functions for listing, creating, updating, and deleting knowledge base tags. - Introduced batch update functionality for enabling/disabling FAQ entries and updating their tags. - Enhanced the KnowledgeBase.vue and FAQEntryManager.vue components to support tag management and batch operations. - Updated localization files to include new strings related to tag management and batch operations.
This commit is contained in:
@@ -90,6 +90,38 @@ export function getChunkByIdOnly(chunkId: string) {
|
||||
return get(`/api/v1/chunks/by-id/${chunkId}`);
|
||||
}
|
||||
|
||||
export function listKnowledgeTags(kbId: string) {
|
||||
return get(`/api/v1/knowledge-bases/${kbId}/tags`);
|
||||
}
|
||||
|
||||
export function createKnowledgeBaseTag(
|
||||
kbId: string,
|
||||
data: { name: string; color?: string; sort_order?: number },
|
||||
) {
|
||||
return post(`/api/v1/knowledge-bases/${kbId}/tags`, data);
|
||||
}
|
||||
|
||||
export function updateKnowledgeBaseTag(
|
||||
kbId: string,
|
||||
tagId: string,
|
||||
data: { name?: string; color?: string; sort_order?: number },
|
||||
) {
|
||||
return put(`/api/v1/knowledge-bases/${kbId}/tags/${tagId}`, data);
|
||||
}
|
||||
|
||||
export function deleteKnowledgeBaseTag(kbId: string, tagId: string, params?: { force?: boolean }) {
|
||||
const forceQuery = params?.force ? '?force=true' : '';
|
||||
return del(`/api/v1/knowledge-bases/${kbId}/tags/${tagId}${forceQuery}`);
|
||||
}
|
||||
|
||||
export function updateKnowledgeTagBatch(data: { updates: Record<string, string | null> }) {
|
||||
return put(`/api/v1/knowledge/tags`, data);
|
||||
}
|
||||
|
||||
export function updateFAQEntryTagBatch(kbId: string, data: { updates: Record<string, string | null> }) {
|
||||
return put(`/api/v1/knowledge-bases/${kbId}/faq/entries/tags`, data);
|
||||
}
|
||||
|
||||
const buildQuery = (params?: Record<string, any>) => {
|
||||
if (!params) return '';
|
||||
const query = new URLSearchParams();
|
||||
@@ -114,6 +146,10 @@ export function updateFAQEntry(kbId: string, entryId: string, data: any) {
|
||||
return put(`/api/v1/knowledge-bases/${kbId}/faq/entries/${entryId}`, data);
|
||||
}
|
||||
|
||||
export function updateFAQEntryStatusBatch(kbId: string, data: { updates: Record<string, boolean> }) {
|
||||
return put(`/api/v1/knowledge-bases/${kbId}/faq/entries/status`, data);
|
||||
}
|
||||
|
||||
export function deleteFAQEntries(kbId: string, ids: string[]) {
|
||||
return del(`/api/v1/knowledge-bases/${kbId}/faq/entries`, { ids });
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ import { marked } from "marked";
|
||||
import { onMounted, ref, nextTick, onUnmounted, onUpdated, watch } from "vue";
|
||||
import { downKnowledgeDetails } from "@/api/knowledge-base/index";
|
||||
import { MessagePlugin } from "tdesign-vue-next";
|
||||
import picturePreview from '@/components/picture-preview.vue';
|
||||
import { sanitizeHTML, safeMarkdownToHTML, createSafeImage, isValidImageURL } from '@/utils/security';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
@@ -19,8 +18,6 @@ let doc = null;
|
||||
let down = ref()
|
||||
let mdContentWrap = ref()
|
||||
let url = ref('')
|
||||
let reviewUrl = ref('')
|
||||
let reviewImg = ref(false)
|
||||
onMounted(() => {
|
||||
nextTick(() => {
|
||||
doc = document.getElementsByClassName('t-drawer__body')[0]
|
||||
@@ -61,10 +58,6 @@ watch(() => props.details.md, (newVal) => {
|
||||
const images = mdContentWrap.value.querySelectorAll('img.markdown-image');
|
||||
if (images) {
|
||||
images.forEach(async item => {
|
||||
item.addEventListener('click', function (event) {
|
||||
reviewUrl.value = event.target.src;
|
||||
reviewImg.value = true
|
||||
})
|
||||
const isValid = await checkImage(item.src);
|
||||
if (!isValid) {
|
||||
item.remove();
|
||||
@@ -103,10 +96,6 @@ const processMarkdown = (markdownText) => {
|
||||
|
||||
return sanitizedHTML;
|
||||
};
|
||||
const closePreImg = () => {
|
||||
reviewImg.value = false
|
||||
reviewUrl.value = '';
|
||||
}
|
||||
const handleClose = () => {
|
||||
emit("closeDoc", false);
|
||||
doc.scrollTop = 0;
|
||||
@@ -179,7 +168,6 @@ const handleDetailsScroll = () => {
|
||||
<t-button theme="default" @click="handleClose">{{ $t('common.cancel') }}</t-button>
|
||||
</template>
|
||||
</t-drawer>
|
||||
<picturePreview :reviewImg="reviewImg" :reviewUrl="reviewUrl" @closePreImg="closePreImg"></picturePreview>
|
||||
</div>
|
||||
</template>
|
||||
<style scoped lang="less">
|
||||
|
||||
@@ -24,7 +24,10 @@ export default function (knowledgeBaseId?: string) {
|
||||
id: "",
|
||||
total: 0
|
||||
});
|
||||
const getKnowled = (query = { page: 1, page_size: 35 }, kbId?: string) => {
|
||||
const getKnowled = (
|
||||
query: { page: number; page_size: number; tag_id?: string } = { page: 1, page_size: 35 },
|
||||
kbId?: string,
|
||||
) => {
|
||||
const targetKbId = kbId || knowledgeBaseId;
|
||||
if (!targetKbId) return;
|
||||
|
||||
|
||||
@@ -24,6 +24,27 @@ export default {
|
||||
description: 'Description',
|
||||
files: 'Files',
|
||||
settings: 'Settings',
|
||||
documentCategoryTitle: 'Document Categories',
|
||||
tagUpdateSuccess: 'Tag updated successfully',
|
||||
category: 'Category',
|
||||
faqCategoryTitle: 'FAQ Categories',
|
||||
untagged: 'Uncategorized',
|
||||
tagSearchTooltip: 'Search tags',
|
||||
tagCreateAction: 'Create tag',
|
||||
tagSearchPlaceholder: 'Type to filter tags',
|
||||
tagNamePlaceholder: 'Enter tag name',
|
||||
tagNameRequired: 'Please provide a tag name',
|
||||
tagCreateSuccess: 'Tag created',
|
||||
tagEditSuccess: 'Tag updated',
|
||||
tagDeleteTitle: 'Delete tag',
|
||||
tagDeleteDesc: 'Delete tag "{name}"? Related FAQs will become untagged.',
|
||||
tagDeleteSuccess: 'Tag deleted',
|
||||
tagEditAction: 'Rename',
|
||||
tagDeleteAction: 'Delete',
|
||||
tagEmptyResult: 'No matching tags',
|
||||
tagLabel: 'Category',
|
||||
tagPlaceholder: 'Please select a category',
|
||||
noTags: 'No categories',
|
||||
upload: 'Upload File',
|
||||
uploadSuccess: 'File uploaded successfully!',
|
||||
uploadFailed: 'File upload failed!',
|
||||
@@ -730,6 +751,7 @@ export default {
|
||||
questionIndexModeLabel: 'Question Indexing Mode',
|
||||
questionIndexModeDescription: 'Combined: Standard and similar questions are indexed together. Separate: Each question is indexed independently for more precise retrieval but requires more storage.',
|
||||
entryGuide: 'Each FAQ entry contains a primary question, similar questions, negative examples, and multiple answers. Manage them in the FAQ knowledge base detail view.',
|
||||
tagDesc: 'Select category for FAQ entries',
|
||||
modes: {
|
||||
questionOnly: 'Questions only',
|
||||
questionAnswer: 'Question + answer',
|
||||
@@ -740,6 +762,8 @@ export default {
|
||||
answers: 'Answers',
|
||||
similarQuestions: 'Similar Questions',
|
||||
negativeQuestions: 'Negative Examples',
|
||||
categoryLabel: 'FAQ Category',
|
||||
categoryButton: 'Switch Category',
|
||||
editorCreate: 'Create FAQ Entry',
|
||||
editorEdit: 'Edit FAQ Entry',
|
||||
addAnswer: 'Add Answer',
|
||||
@@ -771,6 +795,15 @@ export default {
|
||||
matchTypeEmbedding: 'Vector Match',
|
||||
matchTypeKeywords: 'Keyword Match',
|
||||
similarityThresholdLabel: 'Similarity Threshold',
|
||||
statusEnabled: 'Enabled',
|
||||
statusDisabled: 'Disabled',
|
||||
statusEnableSuccess: 'FAQ entry enabled',
|
||||
statusDisableSuccess: 'FAQ entry disabled',
|
||||
statusUpdateFailed: 'Failed to update status',
|
||||
batchUpdateTag: 'Batch Update Category',
|
||||
batchUpdateTagTip: 'Set category for {count} selected entries',
|
||||
batchEnable: 'Batch Enable',
|
||||
batchDisable: 'Batch Disable',
|
||||
},
|
||||
faqImport: {
|
||||
title: 'Batch Import FAQ',
|
||||
|
||||
@@ -24,6 +24,27 @@ export default {
|
||||
description: 'Описание',
|
||||
files: 'Файлы',
|
||||
settings: 'Настройки',
|
||||
documentCategoryTitle: 'Категории документов',
|
||||
faqCategoryTitle: 'Категории FAQ',
|
||||
untagged: 'Без метки',
|
||||
tagSearchTooltip: 'Поиск тегов',
|
||||
tagUpdateSuccess: 'Тег успешно обновлен',
|
||||
category: 'Категория',
|
||||
tagCreateAction: 'Создать тег',
|
||||
tagSearchPlaceholder: 'Введите название тега',
|
||||
tagNamePlaceholder: 'Введите название тега',
|
||||
tagNameRequired: 'Пожалуйста, укажите название тега',
|
||||
tagCreateSuccess: 'Тег создан',
|
||||
tagEditSuccess: 'Тег обновлён',
|
||||
tagDeleteTitle: 'Удаление тега',
|
||||
tagDeleteDesc: 'Удалить тег «{name}»? Связанные FAQ будут без метки.',
|
||||
tagDeleteSuccess: 'Тег удалён',
|
||||
tagEditAction: 'Переименовать',
|
||||
tagDeleteAction: 'Удалить',
|
||||
tagEmptyResult: 'Подходящие теги не найдены',
|
||||
tagLabel: 'Категория',
|
||||
tagPlaceholder: 'Пожалуйста, выберите категорию',
|
||||
noTags: 'Нет категорий',
|
||||
upload: 'Загрузить файл',
|
||||
uploadSuccess: 'Файл успешно загружен!',
|
||||
uploadFailed: 'Ошибка загрузки файла!',
|
||||
@@ -820,6 +841,7 @@ export default {
|
||||
questionIndexModeLabel: 'Режим индексации вопросов',
|
||||
questionIndexModeDescription: 'Объединенная: стандартные и похожие вопросы индексируются вместе. Раздельная: каждый вопрос индексируется независимо для более точного поиска, но требует больше места.',
|
||||
entryGuide: 'Каждый FAQ включает основной вопрос, похожие вопросы, негативные примеры и несколько ответов. Управляйте ими в деталях FAQ-базы.',
|
||||
tagDesc: 'Выберите категорию для записей FAQ',
|
||||
modes: {
|
||||
questionOnly: 'Только вопросы',
|
||||
questionAnswer: 'Вопрос + ответ',
|
||||
@@ -830,6 +852,8 @@ export default {
|
||||
answers: 'Ответы',
|
||||
similarQuestions: 'Похожие вопросы',
|
||||
negativeQuestions: 'Негативные примеры',
|
||||
categoryLabel: 'Категория FAQ',
|
||||
categoryButton: 'Сменить категорию',
|
||||
editorCreate: 'Создать FAQ запись',
|
||||
editorEdit: 'Редактировать FAQ запись',
|
||||
addAnswer: 'Добавить ответ',
|
||||
@@ -861,6 +885,15 @@ export default {
|
||||
matchTypeEmbedding: 'Векторное совпадение',
|
||||
matchTypeKeywords: 'Совпадение ключевых слов',
|
||||
similarityThresholdLabel: 'Порог сходства',
|
||||
statusEnabled: 'Включено',
|
||||
statusDisabled: 'Выключено',
|
||||
statusEnableSuccess: 'Запись FAQ включена',
|
||||
statusDisableSuccess: 'Запись FAQ отключена',
|
||||
statusUpdateFailed: 'Не удалось обновить статус',
|
||||
batchUpdateTag: 'Пакетное обновление категории',
|
||||
batchUpdateTagTip: 'Установить категорию для {count} выбранных записей',
|
||||
batchEnable: 'Пакетное включение',
|
||||
batchDisable: 'Пакетное отключение',
|
||||
},
|
||||
faqImport: {
|
||||
title: 'Пакетный импорт FAQ',
|
||||
|
||||
@@ -24,6 +24,27 @@ export default {
|
||||
description: "描述",
|
||||
files: "文件",
|
||||
settings: "设置",
|
||||
documentCategoryTitle: "文档分类",
|
||||
faqCategoryTitle: "问题分类",
|
||||
untagged: "未分类",
|
||||
tagUpdateSuccess: "标签更新成功",
|
||||
tagSearchTooltip: "搜索标签",
|
||||
category: "分类",
|
||||
tagCreateAction: "新建标签",
|
||||
tagSearchPlaceholder: "输入标签名称关键字",
|
||||
tagNamePlaceholder: "请输入标签名称",
|
||||
tagNameRequired: "请先输入标签名称",
|
||||
tagCreateSuccess: "标签创建成功",
|
||||
tagEditSuccess: "标签更新成功",
|
||||
tagDeleteTitle: "删除标签",
|
||||
tagDeleteDesc: "确定删除标签“{name}”?已关联的 FAQ 将被标记为未分类",
|
||||
tagDeleteSuccess: "标签已删除",
|
||||
tagEditAction: "重命名",
|
||||
tagDeleteAction: "删除",
|
||||
tagEmptyResult: "未找到匹配的标签",
|
||||
tagLabel: "分类",
|
||||
tagPlaceholder: "请选择分类",
|
||||
noTags: "暂无分类",
|
||||
upload: "上传文件",
|
||||
uploadSuccess: "文件上传成功!",
|
||||
uploadFailed: "文件上传失败!",
|
||||
@@ -1049,6 +1070,7 @@ export default {
|
||||
questionIndexModeLabel: "问题索引方式",
|
||||
questionIndexModeDescription: "合并索引:标准问和相似问合并索引;分别索引:标准问和每个相似问独立索引,检索更精确但需要更多存储",
|
||||
entryGuide: "FAQ 条目由标准问、相似问、反例和多个答案组成,可在知识库详情中批量导入、编辑。",
|
||||
tagDesc: "为 FAQ 条目选择分类",
|
||||
modes: {
|
||||
questionOnly: "仅标准问/相似问",
|
||||
questionAnswer: "标准问 + 答案",
|
||||
@@ -1063,6 +1085,8 @@ export default {
|
||||
similarQuestionsDesc: "添加与标准问意思相同但表述不同的问题,帮助系统更好地匹配用户查询。",
|
||||
negativeQuestions: "反例",
|
||||
negativeQuestionsDesc: "添加不应匹配此答案的问题,用于排除误匹配的情况。",
|
||||
categoryLabel: "FAQ 分类",
|
||||
categoryButton: "切换分类",
|
||||
editorCreate: "新增 FAQ 条目",
|
||||
editorEdit: "编辑 FAQ 条目",
|
||||
addAnswer: "添加答案",
|
||||
@@ -1094,6 +1118,15 @@ export default {
|
||||
matchTypeEmbedding: "向量匹配",
|
||||
matchTypeKeywords: "关键词匹配",
|
||||
similarityThresholdLabel: "相似度阈值",
|
||||
statusEnabled: "已启用",
|
||||
statusDisabled: "已禁用",
|
||||
statusEnableSuccess: "FAQ 条目已启用",
|
||||
statusDisableSuccess: "FAQ 条目已禁用",
|
||||
statusUpdateFailed: "更新状态失败",
|
||||
batchUpdateTag: "批量分类",
|
||||
batchUpdateTagTip: "将为 {count} 个选中的条目设置分类",
|
||||
batchEnable: "批量启用",
|
||||
batchDisable: "批量禁用",
|
||||
},
|
||||
faqImport: {
|
||||
title: "批量导入 FAQ",
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user