feat:【antd】【ai】知识库的 knowledge 优化(retrieval)
This commit is contained in:
@@ -11,4 +11,5 @@ export const ACTION_ICON = {
|
|||||||
VIEW: 'lucide:eye',
|
VIEW: 'lucide:eye',
|
||||||
COPY: 'lucide:copy',
|
COPY: 'lucide:copy',
|
||||||
CLOSE: 'lucide:x',
|
CLOSE: 'lucide:x',
|
||||||
|
BOOK: 'lucide:book',
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '操作',
|
title: '操作',
|
||||||
width: 150,
|
width: 280,
|
||||||
fixed: 'right',
|
fixed: 'right',
|
||||||
slots: { default: 'actions' },
|
slots: { default: 'actions' },
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -131,23 +131,25 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
auth: ['ai:knowledge:update'],
|
auth: ['ai:knowledge:update'],
|
||||||
onClick: handleEdit.bind(null, row),
|
onClick: handleEdit.bind(null, row),
|
||||||
},
|
},
|
||||||
]"
|
|
||||||
:drop-down-actions="[
|
|
||||||
{
|
{
|
||||||
label: $t('ui.widgets.document'),
|
label: $t('ui.widgets.document'),
|
||||||
type: 'link',
|
type: 'link',
|
||||||
|
icon: ACTION_ICON.BOOK,
|
||||||
auth: ['ai:knowledge:query'],
|
auth: ['ai:knowledge:query'],
|
||||||
onClick: handleDocument.bind(null, row.id),
|
onClick: handleDocument.bind(null, row.id),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '召回测试',
|
label: '召回测试',
|
||||||
type: 'link',
|
type: 'link',
|
||||||
|
icon: ACTION_ICON.SEARCH,
|
||||||
auth: ['ai:knowledge:query'],
|
auth: ['ai:knowledge:query'],
|
||||||
onClick: handleRetrieval.bind(null, row.id),
|
onClick: handleRetrieval.bind(null, row.id),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: $t('common.delete'),
|
label: $t('common.delete'),
|
||||||
type: 'link',
|
type: 'link',
|
||||||
|
danger: true,
|
||||||
|
icon: ACTION_ICON.DELETE,
|
||||||
auth: ['ai:knowledge:delete'],
|
auth: ['ai:knowledge:delete'],
|
||||||
popConfirm: {
|
popConfirm: {
|
||||||
title: $t('ui.actionMessage.deleteConfirm', [row.name]),
|
title: $t('ui.actionMessage.deleteConfirm', [row.name]),
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ const [Modal, modalApi] = useVbenModal({
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Modal class="w-2/5" :title="getTitle">
|
<Modal :title="getTitle" class="w-2/5">
|
||||||
<Form class="mx-4" />
|
<Form class="mx-4" />
|
||||||
</Modal>
|
</Modal>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -50,8 +50,6 @@ async function getRetrievalResult() {
|
|||||||
similarityThreshold: queryParams.similarityThreshold,
|
similarityThreshold: queryParams.similarityThreshold,
|
||||||
});
|
});
|
||||||
segments.value = data || [];
|
segments.value = data || [];
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
}
|
}
|
||||||
@@ -157,43 +155,44 @@ onMounted(() => {
|
|||||||
<div
|
<div
|
||||||
v-for="(segment, index) in segments"
|
v-for="(segment, index) in segments"
|
||||||
:key="index"
|
:key="index"
|
||||||
class="p-15 mb-20 rounded border border-solid border-gray-200"
|
class="mt-2 rounded border border-solid border-gray-200 px-2 py-2"
|
||||||
>
|
>
|
||||||
<div class="mb-5 flex justify-between text-sm text-gray-500">
|
<div
|
||||||
|
class="mb-2 flex items-center justify-between gap-8 text-sm text-gray-500"
|
||||||
|
>
|
||||||
<span>
|
<span>
|
||||||
分段({{ segment.id }}) · {{ segment.contentLength }} 字符数 ·
|
分段({{ segment.id }}) · {{ segment.contentLength }} 字符数 ·
|
||||||
{{ segment.tokens }} Token
|
{{ segment.tokens }} Token
|
||||||
</span>
|
</span>
|
||||||
<span
|
<span
|
||||||
class="rounded-full bg-blue-50 py-4 text-sm font-bold text-blue-500"
|
class="whitespace-nowrap rounded-full bg-blue-50 px-2 py-1 text-sm text-blue-500"
|
||||||
>
|
>
|
||||||
score: {{ segment.score }}
|
score: {{ segment.score }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="mb-10 overflow-hidden whitespace-pre-wrap rounded bg-gray-50 p-10 text-sm transition-all duration-100"
|
class="mb-2 overflow-hidden whitespace-pre-wrap rounded bg-gray-50 text-sm transition-all duration-100"
|
||||||
:class="{
|
:class="{
|
||||||
'max-h-50 line-clamp-2': !segment.expanded,
|
'line-clamp-2 max-h-40': !segment.expanded,
|
||||||
'max-h-[1500px]': segment.expanded,
|
'max-h-[1500px]': segment.expanded,
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
{{ segment.content }}
|
{{ segment.content }}
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center justify-between">
|
<div class="flex items-center justify-between gap-8">
|
||||||
<div class="flex items-center text-sm text-gray-500">
|
<div class="flex items-center gap-1 text-sm text-gray-500">
|
||||||
<IconifyIcon icon="lucide:file-text" class="mr-5" />
|
<IconifyIcon icon="lucide:file-text" />
|
||||||
<span>{{ segment.documentName || '未知文档' }}</span>
|
<span>{{ segment.documentName || '未知文档' }}</span>
|
||||||
</div>
|
</div>
|
||||||
<Button size="small" @click="toggleExpand(segment)">
|
<Button size="small" @click="toggleExpand(segment)">
|
||||||
{{ segment.expanded ? '收起' : '展开' }}
|
{{ segment.expanded ? '收起' : '展开' }}
|
||||||
<span
|
<IconifyIcon
|
||||||
class="mr-5"
|
:icon="
|
||||||
:class="
|
|
||||||
segment.expanded
|
segment.expanded
|
||||||
? 'lucide:chevron-up'
|
? 'lucide:chevron-up'
|
||||||
: 'lucide:chevron-down'
|
: 'lucide:chevron-down'
|
||||||
"
|
"
|
||||||
></span>
|
/>
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user