feat:【ele】【ai】知识库的 knowledge 优化实现

This commit is contained in:
YunaiV
2025-11-14 18:22:56 +08:00
parent 78bd8bee8f
commit 5dc6f2d672
10 changed files with 134 additions and 21 deletions

View File

@@ -48,9 +48,13 @@ export function updateKnowledgeSegment(
}
// 修改知识库分段状态
export function updateKnowledgeSegmentStatus(data: any) {
return requestClient.put('/ai/knowledge/segment/update-status', data);
export function updateKnowledgeSegmentStatus(id: number, status: number) {
return requestClient.put('/ai/knowledge/segment/update-status', {
id,
status,
});
}
// 删除知识库分段
export function deleteKnowledgeSegment(id: number) {
return requestClient.delete(`/ai/knowledge/segment/delete?id=${id}`);

View File

@@ -10,4 +10,5 @@ export const ACTION_ICON = {
MORE: 'lucide:ellipsis-vertical',
VIEW: 'lucide:eye',
COPY: 'lucide:copy',
BOOK: 'lucide:book',
};

View File

@@ -0,0 +1,113 @@
import type { RouteRecordRaw } from 'vue-router';
const routes: RouteRecordRaw[] = [
{
path: '/ai',
name: 'Ai',
meta: {
title: 'Ai',
hideInMenu: true,
},
children: [
// {
// path: 'image/square',
// component: () => import('#/views/ai/image/square/index.vue'),
// name: 'AiImageSquare',
// meta: {
// noCache: true,
// hidden: true,
// canTo: true,
// title: '绘图作品',
// activePath: '/ai/image',
// },
// },
{
path: 'knowledge/document',
component: () => import('#/views/ai/knowledge/document/index.vue'),
name: 'AiKnowledgeDocument',
meta: {
noCache: true,
hidden: true,
canTo: true,
title: '知识库文档',
activePath: '/ai/knowledge',
},
},
{
path: 'knowledge/document/create',
component: () => import('#/views/ai/knowledge/document/form/index.vue'),
name: 'AiKnowledgeDocumentCreate',
meta: {
noCache: true,
hidden: true,
canTo: true,
title: '创建文档',
activePath: '/ai/knowledge',
},
},
{
path: 'knowledge/document/update',
component: () => import('#/views/ai/knowledge/document/form/index.vue'),
name: 'AiKnowledgeDocumentUpdate',
meta: {
noCache: true,
hidden: true,
canTo: true,
title: '修改文档',
activePath: '/ai/knowledge',
},
},
{
path: 'knowledge/retrieval',
component: () =>
import('#/views/ai/knowledge/knowledge/retrieval/index.vue'),
name: 'AiKnowledgeRetrieval',
meta: {
noCache: true,
hidden: true,
canTo: true,
title: '文档召回测试',
activePath: '/ai/knowledge',
},
},
{
path: 'knowledge/segment',
component: () => import('#/views/ai/knowledge/segment/index.vue'),
name: 'AiKnowledgeSegment',
meta: {
noCache: true,
hidden: true,
canTo: true,
title: '知识库分段',
activePath: '/ai/knowledge',
},
},
// {
// path: String.raw`workflow/create/:id(\d+)/:type(update|create)`,
// component: () => import('#/views/ai/workflow/form/index.vue'),
// name: 'AiWorkflowCreate',
// meta: {
// noCache: true,
// hidden: true,
// canTo: true,
// title: '设计 AI 工作流',
// activePath: '/ai/workflow',
// },
// },
// {
// path: 'console/workflow/:type/:id',
// component: () => import('#/views/ai/workflow/form/index.vue'),
// name: 'AiWorkflowUpdate',
// meta: {
// noCache: true,
// hidden: true,
// canTo: true,
// title: '设计 AI 工作流',
// activePath: '/ai/workflow',
// },
// },
],
},
];
export default routes;

View File

@@ -53,10 +53,10 @@ export function useFormSchema(): VbenFormSchema[] {
component: 'InputNumber',
componentProps: {
placeholder: '请输入检索 topK',
controlsPosition: 'right',
class: '!w-full',
min: 0,
max: 10,
controlsPosition: 'right',
class: '!w-full',
},
rules: 'required',
},
@@ -66,12 +66,12 @@ export function useFormSchema(): VbenFormSchema[] {
component: 'InputNumber',
componentProps: {
placeholder: '请输入检索相似度阈值',
controlsPosition: 'right',
class: '!w-full',
min: 0,
max: 1,
step: 0.01,
precision: 2,
controlsPosition: 'right',
class: '!w-full',
},
rules: 'required',
},
@@ -159,8 +159,8 @@ export function useGridColumns(
attrs: { beforeChange: onStatusChange },
name: 'CellSwitch',
props: {
checkedValue: CommonStatusEnum.ENABLE,
unCheckedValue: CommonStatusEnum.DISABLE,
activeValue: CommonStatusEnum.ENABLE,
inactiveValue: CommonStatusEnum.DISABLE,
},
},
},

View File

@@ -164,12 +164,11 @@ onMounted(() => {
auth: ['ai:knowledge:update'],
onClick: handleEdit.bind(null, row.id),
},
]"
:drop-down-actions="[
{
label: '分段',
type: 'primary',
link: true,
icon: ACTION_ICON.BOOK,
auth: ['ai:knowledge:query'],
onClick: handleSegment.bind(null, row.id),
},

View File

@@ -56,10 +56,10 @@ export function useFormSchema(): VbenFormSchema[] {
component: 'InputNumber',
componentProps: {
placeholder: '请输入检索 topK',
controlsPosition: 'right',
class: '!w-full',
min: 0,
max: 10,
controlsPosition: 'right',
class: '!w-full',
},
rules: 'required',
},
@@ -69,12 +69,12 @@ export function useFormSchema(): VbenFormSchema[] {
component: 'InputNumber',
componentProps: {
placeholder: '请输入检索相似度阈值',
controlsPosition: 'right',
class: '!w-full',
min: 0,
max: 1,
step: 0.01,
precision: 2,
controlsPosition: 'right',
class: '!w-full',
},
rules: 'required',
},
@@ -170,4 +170,3 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
},
];
}

View File

@@ -87,4 +87,3 @@ const [Modal, modalApi] = useVbenModal({
<Form class="mx-4" />
</Modal>
</template>

View File

@@ -9,8 +9,8 @@ import {
ElButton,
ElCard,
ElEmpty,
ElInputNumber,
ElInput,
ElInputNumber,
ElMessage,
} from 'element-plus';

View File

@@ -109,8 +109,8 @@ export function useGridColumns(
attrs: { beforeChange: onStatusChange },
name: 'CellSwitch',
props: {
checkedValue: CommonStatusEnum.ENABLE,
unCheckedValue: CommonStatusEnum.DISABLE,
activeValue: CommonStatusEnum.ENABLE,
inactiveValue: CommonStatusEnum.DISABLE,
},
},
},
@@ -128,4 +128,3 @@ export function useGridColumns(
},
];
}

View File

@@ -87,4 +87,3 @@ const [Modal, modalApi] = useVbenModal({
<Form class="mx-4" />
</Modal>
</template>