This commit is contained in:
lyc 2024-11-20 15:23:42 +08:00
parent c803ecd796
commit 1a0a2f9a67
5 changed files with 115 additions and 33 deletions

View File

@ -2,14 +2,6 @@ import request from '@/utils/request'
import axios from 'axios' import axios from 'axios'
let rootPath = import.meta.env.VITE_APP_ENV === 'production' ? 'https://ai.ysaix.com:7864' : '' 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) { export function conversation(data) {
return axios({ return axios({
@ -71,3 +63,47 @@ export function removeChildTemp(id) {
method: 'delete' 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',
})
}

View File

@ -28,6 +28,7 @@
<script setup> <script setup>
import { ref, watch} from 'vue' import { ref, watch} from 'vue'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
import { editTempResult } from '@/api/mode/index.js'
const textarea = ref('') const textarea = ref('')
@ -50,9 +51,11 @@ watch(() => props.item.answer, (newVal) => {
const emit = defineEmits(['saveEdit']) const emit = defineEmits(['saveEdit'])
const onSave = () =>{ const onSave = () =>{
emit('saveEdit', textarea.value) editTempResult({id: props.item.reultId, content: textarea.value}).then( res =>{
isDialog.value = false isDialog.value = false
ElMessage.success('操作成功') ElMessage.success('操作成功')
emit('saveEdit', textarea.value)
})
} }
</script> </script>

View File

@ -10,7 +10,7 @@
<el-dropdown @command="changeTemplate" :hide-on-click="false"> <el-dropdown @command="changeTemplate" :hide-on-click="false">
<span class="el-dropdown-link"> <span class="el-dropdown-link">
{{ curTemplate.name }} {{ curTemplate.name }}
<i class="iconfont icon-xiangxia" </i> <i class="iconfont icon-xiangxia"></i>
</span> </span>
<template #dropdown> <template #dropdown>
<el-dropdown-menu> <el-dropdown-menu>
@ -32,7 +32,7 @@
</div> </div>
</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" /> <Dialog v-model="showDialog" :modeType="type" />
</template> </template>
@ -70,7 +70,7 @@ const curTemplate = reactive({ name: '', id: '' })
const templateList = ref([]) const templateList = ref([])
// //
const getTemplateList = () => { const getTemplateList = () => {
modelList({ model: props.type, type: 1, ex3: 1 }).then(res => { modelList({ model: props.type, type: 1 }).then(res => {
templateList.value = res.rows templateList.value = res.rows
Object.assign(curTemplate, res.rows[0]); Object.assign(curTemplate, res.rows[0]);
emit('changeTemp', res.rows[0].id) emit('changeTemp', res.rows[0].id)

View File

@ -2,17 +2,18 @@
<el-dialog v-model="mode" :show-close="false" width="600" destroy-on-close> <el-dialog v-model="mode" :show-close="false" width="600" destroy-on-close>
<template #header> <template #header>
<div class="custom-header flex"> <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> <i class="iconfont icon-guanbi" @click="mode = false"></i>
</div> </div>
</template> </template>
<div class="dialog-content" v-loading="loading"> <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 :model="form" label-width="auto">
<el-form-item label="名称"> <el-form-item label="名称">
<el-input v-model="form.name" /> <el-input v-model="form.name" />
</el-form-item> </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-input v-model="form.prompt" type="textarea" />
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -60,9 +61,8 @@ const form = reactive({
}) })
watch(() => props.isAdd, (newVal) => { watch(() => props.isAdd, (newVal) => {
console.log(newVal)
if (!newVal) { if (!newVal) {
console.log(newVal, 'isEditKeyWord');
form.name = props.item?.name form.name = props.item?.name
form.prompt = props.item?.prompt form.prompt = props.item?.prompt
} }
@ -76,8 +76,8 @@ const saveAdd = async () => {
try { try {
var msg = null var msg = null
// //
if (props.temp.ex3 == '1') { if (props.item.ex3 == '1') {
var { msg } = await addKeyWords({ name: form.name, id: props.temp.id }) var { msg } = await addKeyWords({ name: form.name, id: props.item.id })
} }
else { else {
// //
@ -85,12 +85,12 @@ const saveAdd = async () => {
name: form.name, name: form.name,
type: 2, // 2 type: 2, // 2
sortNum: 1, sortNum: 1,
parentId: props.temp.id, parentId: props.item.id,
lmType: 1, lmType: 1,
model: props.modeType, model: props.modeType,
prompt: form.prompt, prompt: form.prompt,
ex1: props.temp.ex1, // ex1: props.item.ex1, //
ex2: props.temp.ex2, // ex2: props.item.ex2, //
ex3: '', // ex3: '', //
} }
var { msg } = await addChildTemp(obj) var { msg } = await addChildTemp(obj)
@ -128,4 +128,10 @@ const saveAdd = async () => {
font-weight: bold; font-weight: bold;
} }
} }
.small-tip{
text-align: left;
font-size: 12px;
margin-bottom: 15px;
color: #F56C6C;
}
</style> </style>

View File

@ -53,9 +53,9 @@
<!--编辑结果--> <!--编辑结果-->
<EditDialog v-model="isEdit" :item="editItem" @saveEdit="saveEdit" /> <EditDialog v-model="isEdit" :item="editItem" @saveEdit="saveEdit" />
<!--AI 对话调整--> <!--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> </div>
</template> </template>
@ -67,7 +67,7 @@ import AdjustDialog from './adjust-dialog.vue'
import keywordDialog from './keyword-dialog.vue'; import keywordDialog from './keyword-dialog.vue';
import { sessionStore } from '@/utils/store' import { sessionStore } from '@/utils/store'
import useUserStore from '@/store/modules/user' 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' import { dataSetJson } from '@/utils/comm.js'
const userStore = useUserStore() const userStore = useUserStore()
@ -90,16 +90,35 @@ const getChildTemplate = () => {
tempLoading.value = true tempLoading.value = true
modelList({ model: props.modeType, type: 2, parentId: props.tempId }).then(res => { modelList({ model: props.modeType, type: 2, parentId: props.tempId }).then(res => {
childTempList.value = res.rows childTempList.value = res.rows
getTempResult()
}).finally(() => { }).finally(() => {
tempLoading.value = false 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) const isEdit = ref(false)
watch(() => props.tempId, (newVal) => { watch(() => props.tempId, (newVal) => {
if (newVal) { if (newVal) {
// isEdit.value = true // isEdit.value = true
getChildTemplate() getChildTemplate()
} }
}) })
@ -122,24 +141,38 @@ const getCompletion = async () => {
for (let item of childTempList.value) { for (let item of childTempList.value) {
try { try {
item.loading = true item.loading = true
params.prompt = `根据${curNode.edustage}语文课标,提炼出${item.name}` params.prompt = `根据${curNode.edustage}${curNode.edusubject}课标,提炼出${item.name}`
const { data } = await completion(params) const { data } = await completion(params)
let answer = data.answer let answer = data.answer
item.oldAnswer = answer item.oldAnswer = answer
item.answer = getResult(answer); item.answer = getResult(answer);
onSaveTemp(item)
} finally { } finally {
item.loading = false 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) => { const againResult = async (index, item) => {
try { try {
childTempList.value[index].loading = true childTempList.value[index].loading = true
params.prompt = `根据${curNode.edustage}语文课标,提炼出${item.name}` params.prompt = `根据${curNode.edustage}${curNode.edusubject}课标,提炼出${item.name}`
const { data } = await completion(params) const { data } = await completion(params)
let answer = data.answer let answer = data.answer
childTempList.value[index].oldAnswer = answer childTempList.value[index].oldAnswer = answer
@ -170,9 +203,10 @@ const onEdit = (index, item) => {
// //
const saveEdit = (data) => { const saveEdit = (data) => {
childTempList.value[curIndex.value].oldAnswer = data // childTempList.value[curIndex.value].oldAnswer = data
let answer = getResult(data); // let answer = getResult(data);
childTempList.value[curIndex.value].answer = answer // childTempList.value[curIndex.value].answer = answer
getChildTemplate()
} }
const isAdjust = ref(false) const isAdjust = ref(false)
@ -191,6 +225,8 @@ const saveAdjust = (item) => {
const keywordItem = reactive({}) const keywordItem = reactive({})
const isEditKeyWord = ref(false) const isEditKeyWord = ref(false)
const editKeyWord = (item) =>{ const editKeyWord = (item) =>{
console.log(item)
isEditKeyWord.value = true isEditKeyWord.value = true
Object.assign(keywordItem, item) Object.assign(keywordItem, item)
} }
@ -210,6 +246,7 @@ onMounted(() => {
let jsonKey = `${text}-${data.edustage}-${data.edusubject}` let jsonKey = `${text}-${data.edustage}-${data.edusubject}`
params.dataset_id = dataSetJson[jsonKey] params.dataset_id = dataSetJson[jsonKey]
}) })
defineExpose({ defineExpose({