feat:【antd】【ai】知识库的 knowledge 优化

This commit is contained in:
YunaiV
2025-11-13 20:32:12 +08:00
parent e092ec737e
commit 2f67bdd410
3 changed files with 26 additions and 14 deletions

View File

@@ -23,6 +23,9 @@ export function useFormSchema(): VbenFormSchema[] {
component: 'Input', component: 'Input',
fieldName: 'name', fieldName: 'name',
label: '知识库名称', label: '知识库名称',
componentProps: {
placeholder: '请输入知识库名称',
},
rules: 'required', rules: 'required',
}, },
{ {
@@ -53,7 +56,6 @@ export function useFormSchema(): VbenFormSchema[] {
component: 'InputNumber', component: 'InputNumber',
componentProps: { componentProps: {
placeholder: '请输入检索 topK', placeholder: '请输入检索 topK',
class: 'w-full',
min: 0, min: 0,
max: 10, max: 10,
}, },
@@ -65,7 +67,6 @@ export function useFormSchema(): VbenFormSchema[] {
component: 'InputNumber', component: 'InputNumber',
componentProps: { componentProps: {
placeholder: '请输入检索相似度阈值', placeholder: '请输入检索相似度阈值',
class: 'w-full',
min: 0, min: 0,
max: 1, max: 1,
step: 0.01, step: 0.01,
@@ -94,14 +95,19 @@ export function useGridFormSchema(): VbenFormSchema[] {
fieldName: 'name', fieldName: 'name',
label: '知识库名称', label: '知识库名称',
component: 'Input', component: 'Input',
componentProps: {
placeholder: '请输入知识库名称',
allowClear: true,
},
}, },
{ {
fieldName: 'status', fieldName: 'status',
label: '是否启用', label: '是否启用',
component: 'Select', component: 'Select',
componentProps: { componentProps: {
allowClear: true,
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'), options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
placeholder: '请选择是否启用',
allowClear: true,
}, },
}, },
{ {
@@ -122,22 +128,27 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
{ {
field: 'id', field: 'id',
title: '编号', title: '编号',
minWidth: 100,
}, },
{ {
field: 'name', field: 'name',
title: '知识库名称', title: '知识库名称',
minWidth: 150,
}, },
{ {
field: 'description', field: 'description',
title: '知识库描述', title: '知识库描述',
minWidth: 200,
}, },
{ {
field: 'embeddingModel', field: 'embeddingModel',
title: '向量化模型', title: '向量化模型',
minWidth: 150,
}, },
{ {
field: 'status', field: 'status',
title: '是否启用', title: '是否启用',
minWidth: 100,
cellRender: { cellRender: {
name: 'CellDict', name: 'CellDict',
props: { type: DICT_TYPE.COMMON_STATUS }, props: { type: DICT_TYPE.COMMON_STATUS },
@@ -146,6 +157,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
{ {
field: 'createTime', field: 'createTime',
title: '创建时间', title: '创建时间',
minWidth: 180,
formatter: 'formatDateTime', formatter: 'formatDateTime',
}, },
{ {

View File

@@ -28,17 +28,17 @@ function handleRefresh() {
gridApi.query(); gridApi.query();
} }
/** 创建 */ /** 创建知识库 */
function handleCreate() { function handleCreate() {
formModalApi.setData(null).open(); formModalApi.setData(null).open();
} }
/** 编辑 */ /** 编辑知识库 */
function handleEdit(row: AiKnowledgeKnowledgeApi.Knowledge) { function handleEdit(row: AiKnowledgeKnowledgeApi.Knowledge) {
formModalApi.setData(row).open(); formModalApi.setData(row).open();
} }
/** 删除 */ /** 删除知识库 */
async function handleDelete(row: AiKnowledgeKnowledgeApi.Knowledge) { async function handleDelete(row: AiKnowledgeKnowledgeApi.Knowledge) {
const hideLoading = message.loading({ const hideLoading = message.loading({
content: $t('ui.actionMessage.deleting', [row.name]), content: $t('ui.actionMessage.deleting', [row.name]),
@@ -46,15 +46,14 @@ async function handleDelete(row: AiKnowledgeKnowledgeApi.Knowledge) {
}); });
try { try {
await deleteKnowledge(row.id as number); await deleteKnowledge(row.id as number);
message.success({ message.success($t('ui.actionMessage.deleteSuccess', [row.name]));
content: $t('ui.actionMessage.deleteSuccess', [row.name]),
});
handleRefresh(); handleRefresh();
} finally { } finally {
hideLoading(); hideLoading();
} }
} }
/** 文档按钮操作 */
/** 跳转到知识库文档页面 */
const router = useRouter(); const router = useRouter();
function handleDocument(id: number) { function handleDocument(id: number) {
router.push({ router.push({
@@ -92,6 +91,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
}, },
rowConfig: { rowConfig: {
keyField: 'id', keyField: 'id',
isHover: true,
}, },
toolbarConfig: { toolbarConfig: {
refresh: true, refresh: true,

View File

@@ -17,7 +17,7 @@ import {
import { getKnowledge } from '#/api/ai/knowledge/knowledge'; import { getKnowledge } from '#/api/ai/knowledge/knowledge';
import { searchKnowledgeSegment } from '#/api/ai/knowledge/segment'; import { searchKnowledgeSegment } from '#/api/ai/knowledge/segment';
/** 文档召回测试 */ /** 知识库文档召回测试 */
defineOptions({ name: 'KnowledgeDocumentRetrieval' }); defineOptions({ name: 'KnowledgeDocumentRetrieval' });
const route = useRoute(); const route = useRoute();
@@ -32,7 +32,7 @@ const queryParams = reactive({
similarityThreshold: 0.5, similarityThreshold: 0.5,
}); });
/** 调用文档召回测试接口 */ /** 执行召回测试 */
async function getRetrievalResult() { async function getRetrievalResult() {
if (!queryParams.content) { if (!queryParams.content) {
message.warning('请输入查询文本'); message.warning('请输入查询文本');
@@ -57,12 +57,12 @@ async function getRetrievalResult() {
} }
} }
/** 展开/收起段落内容 */ /** 切换段落展开状态 */
function toggleExpand(segment: any) { function toggleExpand(segment: any) {
segment.expanded = !segment.expanded; segment.expanded = !segment.expanded;
} }
/** 获取知识库信息 */ /** 获取知识库配置信息 */
async function getKnowledgeInfo(id: number) { async function getKnowledgeInfo(id: number) {
try { try {
const knowledge = await getKnowledge(id); const knowledge = await getKnowledge(id);