lyc-dev #45
|
@ -2,14 +2,6 @@ import request from '@/utils/request'
|
|||
import axios from 'axios'
|
||||
|
||||
let rootPath = import.meta.env.VITE_APP_ENV === 'production' ? 'https://ai.ysaix.com:7864' : ''
|
||||
// 查询模板列表
|
||||
export function modelList(params) {
|
||||
return request({
|
||||
url: '/education/llmModel/list',
|
||||
method: 'get',
|
||||
params
|
||||
})
|
||||
}
|
||||
|
||||
export function conversation(data) {
|
||||
return axios({
|
||||
|
@ -71,3 +63,47 @@ export function removeChildTemp(id) {
|
|||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
// 查询模板列表
|
||||
export function modelList(params) {
|
||||
return request({
|
||||
url: '/education/llmModel/list',
|
||||
method: 'get',
|
||||
params
|
||||
})
|
||||
}
|
||||
|
||||
// 保存模板 结果
|
||||
export function tempSave(data) {
|
||||
return request({
|
||||
url: '/education/result',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改模板结果
|
||||
export function editTempResult(data) {
|
||||
return request({
|
||||
url: '/education/result',
|
||||
method: 'put',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 查询模板结果
|
||||
export function tempResult(params) {
|
||||
return request({
|
||||
url: '/education/result/list',
|
||||
method: 'get',
|
||||
params
|
||||
})
|
||||
}
|
||||
|
||||
// 删除模板结果
|
||||
export function tempResultRemove(id) {
|
||||
return request({
|
||||
url: `/education/result/${id}`,
|
||||
method: 'get',
|
||||
})
|
||||
}
|
|
@ -28,6 +28,7 @@
|
|||
<script setup>
|
||||
import { ref, watch} from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { editTempResult } from '@/api/mode/index.js'
|
||||
|
||||
const textarea = ref('')
|
||||
|
||||
|
@ -50,9 +51,11 @@ watch(() => props.item.answer, (newVal) => {
|
|||
|
||||
const emit = defineEmits(['saveEdit'])
|
||||
const onSave = () =>{
|
||||
emit('saveEdit', textarea.value)
|
||||
isDialog.value = false
|
||||
ElMessage.success('操作成功')
|
||||
editTempResult({id: props.item.reultId, content: textarea.value}).then( res =>{
|
||||
isDialog.value = false
|
||||
ElMessage.success('操作成功')
|
||||
emit('saveEdit', textarea.value)
|
||||
})
|
||||
}
|
||||
|
||||
</script>
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<el-dropdown @command="changeTemplate" :hide-on-click="false">
|
||||
<span class="el-dropdown-link">
|
||||
{{ curTemplate.name }}
|
||||
<i class="iconfont icon-xiangxia" </i>
|
||||
<i class="iconfont icon-xiangxia"></i>
|
||||
</span>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
|
@ -32,7 +32,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<!--添加提示词-->
|
||||
<keywordDialog v-model="wordDialog" :modeType="type" :isAdd="wordDialog" :temp="curTemplate"/>
|
||||
<keywordDialog v-model="wordDialog" :modeType="type" :isAdd="wordDialog" :item="curTemplate"/>
|
||||
<Dialog v-model="showDialog" :modeType="type" />
|
||||
</template>
|
||||
|
||||
|
@ -70,7 +70,7 @@ const curTemplate = reactive({ name: '', id: '' })
|
|||
const templateList = ref([])
|
||||
// 获取模板列表
|
||||
const getTemplateList = () => {
|
||||
modelList({ model: props.type, type: 1, ex3: 1 }).then(res => {
|
||||
modelList({ model: props.type, type: 1 }).then(res => {
|
||||
templateList.value = res.rows
|
||||
Object.assign(curTemplate, res.rows[0]);
|
||||
emit('changeTemp', res.rows[0].id)
|
||||
|
|
|
@ -2,17 +2,18 @@
|
|||
<el-dialog v-model="mode" :show-close="false" width="600" destroy-on-close>
|
||||
<template #header>
|
||||
<div class="custom-header flex">
|
||||
<span>{{ isAdd ? temp && temp.ex3 == '1' ? '请输入新的模板名称' : '添加提示词' : '编辑提示词' }}</span>
|
||||
<span>{{ isAdd ? item && item.ex3 == '1' ? '请输入新的模板名称' : '添加提示词' : '编辑提示词' }}</span>
|
||||
<i class="iconfont icon-guanbi" @click="mode = false"></i>
|
||||
</div>
|
||||
</template>
|
||||
<div class="dialog-content" v-loading="loading">
|
||||
<p class="small-tip" v-if="item && item.ex3 == '1'">*当前模板为系统预设,不支持直接操作。会复制一份为自己的然后再操作</p>
|
||||
<el-form :model="form" label-width="auto">
|
||||
<el-form-item label="名称">
|
||||
<el-input v-model="form.name" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="提示词" v-if="isAdd ? !(temp && temp.ex3 == '1') : true">
|
||||
<el-form-item label="提示词" v-if="isAdd ? !(item && item.ex3 == '1') : true">
|
||||
<el-input v-model="form.prompt" type="textarea" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
@ -60,9 +61,8 @@ const form = reactive({
|
|||
})
|
||||
|
||||
watch(() => props.isAdd, (newVal) => {
|
||||
console.log(newVal)
|
||||
if (!newVal) {
|
||||
console.log(newVal, 'isEditKeyWord');
|
||||
|
||||
form.name = props.item?.name
|
||||
form.prompt = props.item?.prompt
|
||||
}
|
||||
|
@ -76,8 +76,8 @@ const saveAdd = async () => {
|
|||
try {
|
||||
var msg = null
|
||||
// 为主模板预设
|
||||
if (props.temp.ex3 == '1') {
|
||||
var { msg } = await addKeyWords({ name: form.name, id: props.temp.id })
|
||||
if (props.item.ex3 == '1') {
|
||||
var { msg } = await addKeyWords({ name: form.name, id: props.item.id })
|
||||
}
|
||||
else {
|
||||
// 添加子模板
|
||||
|
@ -85,12 +85,12 @@ const saveAdd = async () => {
|
|||
name: form.name,
|
||||
type: 2, // 子模板 固定值为2
|
||||
sortNum: 1,
|
||||
parentId: props.temp.id,
|
||||
parentId: props.item.id,
|
||||
lmType: 1,
|
||||
model: props.modeType,
|
||||
prompt: form.prompt,
|
||||
ex1: props.temp.ex1, //学段
|
||||
ex2: props.temp.ex2, // 学科
|
||||
ex1: props.item.ex1, //学段
|
||||
ex2: props.item.ex2, // 学科
|
||||
ex3: '', //是否系统预设 这里默认空
|
||||
}
|
||||
var { msg } = await addChildTemp(obj)
|
||||
|
@ -128,4 +128,10 @@ const saveAdd = async () => {
|
|||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
.small-tip{
|
||||
text-align: left;
|
||||
font-size: 12px;
|
||||
margin-bottom: 15px;
|
||||
color: #F56C6C;
|
||||
}
|
||||
</style>
|
|
@ -53,9 +53,9 @@
|
|||
<!--编辑结果-->
|
||||
<EditDialog v-model="isEdit" :item="editItem" @saveEdit="saveEdit" />
|
||||
<!--AI 对话调整-->
|
||||
<AdjustDialog v-model="isAdjust" :item="editItem" @saveAdjust="saveAdjust" />
|
||||
<AdjustDialog v-model="isAdjust" :modeType="modeType" :item="editItem" @saveAdjust="saveAdjust" />
|
||||
<!--编辑提示词-->
|
||||
<keywordDialog v-model="isEditKeyWord" :isAdd="isEdit" :item="keywordItem"/>
|
||||
<keywordDialog v-model="isEditKeyWord" :isAdd="!isEditKeyWord" :item="keywordItem"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
@ -67,7 +67,7 @@ import AdjustDialog from './adjust-dialog.vue'
|
|||
import keywordDialog from './keyword-dialog.vue';
|
||||
import { sessionStore } from '@/utils/store'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
import { conversation, completion, modelList, removeChildTemp } from '@/api/mode/index'
|
||||
import { tempSave, completion, modelList, removeChildTemp, tempResult } from '@/api/mode/index'
|
||||
import { dataSetJson } from '@/utils/comm.js'
|
||||
|
||||
const userStore = useUserStore()
|
||||
|
@ -90,16 +90,35 @@ const getChildTemplate = () => {
|
|||
tempLoading.value = true
|
||||
modelList({ model: props.modeType, type: 2, parentId: props.tempId }).then(res => {
|
||||
childTempList.value = res.rows
|
||||
|
||||
getTempResult()
|
||||
}).finally(() => {
|
||||
tempLoading.value = false
|
||||
})
|
||||
}
|
||||
// 查询模板结果
|
||||
const getTempResult = () =>{
|
||||
tempResult({mainModelId: props.tempId}).then(res =>{
|
||||
console.log(res,1000)
|
||||
let rows = res.rows
|
||||
childTempList.value.forEach(item =>{
|
||||
rows.forEach(el =>{
|
||||
if(item.id == el.modelId){
|
||||
item.answer = el.content
|
||||
item.reultId = el.id
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
const isEdit = ref(false)
|
||||
watch(() => props.tempId, (newVal) => {
|
||||
if (newVal) {
|
||||
// isEdit.value = true
|
||||
getChildTemplate()
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -122,24 +141,38 @@ const getCompletion = async () => {
|
|||
for (let item of childTempList.value) {
|
||||
try {
|
||||
item.loading = true
|
||||
params.prompt = `根据${curNode.edustage}语文课标,提炼出${item.name}`
|
||||
params.prompt = `根据${curNode.edustage}${curNode.edusubject}课标,提炼出${item.name}`
|
||||
const { data } = await completion(params)
|
||||
let answer = data.answer
|
||||
item.oldAnswer = answer
|
||||
item.answer = getResult(answer);
|
||||
|
||||
onSaveTemp(item)
|
||||
} finally {
|
||||
item.loading = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 保存模板
|
||||
const onSaveTemp = (item) =>{
|
||||
const data = {
|
||||
mainModelId: props.tempId,
|
||||
modelId: item.id,
|
||||
examDocld: '',
|
||||
content: item.oldAnswer
|
||||
}
|
||||
tempSave(data).then(res =>{
|
||||
console.log(res)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 重新研读
|
||||
const againResult = async (index, item) => {
|
||||
try {
|
||||
childTempList.value[index].loading = true
|
||||
params.prompt = `根据${curNode.edustage}语文课标,提炼出${item.name}`
|
||||
params.prompt = `根据${curNode.edustage}${curNode.edusubject}课标,提炼出${item.name}`
|
||||
const { data } = await completion(params)
|
||||
let answer = data.answer
|
||||
childTempList.value[index].oldAnswer = answer
|
||||
|
@ -170,9 +203,10 @@ const onEdit = (index, item) => {
|
|||
|
||||
// 保存编辑
|
||||
const saveEdit = (data) => {
|
||||
childTempList.value[curIndex.value].oldAnswer = data
|
||||
let answer = getResult(data);
|
||||
childTempList.value[curIndex.value].answer = answer
|
||||
// childTempList.value[curIndex.value].oldAnswer = data
|
||||
// let answer = getResult(data);
|
||||
// childTempList.value[curIndex.value].answer = answer
|
||||
getChildTemplate()
|
||||
}
|
||||
|
||||
const isAdjust = ref(false)
|
||||
|
@ -191,6 +225,8 @@ const saveAdjust = (item) => {
|
|||
const keywordItem = reactive({})
|
||||
const isEditKeyWord = ref(false)
|
||||
const editKeyWord = (item) =>{
|
||||
console.log(item)
|
||||
|
||||
isEditKeyWord.value = true
|
||||
Object.assign(keywordItem, item)
|
||||
}
|
||||
|
@ -210,6 +246,7 @@ onMounted(() => {
|
|||
let jsonKey = `${text}-${data.edustage}-${data.edusubject}`
|
||||
params.dataset_id = dataSetJson[jsonKey]
|
||||
|
||||
|
||||
})
|
||||
|
||||
defineExpose({
|
||||
|
|
Loading…
Reference in New Issue