feat: 命中测试

This commit is contained in:
wangdan-fit2cloud 2023-12-29 15:13:30 +08:00
parent 89a74dd862
commit 6c2a6673df
10 changed files with 117 additions and 35 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@ -231,6 +231,21 @@ const putChatVote: (
)
}
/**
*
* @param application_id
* @param loading
* @query { query_text: string, top_number: number, similarity: number }
* @returns
*/
const getApplicationHitTest: (
application_id: string,
data: any,
loading?: Ref<boolean>
) => Promise<Result<Array<any>>> = (application_id, data, loading) => {
return get(`${prefix}/${application_id}/hit_test`, data, loading)
}
export default {
getAllAppilcation,
getApplication,
@ -246,5 +261,6 @@ export default {
putAccessToken,
postAppAuthentication,
getProfile,
putChatVote
putChatVote,
getApplicationHitTest
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 770 KiB

View File

@ -50,6 +50,18 @@ const applicationRouter = {
},
component: () => import('@/views/application/CreateAndSetting.vue')
},
{
path: 'hit-test',
name: 'AppHitTest',
meta: {
icon: 'app-hit-test',
title: '命中测试',
active: 'hit-test',
parentPath: '/application/:id',
parentName: 'ApplicationDetail'
},
component: () => import('@/views/hit-test/index.vue')
},
{
path: 'log',
name: 'Log',

View File

@ -37,18 +37,18 @@ const datasetRouter = {
},
component: () => import('@/views/document/index.vue')
},
// {
// path: 'hit-test',
// name: 'HitTest',
// meta: {
// icon: 'app-hit-test',
// title: '命中测试',
// active: 'hit-test',
// parentPath: '/dataset/:id',
// parentName: 'DatasetDetail'
// },
// component: () => import('@/views/hit-test/index.vue')
// },
{
path: 'hit-test',
name: 'DatasetHitTest',
meta: {
icon: 'app-hit-test',
title: '命中测试',
active: 'hit-test',
parentPath: '/dataset/:id',
parentName: 'DatasetDetail'
},
component: () => import('@/views/hit-test/index.vue')
},
{
path: 'setting',
name: 'DatasetSetting',

View File

@ -126,5 +126,8 @@ onMounted(() => {
color: var(--app-text-color);
}
}
:deep(.el-divider__text) {
background: var(--app-layout-bg-color);
}
}
</style>

View File

@ -8,14 +8,14 @@
</h3>
</template>
<div class="hit-test__main p-16" v-loading="loading">
<div class="question-title clearfix">
<div class="question-title clearfix" v-if="questionTitle">
<div class="avatar">
<AppAvatar>
<img src="@/assets/user-icon.svg" style="width: 54%" alt="" />
</AppAvatar>
</div>
<div class="content">
<h4 class="text break-all">111111</h4>
<h4 class="text break-all">{{ questionTitle }}</h4>
</div>
</div>
<el-scrollbar>
@ -41,9 +41,25 @@
:showIcon="false"
@click="editParagraph(item)"
>
<div class="active-button primary">{{ (item.similarity * 100).toFixed(2) }}%</div>
<template #footer>
<div class="footer-content flex-between">
<span> {{ numberFormat(item?.content.length) || 0 }} 字符 </span>
<el-text>
<el-icon>
<Document />
</el-icon>
{{ item?.document_name }}
</el-text>
<div v-if="item.trample_num || item.star_num">
<span v-if="item.star_num">
<AppIcon iconName="app-like-color"></AppIcon>
{{ item.star_num }}
</span>
<span v-if="item.trample_num" class="ml-4">
<AppIcon iconName="app-oppose-color"></AppIcon>
{{ item.trample_num }}
</span>
</div>
</div>
</template>
</CardBox>
@ -53,7 +69,7 @@
</el-scrollbar>
</div>
<!-- <ParagraphDialog ref="ParagraphDialogRef" :title="title" @refresh="refresh" /> -->
<ParagraphDialog ref="ParagraphDialogRef" :title="title" @refresh="refresh" />
</LayoutContainer>
<div class="hit-test__operate p-24 pt-0">
<el-popover :visible="popoverVisible" placement="top-start" :width="560" trigger="click">
@ -121,17 +137,13 @@
<script setup lang="ts">
import { reactive, ref, onMounted, computed } from 'vue'
import { useRoute } from 'vue-router'
import documentApi from '@/api/document'
import paragraphApi from '@/api/paragraph'
import datasetApi from '@/api/dataset'
// import ParagraphDialog from './component/ParagraphDialog.vue'
import { numberFormat } from '@/utils/utils'
import { MsgSuccess, MsgConfirm } from '@/utils/message'
import useStore from '@/stores'
const { paragraph } = useStore()
import applicationApi from '@/api/application'
import ParagraphDialog from '@/views/paragraph/component/ParagraphDialog.vue'
const route = useRoute()
const {
params: { id, documentId }
params: { id }
} = route as any
const ParagraphDialogRef = ref()
@ -144,9 +156,19 @@ const formInline = reactive({
top_number: 5
})
const popoverVisible = ref(false)
const questionTitle = ref('')
const isDisabledChart = computed(() => !inputValue.value)
const isApplication = computed(() => {
const { meta } = route as any
return meta?.activeMenu.includes('application')
})
const isDataset = computed(() => {
const { meta } = route as any
return meta?.activeMenu.includes('dataset')
})
function editParagraph(row: any) {
title.value = '分段详情'
ParagraphDialogRef.value.open(row)
@ -170,9 +192,19 @@ function getHitTestList() {
similarity: formInline.similarity / 100,
top_number: formInline.top_number
}
datasetApi.getDatasetHitTest(id, obj, loading).then((res) => {
paragraphDetail.value = res.data
})
if (isDataset.value) {
datasetApi.getDatasetHitTest(id, obj, loading).then((res) => {
paragraphDetail.value = res.data
questionTitle.value = inputValue.value
inputValue.value = ''
})
} else if (isApplication.value) {
applicationApi.getApplicationHitTest(id, obj, loading).then((res) => {
paragraphDetail.value = res.data
questionTitle.value = inputValue.value
inputValue.value = ''
})
}
}
function refresh(data: any) {

View File

@ -122,7 +122,7 @@ defineExpose({
background: var(--app-layout-bg-color);
padding: 0;
}
.el-divider__text {
:deep(.el-divider__text) {
background: var(--app-layout-bg-color);
}
}

View File

@ -28,7 +28,12 @@
</el-col>
<el-col :span="8" class="border-l p-24">
<!-- 关联问题 -->
<ProblemComponent :problemId="problemId" ref="ProblemRef" />
<ProblemComponent
:problemId="problemId"
:docId="document_id"
:datasetId="dataset_id"
ref="ProblemRef"
/>
</el-col>
</el-row>
<template #footer v-if="!problemId">
@ -69,12 +74,16 @@ const loading = ref(false)
const problemId = ref('')
const detail = ref<any>({})
const isEdit = ref(false)
const document_id = ref('')
const dataset_id = ref('')
watch(dialogVisible, (bool) => {
if (!bool) {
problemId.value = ''
detail.value = {}
isEdit.value = false
document_id.value = ''
dataset_id.value = ''
}
})
@ -83,6 +92,8 @@ const open = (data: any) => {
detail.value.title = data.title
detail.value.content = data.content
problemId.value = data.id
document_id.value = data.document_id
dataset_id.value = data.dataset_id
} else {
isEdit.value = true
}
@ -92,7 +103,13 @@ const submitHandle = async () => {
if (await paragraphFormRef.value?.validate()) {
if (problemId.value) {
paragraph
.asyncPutParagraph(id, documentId, problemId.value, paragraphFormRef.value?.form, loading)
.asyncPutParagraph(
dataset_id.value,
documentId || document_id.value,
problemId.value,
paragraphFormRef.value?.form,
loading
)
.then((res: any) => {
emit('refresh', res.data)
isEdit.value = false

View File

@ -37,7 +37,9 @@ import { useRoute } from 'vue-router'
import paragraphApi from '@/api/paragraph'
const props = defineProps({
problemId: String
problemId: String,
docId: String,
datasetId: String
})
const route = useRoute()
@ -68,7 +70,7 @@ function delProblemHandle(item: any, index: number) {
loading.value = true
if (item.id) {
paragraphApi
.delProblem(id, documentId, props.problemId || '', item.id)
.delProblem(props.datasetId || id, documentId || props.docId, props.problemId || '', item.id)
.then((res) => {
getProblemList()
})
@ -84,7 +86,7 @@ function delProblemHandle(item: any, index: number) {
function getProblemList() {
loading.value = true
paragraphApi
.getProblem(id, documentId, props.problemId || '')
.getProblem(props.datasetId || id, documentId || props.docId, props.problemId || '')
.then((res) => {
problemList.value = res.data
loading.value = false
@ -108,7 +110,7 @@ function addProblemHandle(val: string) {
loading.value = true
if (props.problemId) {
paragraphApi
.postProblem(id, documentId, props.problemId, obj)
.postProblem(props.datasetId || id, documentId || props.docId, props.problemId, obj)
.then((res) => {
getProblemList()
problemValue.value = ''