|
|
|
@ -11,56 +11,85 @@
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="提示词类型" prop="type">
|
|
|
|
|
<el-select v-model="dataInfo['type']" style="width: 100%;" placeholder="请选择提示词类型">
|
|
|
|
|
<el-select v-model="dataInfo['type']" style="width: 100%;" placeholder="请选择提示词类型" @change="selectType">
|
|
|
|
|
<el-option v-for="item in typeOptions" :key="item.value" :label="item.label" :value="item.value" />
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="提示词名称" prop="name">
|
|
|
|
|
<el-input v-model="dataInfo['name']" clearable placeholder="请输入提示词名称" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item v-if="dataInfo.type ==='1'" label="所属目录" prop="evidenceCategoryList">
|
|
|
|
|
<el-cascader v-model="dataInfo.evidenceCategoryList" style="width: 100%;" :props="defaultProps" :options="treeData" />
|
|
|
|
|
<el-form-item v-if="dataInfo.type ==='1'" label="所属目录" prop="evidenceCategoryIdList">
|
|
|
|
|
<el-cascader v-model="dataInfo.evidenceCategoryIdList" style="width: 100%;" :props="defaultProps" :options="treeData" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<!-- <el-form-item v-if="dataInfo.type ==='1'" label="类目图标" prop="caseType">
|
|
|
|
|
<div class="select-img">
|
|
|
|
|
<div class="sel-btn" @click="openSelectImg">请选择</div>
|
|
|
|
|
</div>
|
|
|
|
|
</el-form-item> -->
|
|
|
|
|
<el-form-item v-if="dataInfo.type ==='2'" label="分类" prop="typeList">
|
|
|
|
|
<el-select v-model="dataInfo['typeList']" multiple style="width: 100%;" placeholder="请选择分类">
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="item in typeData"
|
|
|
|
|
:key="item.id"
|
|
|
|
|
|
|
|
|
|
:value="item.id"
|
|
|
|
|
:label="item.recordType"
|
|
|
|
|
/>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item v-if="dataInfo.type ==='1'" label="提取属性" prop="extractAttributes">
|
|
|
|
|
<div class="params-table">
|
|
|
|
|
<div class="top">
|
|
|
|
|
<span style="width: 450px;">字典标签</span>
|
|
|
|
|
<span style="width: 150px;">字典数值</span>
|
|
|
|
|
<span style="width: 450px;">属性键值</span>
|
|
|
|
|
<span style="width: 150px;">属性类型</span>
|
|
|
|
|
<span style="width: 80px;">操作</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div v-for="(item,index) in dataInfo.extractAttributes" :key="index" class="table-item">
|
|
|
|
|
<el-input v-model="item.attrName" style="width: 400px;margin-right: 40px;" placeholder="请输入" />
|
|
|
|
|
<el-select v-model="item.attrValueType" style="width: 120px;margin-right: 40px;" clearable placeholder="请选择">
|
|
|
|
|
<el-option v-for="items in extractList" :key="items.value" :label="items.label" :value="items.value" />
|
|
|
|
|
</el-select>
|
|
|
|
|
<i class="el-icon-delete" @click="delItem(index)" />
|
|
|
|
|
<div class="params-table-content">
|
|
|
|
|
<div v-for="(item,index) in dataInfo.extractAttributes" :key="index" class="table-item">
|
|
|
|
|
<el-input v-model="item.attrName" style="width: 400px;margin-right: 40px;" placeholder="请输入" />
|
|
|
|
|
<el-select v-model="item.attrValueType" style="width: 120px;margin-right: 40px;" clearable placeholder="请选择">
|
|
|
|
|
<el-option v-for="items in extractList" :key="items.value" :label="items.label" :value="items.value" />
|
|
|
|
|
</el-select>
|
|
|
|
|
<i class="el-icon-delete" @click="delItem(index)" />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="add-table" @click="addItem">
|
|
|
|
|
<i class="el-icon-circle-plus-outline" style="color: #3763FF;font-size: 16px;" />
|
|
|
|
|
<span>添加数据</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item v-if="dataInfo.type ==='2'" label="参数配置">
|
|
|
|
|
<vxe-grid
|
|
|
|
|
ref="entityTable"
|
|
|
|
|
v-bind="entityOptions"
|
|
|
|
|
> <template #templateName_edit="{row}">
|
|
|
|
|
<el-input v-model="row['templateName']" placeholder="请输入" />
|
|
|
|
|
</template>
|
|
|
|
|
<template #value_edit="{row}">
|
|
|
|
|
<el-input v-model="row['value']" placeholder="请输入" />
|
|
|
|
|
</template>
|
|
|
|
|
</vxe-grid>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item v-if="dataInfo.type ==='3'" label="提示词规则" prop="rules">
|
|
|
|
|
<el-input v-model="dataInfo['rules']" :row="4" readonly type="textarea" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="right">
|
|
|
|
|
<div class="right-header">
|
|
|
|
|
<span>提示词配置</span>
|
|
|
|
|
<div class="btn-list">
|
|
|
|
|
<div class="ai-btn">
|
|
|
|
|
<!-- <div class="ai-btn">
|
|
|
|
|
<i class="el-icon-refresh" />
|
|
|
|
|
<span>AI自动生成</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div> -->
|
|
|
|
|
<div class="btn" @click="handleDebug">调试</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
<div class="content">
|
|
|
|
|
<div v-if="dataInfo.prompt" class="content">
|
|
|
|
|
<!-- <el-input
|
|
|
|
|
v-model="dataInfo['prompt']"
|
|
|
|
|
type="textarea"
|
|
|
|
@ -68,8 +97,10 @@
|
|
|
|
|
placeholder="请输入提示词模板"
|
|
|
|
|
/> -->
|
|
|
|
|
<PromptInput
|
|
|
|
|
v-model="customInputHTML"
|
|
|
|
|
|
|
|
|
|
v-model="dataInfo.prompt"
|
|
|
|
|
placeholder=""
|
|
|
|
|
:data-list="promptValue[dataInfo.type]"
|
|
|
|
|
@inputText="handleChangeInputText"
|
|
|
|
|
@changeChosen="handleChangeChosen"
|
|
|
|
|
/>
|
|
|
|
@ -79,7 +110,6 @@
|
|
|
|
|
</div>
|
|
|
|
|
<div class="footer-btns">
|
|
|
|
|
<div class="btn" @click="submit">发布模板</div>
|
|
|
|
|
<div class="btn" @click="submit">保存</div>
|
|
|
|
|
<div class="reset_btn" @click="reset">重置</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
@ -91,8 +121,9 @@
|
|
|
|
|
import PromptDebug from './PromptDebug.vue'
|
|
|
|
|
import SelectImg from './SelectImg.vue'
|
|
|
|
|
import { getCaseEvidenceTree } from '@/api/caseDetails/evidence'
|
|
|
|
|
import { addOrUpdPrompt } from '@/api/promptManagement'
|
|
|
|
|
import PromptInput from './PromptInput.vue'
|
|
|
|
|
import { addOrUpdPrompt, getChunkClassify, queryPromptDetails } from '@/api/promptManagement'
|
|
|
|
|
import mixin from '@/views/mixin'
|
|
|
|
|
export default {
|
|
|
|
|
name: 'AddPrompt',
|
|
|
|
|
components: {
|
|
|
|
@ -102,104 +133,151 @@ export default {
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
// 输入框的文本,可让后端使用,如不使用,也没啥用
|
|
|
|
|
customInputText: '',
|
|
|
|
|
// 输入框返回的@人员数据
|
|
|
|
|
customInputMentions: [],
|
|
|
|
|
dataInfo: {
|
|
|
|
|
// 输入框的html代码
|
|
|
|
|
customInputHTML: '',
|
|
|
|
|
// 输入框的文本,可让后端使用,如不使用,也没啥用
|
|
|
|
|
customInputText: '',
|
|
|
|
|
// 输入框返回的@人员数据
|
|
|
|
|
customInputMentions: [],
|
|
|
|
|
|
|
|
|
|
rules: '(问[::](.*?))\s*答[::](.*?)(?=(问[::]|$))',
|
|
|
|
|
caseType: '',
|
|
|
|
|
type: '1',
|
|
|
|
|
name: '',
|
|
|
|
|
evidenceCategoryList: [],
|
|
|
|
|
typeList: [],
|
|
|
|
|
extractAttributes: [],
|
|
|
|
|
prompt: '请根据属性定义从源文本中提取属性:\n' +
|
|
|
|
|
'\n' +
|
|
|
|
|
'示例文本:\n' +
|
|
|
|
|
'"\n' +
|
|
|
|
|
'甲方:张三公司\n' +
|
|
|
|
|
'乙方:\n' +
|
|
|
|
|
'数量:5000吨水泥\n' +
|
|
|
|
|
'合同金额:8346元\n' +
|
|
|
|
|
'支付时间:2022年11月30日\n' +
|
|
|
|
|
'履行期限:2022年12月1日至2023年12月1日\n' +
|
|
|
|
|
'签订日期:2022年11月23日\n' +
|
|
|
|
|
'"\n' +
|
|
|
|
|
'\n' +
|
|
|
|
|
'示例结果:\n' +
|
|
|
|
|
'{\n' +
|
|
|
|
|
' "甲方名称": "张三公司",\n' +
|
|
|
|
|
' "乙方名称": "",\n' +
|
|
|
|
|
' "数量": "5000吨水泥",\n' +
|
|
|
|
|
' "合同金额": "8346.00",\n' +
|
|
|
|
|
' "支付时间": "2022-11-30",\n' +
|
|
|
|
|
' "履行期限": "2022年12月1日至2023年12月1日",\n' +
|
|
|
|
|
' "签订日期": "2022-11-23"\n' +
|
|
|
|
|
'}\n' +
|
|
|
|
|
'\n' +
|
|
|
|
|
'源文本:\n' +
|
|
|
|
|
'{ocr_txt}\n' +
|
|
|
|
|
'\n' +
|
|
|
|
|
'属性定义:\n' +
|
|
|
|
|
'{attr_define}\n' +
|
|
|
|
|
'\n' +
|
|
|
|
|
'### 注意事项:\n' +
|
|
|
|
|
'1. 将结果以JSON格式返回。不需要进行解释。\n' +
|
|
|
|
|
'2. 如果某字段提取不到,则返回""。\n' +
|
|
|
|
|
'3. 日期格式为yyyy-MM-dd,数字格式返回保留两位小数。\n' +
|
|
|
|
|
'4. 值为文本类型的数据,尽量使用原文中的文字。\n' +
|
|
|
|
|
'5. 只可以使用原文中的文字,不可以自行添加内容。\n' +
|
|
|
|
|
'\n' +
|
|
|
|
|
'回溯你输出的结果,确保你的输出结果符合json格式。'
|
|
|
|
|
prompt: ''
|
|
|
|
|
},
|
|
|
|
|
tableList: [{
|
|
|
|
|
name: '',
|
|
|
|
|
type: ''
|
|
|
|
|
}],
|
|
|
|
|
promptValue: {
|
|
|
|
|
'1': ['source_text', 'attr_define'],
|
|
|
|
|
'2': ['headEntityType', 'tailEntityType', 'relation']
|
|
|
|
|
},
|
|
|
|
|
// 实体关系配置
|
|
|
|
|
entityOptions: {
|
|
|
|
|
...mixin.data().gridOptions,
|
|
|
|
|
height: '300px',
|
|
|
|
|
editConfig: {
|
|
|
|
|
trigger: 'click',
|
|
|
|
|
mode: 'cell'
|
|
|
|
|
},
|
|
|
|
|
editRules: {
|
|
|
|
|
result: [{ required: true, message: '不能为空!' }]
|
|
|
|
|
},
|
|
|
|
|
columns: [
|
|
|
|
|
{ title: '类型', field: 'type' },
|
|
|
|
|
{ title: '占位符', field: 'templateName' },
|
|
|
|
|
{ title: '实体类型', field: 'value', editRender: { placeholder: '请点击输入...' }, slots: { edit: 'value_edit' }}
|
|
|
|
|
|
|
|
|
|
],
|
|
|
|
|
data: []
|
|
|
|
|
},
|
|
|
|
|
rules: {
|
|
|
|
|
caseType: [{ required: true, message: '案件类型不能为空!', trigger: 'blur' }],
|
|
|
|
|
type: [{ required: true, message: '提示词类型不能为空!', trigger: 'blur' }],
|
|
|
|
|
name: [{ required: true, message: '提示词名称不能为空!', trigger: 'blur' }],
|
|
|
|
|
extractAttributes: [{ required: true, message: '提取属性不能为空!', trigger: 'blur' }]
|
|
|
|
|
typeList: [{ required: true, message: '分类不能为空!', trigger: 'change' }],
|
|
|
|
|
extractAttributes: [{ required: true, message: '提取属性不能为空!', trigger: 'change' }]
|
|
|
|
|
},
|
|
|
|
|
defaultProps: {
|
|
|
|
|
children: 'child',
|
|
|
|
|
label: 'categoryName',
|
|
|
|
|
value: 'id',
|
|
|
|
|
checkStrictly: true
|
|
|
|
|
value: 'id'
|
|
|
|
|
},
|
|
|
|
|
treeData: [],
|
|
|
|
|
id: '',
|
|
|
|
|
extractList: [
|
|
|
|
|
{
|
|
|
|
|
label: '输入框',
|
|
|
|
|
value: 'text'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: '日期',
|
|
|
|
|
value: 'date'
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
extractList: JSON.parse(sessionStorage.getItem('prompt_attribute_valuetype')),
|
|
|
|
|
typeData: [], // 分类下拉
|
|
|
|
|
// 案件类型数据
|
|
|
|
|
caseTypeOptions: JSON.parse(sessionStorage.getItem('case_type')),
|
|
|
|
|
typeOptions: JSON.parse(sessionStorage.getItem('prompt_type'))
|
|
|
|
|
typeOptions: JSON.parse(sessionStorage.getItem('prompt_type')),
|
|
|
|
|
// 提示词模版
|
|
|
|
|
promptTextList: JSON.parse(sessionStorage.getItem('prompt_prototype_default_text'))
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
mounted() {
|
|
|
|
|
this.getTreeList()
|
|
|
|
|
this.queryChunkClassify()
|
|
|
|
|
|
|
|
|
|
this.selectType('1')
|
|
|
|
|
if (this.$route.params.id) {
|
|
|
|
|
this.getDetails()
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
// 获取分类下拉
|
|
|
|
|
queryChunkClassify() {
|
|
|
|
|
getChunkClassify().then(res => {
|
|
|
|
|
this.typeData = res.data
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
// 获取详情
|
|
|
|
|
getDetails() {
|
|
|
|
|
queryPromptDetails({
|
|
|
|
|
id: this.$route.params.id
|
|
|
|
|
}).then(res => {
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
this.dataInfo = res.data
|
|
|
|
|
this.entityOptions.data = res.data.tripleList || []
|
|
|
|
|
this.data.rules = '(问[::](.*?))\s*答[::](.*?)(?=(问[::]|$))'
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
selectType(val) {
|
|
|
|
|
this.$set(this.dataInfo, 'prompt', null)
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
const text = this.getPromptText(val)
|
|
|
|
|
this.$set(this.dataInfo, 'prompt', text || ' ')
|
|
|
|
|
console.log('text', this.dataInfo)
|
|
|
|
|
})
|
|
|
|
|
if (val === '2') {
|
|
|
|
|
this.entityOptions.data = [
|
|
|
|
|
{
|
|
|
|
|
type: '头节点',
|
|
|
|
|
templateName: 'headEntityType',
|
|
|
|
|
value: ''
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: '关系',
|
|
|
|
|
templateName: 'relation',
|
|
|
|
|
value: ''
|
|
|
|
|
}, {
|
|
|
|
|
type: '尾节点',
|
|
|
|
|
templateName: 'tailEntityType',
|
|
|
|
|
value: ''
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
getPromptText(val) {
|
|
|
|
|
for (const item of this.promptTextList) {
|
|
|
|
|
if (item.value === val) {
|
|
|
|
|
return item.label
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
// 获取输入框返回的文本
|
|
|
|
|
handleChangeInputText(val) {
|
|
|
|
|
this.customInputText = val
|
|
|
|
|
console.log('111', val)
|
|
|
|
|
},
|
|
|
|
|
// 获取输入框返回的文本
|
|
|
|
|
handleChangeChosen(val) {
|
|
|
|
|
this.customInputMentions = val
|
|
|
|
|
}, handleDebug() {
|
|
|
|
|
this.$refs.PromptDebugRef.show()
|
|
|
|
|
},
|
|
|
|
|
handleDebug() {
|
|
|
|
|
if (this.dataInfo.type === '3') {
|
|
|
|
|
this.$baseMessage.error('分类不能调试!')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
this.$refs.form.validate(valid => {
|
|
|
|
|
if (valid) {
|
|
|
|
|
this.$refs.PromptDebugRef.show(this.dataInfo, this.entityOptions.data)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
openSelectImg() {
|
|
|
|
|
this.$refs.SelectImgRef.show()
|
|
|
|
@ -209,6 +287,11 @@ export default {
|
|
|
|
|
getCaseEvidenceTree({ caseType: 1 }).then(res => {
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
this.treeData = res.data
|
|
|
|
|
for (let i = this.treeData.length - 1; i >= 0; i--) {
|
|
|
|
|
if (!this.treeData[i].child) {
|
|
|
|
|
this.treeData.splice(i, 1)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
@ -222,19 +305,37 @@ export default {
|
|
|
|
|
this.dataInfo.extractAttributes.splice(index, 1)
|
|
|
|
|
},
|
|
|
|
|
reset() {
|
|
|
|
|
|
|
|
|
|
this.dataInfo = {
|
|
|
|
|
rules: '(问[::](.*?))\s*答[::](.*?)(?=(问[::]|$))',
|
|
|
|
|
caseType: '',
|
|
|
|
|
type: '1',
|
|
|
|
|
name: '',
|
|
|
|
|
evidenceCategoryIdList: [],
|
|
|
|
|
typeList: [],
|
|
|
|
|
extractAttributes: [],
|
|
|
|
|
prompt: ''
|
|
|
|
|
}
|
|
|
|
|
this.selectType('1')
|
|
|
|
|
},
|
|
|
|
|
submit() {
|
|
|
|
|
this.$refs.form.validate(valid => {
|
|
|
|
|
if (valid) {
|
|
|
|
|
const params = {
|
|
|
|
|
id: this.id,
|
|
|
|
|
id: this.$route.params.id,
|
|
|
|
|
...this.dataInfo,
|
|
|
|
|
evidenceCategoryId: this.dataInfo.evidenceCategoryList[this.dataInfo.evidenceCategoryList.length - 1 ]
|
|
|
|
|
evidenceCategoryId: this.dataInfo.evidenceCategoryIdList[this.dataInfo.evidenceCategoryIdList.length - 1 ]
|
|
|
|
|
}
|
|
|
|
|
if (params.type === '2') {
|
|
|
|
|
params.tripleList = this.entityOptions.data
|
|
|
|
|
}
|
|
|
|
|
addOrUpdPrompt(params).then(res => {
|
|
|
|
|
const { code, msg } = res
|
|
|
|
|
code === 200 ? (this.id ? this.$baseMessage.success(msg || '编辑成功!') : this.$baseMessage.success(msg || '新增成功!')) : (this.id ? this.$baseMessage.error(msg || '编辑失败!') : this.$baseMessage.error(msg || '新增失败!'))
|
|
|
|
|
this.$store.dispatch(
|
|
|
|
|
'tabsBar/delRoute',
|
|
|
|
|
this.$route
|
|
|
|
|
)
|
|
|
|
|
this.$router.push({ path: '/prompt-config' })
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
@ -300,6 +401,10 @@ export default {
|
|
|
|
|
color: #888888;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
.params-table-content {
|
|
|
|
|
max-height: calc(100vh - 800px);
|
|
|
|
|
overflow-y: auto;
|
|
|
|
|
}
|
|
|
|
|
.add-table {
|
|
|
|
|
height: 56px;
|
|
|
|
|
display: flex;
|
|
|
|
@ -374,7 +479,7 @@ export default {
|
|
|
|
|
}
|
|
|
|
|
.content {
|
|
|
|
|
border-radius: 6px 6px 6px 6px;
|
|
|
|
|
border: 1px solid #D9D9D9;
|
|
|
|
|
// border: 1px solid #D9D9D9;
|
|
|
|
|
margin-top: 14px;
|
|
|
|
|
flex: 1;
|
|
|
|
|
// padding: 16px;
|
|
|
|
|