1
This commit is contained in:
@@ -0,0 +1,113 @@
|
||||
<template>
|
||||
<div class="kg-page">
|
||||
<div class="kg-head">
|
||||
<el-select v-model="datasetId" placeholder="选择知识库" style="width: 260px" @change="load">
|
||||
<el-option v-for="d in datasets" :key="d.id" :label="d.name" :value="d.id" />
|
||||
</el-select>
|
||||
<span class="kg-tip">实体与关系由解析流水线中的 LLM 抽取生成,问答时命中实体自动注入一跳邻居</span>
|
||||
</div>
|
||||
|
||||
<el-row :gutter="12">
|
||||
<el-col :span="10">
|
||||
<el-card shadow="never" class="kg-card">
|
||||
<template #header>实体({{ entityTotal }})</template>
|
||||
<el-table :data="entities" size="small" v-loading="loading">
|
||||
<el-table-column prop="name" label="实体" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="entity_type" label="类型" width="110" />
|
||||
<el-table-column prop="chunk_id" label="来源分块" width="100" />
|
||||
</el-table>
|
||||
<el-pagination class="kg-page-bar" small layout="prev, pager, next" :total="entityTotal"
|
||||
:page-size="entityPageSize" v-model:current-page="entityPage" @current-change="loadEntities" />
|
||||
</el-card>
|
||||
</el-col>
|
||||
<el-col :span="14">
|
||||
<el-card shadow="never" class="kg-card">
|
||||
<template #header>关系({{ relationTotal }})</template>
|
||||
<el-table :data="relations" size="small" v-loading="loading">
|
||||
<el-table-column prop="head" label="主体" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="relation" label="关系" min-width="100" show-overflow-tooltip />
|
||||
<el-table-column prop="tail" label="客体" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="chunk_id" label="来源分块" width="100" />
|
||||
</el-table>
|
||||
<el-pagination class="kg-page-bar" small layout="prev, pager, next" :total="relationTotal"
|
||||
:page-size="relationPageSize" v-model:current-page="relationPage" @current-change="loadRelations" />
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { listDatasets } from '../api/dataset.js'
|
||||
import { listEntities, listRelations } from '../api/kg.js'
|
||||
|
||||
const datasets = ref([])
|
||||
const datasetId = ref(null)
|
||||
const loading = ref(false)
|
||||
|
||||
const entities = ref([])
|
||||
const entityTotal = ref(0)
|
||||
const entityPage = ref(1)
|
||||
const entityPageSize = 20
|
||||
|
||||
const relations = ref([])
|
||||
const relationTotal = ref(0)
|
||||
const relationPage = ref(1)
|
||||
const relationPageSize = 20
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
datasets.value = await listDatasets()
|
||||
if (datasets.value.length) datasetId.value = datasets.value[0].id
|
||||
} catch { /* 忽略 */ }
|
||||
await load()
|
||||
})
|
||||
|
||||
async function load() {
|
||||
entityPage.value = 1
|
||||
relationPage.value = 1
|
||||
await Promise.all([loadEntities(), loadRelations()])
|
||||
}
|
||||
|
||||
async function loadEntities() {
|
||||
if (!datasetId.value) return
|
||||
loading.value = true
|
||||
try {
|
||||
const d = await listEntities({ dataset_id: datasetId.value, page: entityPage.value, page_size: entityPageSize })
|
||||
entities.value = d.list
|
||||
entityTotal.value = d.total
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function loadRelations() {
|
||||
if (!datasetId.value) return
|
||||
loading.value = true
|
||||
try {
|
||||
const d = await listRelations({ dataset_id: datasetId.value, page: relationPage.value, page_size: relationPageSize })
|
||||
relations.value = d.list
|
||||
relationTotal.value = d.total
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.kg-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.kg-tip {
|
||||
font-size: 13px;
|
||||
color: #909399;
|
||||
}
|
||||
.kg-page-bar {
|
||||
margin-top: 10px;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user