You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
fu-hsi-web/src/views/promptManagement/PromptConfig/add/PromptDebug.vue

246 lines
6.5 KiB
Vue

8 months ago
<template>
<cs-drawer
:drawer-option="drawerOption"
>
<div slot="content" class="PromptDebug">
<div class="left">
<div class="title">识别结果预览</div>
<div class="left-content">
8 months ago
<div v-if="dataInfo.name" class="top">{{ `${dataInfo.name}` }}</div>
<div v-if="dataList.length === 0" class="empty">
8 months ago
<img src="@/assets/common/file_empty.png" alt="">
<span>暂无结果请在右侧输入调试内容或上传文档</span>
8 months ago
</div>
<div v-if="dataList.length > 0" class="data-list">
<div v-for="(item,index) in dataList" :key="index" class="data-item">
<div class="left">{{ item.attrName }}</div>
<div class="right">{{ item.attrValue }}</div>
</div>
</div>
8 months ago
</div>
</div>
<div class="right">
<el-button type="primary" class="btn" @click="submit"></el-button>
8 months ago
<div class="right-item">
<span>调试内容</span>
<el-input
8 months ago
v-model="text"
8 months ago
type="textarea"
:rows="8"
placeholder="请输入"
/>
</div>
<div class="right-item">
<span>选择文件</span>
<el-upload
:headers="{
token: token
}"
:action="uploadOption.action"
:accept="uploadOption.accept"
:data="{
temp: true
}"
8 months ago
:on-remove="remove"
8 months ago
:on-success="handleSuccess"
:before-upload="beforeUpload"
>
<div class="up-btn">
请选择文件
</div>
<div class="desc">支持上传扩展名为txtdocdocx文件且仅限一份文件</div>
</el-upload>
</div>
</div>
</div>
</cs-drawer>
</template>
<script>
import { baseURL } from '@/config'
import { getAccessToken } from '@/utils/accessToken'
8 months ago
import { promptDebugging } from '@/api/promptManagement'
8 months ago
export default {
name: 'PromptDebug',
data() {
return {
drawerOption: {
show: false,
title: '提示词调试',
width: '1200px',
hiddenFooter: true
},
8 months ago
text: '',
8 months ago
// 上传配置
uploadOption: {
action: `${baseURL}/minio/uploadFile`,
accept: '.txt,.doc,.docx'
},
token: getAccessToken(),
fileId: '',
fileList: [],
8 months ago
dataList: [],
tripleList: [],
8 months ago
dataInfo: undefined
}
},
methods: {
8 months ago
show(data, list) {
this.fileId = ''
this.dataList = []
8 months ago
this.drawerOption.show = true
this.dataInfo = data
8 months ago
if (list) {
this.list = list
}
8 months ago
},
beforeUpload(file) {
const isLt5M = file.size / 1024 / 1024 < 5
const filename = file.name
const postfix = filename.substring(filename.lastIndexOf('.'))
if (!['.txt', '.doc', '.docx'].includes(postfix)) {
this.$message.error('上传图片只能是 txt,doc,docx 格式!')
return false
}
if (!isLt5M) {
this.$message.error('上传头像图片大小不能超过 5MB!')
return false
}
return true
},
handleSuccess(res, file) {
this.fileId = res.data
8 months ago
},
remove() {
this.fileId = ''
},
// 调试
submit() {
if (!this.text && !this.fileId) {
this.$message.error('请上传文件或者输入调试内容!')
return
}
8 months ago
const params = {
text: this.text,
type: this.dataInfo.type,
prompt: this.dataInfo.prompt,
extractAttributes: this.dataInfo.extractAttributes,
fileId: this.fileId
}
if (params.type === '2') {
params.tripleList = this.list
}
promptDebugging(params).then(res => {
if (res.code === 200) {
this.dataList = res.data
}
})
8 months ago
}
}
}
</script>
<style scoped lang="scss">
.PromptDebug {
display: flex;
padding: 16px;
overflow: auto;
.left {
width: 50%;
.title {
font-size: 18px;
color: #333333;
margin-bottom: 16px;
}
.left-content {
border-radius: 6px 6px 6px 6px;
border: 1px solid #D9D9D9;
width: 100%;
height: calc(100vh - 300px);
.empty {
margin: 260px auto;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
img {
width: 200px;
height: 200px;
}
span {
font-size: 16px;
color: #333333;
}
}
.top {
height: 53px;
background: #F2F6FA;font-size: 16px;
color: #888888;
line-height: 53px;
padding-left: 24px;
}
8 months ago
.data-list {
display: flex;
flex-direction: column;
padding: 24px;
overflow: auto;
height: calc(100vh - 400px);
.data-item {
display: flex;
margin-bottom: 24px;
align-items: center;
.left {
width: 120px;
font-size: 16px;
color: #666666;
text-align: right;
}
.right {
margin-left: 24px;font-size: 16px;
color: #333333;
}
}
}
8 months ago
}
}
.right {
margin-left: 32px;
flex: 1;
position: relative;
.btn {
position: absolute;
right: 0;
top: 16px;
}
8 months ago
.right-item {
display: flex;
flex-direction: column;
margin-top: 24px;
span {
font-size: 16px;
color: #333333;
margin-bottom: 16px;
}
.up-btn {
width: 128px;
height: 42px;
background: #FFFFFF;
border-radius: 6px 6px 6px 6px;
border: 1px solid #3763FF;
line-height: 42px;
font-size: 16px;
color: #3763FF;
cursor: pointer;
}
.desc {
font-size: 16px;
color: #B4B4B4;
margin-top: 16px;
}
}
}
}
</style>