模板修改

This commit is contained in:
lyc 2024-12-18 17:31:10 +08:00
parent 627c70d0e1
commit 0ed69394ef
4 changed files with 91 additions and 21 deletions

View File

@ -59,6 +59,7 @@ import { completion, docList } from '@/api/mode/index'
import { sessionStore } from '@/utils/store' import { sessionStore } from '@/utils/store'
import { dataSetJson } from '@/utils/comm.js' import { dataSetJson } from '@/utils/comm.js'
import useUserStore from '@/store/modules/user' import useUserStore from '@/store/modules/user'
import { sendChart } from '@/api/ai/index'
import emitter from '@/utils/mitt'; import emitter from '@/utils/mitt';
const userInfo = useUserStore().user const userInfo = useUserStore().user
@ -77,6 +78,14 @@ const props = defineProps({
type: { type: {
type: Number, type: Number,
default: 1 default: 1
},
curMode:{
type: Number,
default: 1
},
conversation_id: {
type: [Number, String],
default: ''
} }
}) })
@ -100,7 +109,8 @@ const curNode = reactive({})
const params = reactive( const params = reactive(
{ {
prompt: '', prompt: '',
dataset_id: '' dataset_id: '',
template: ''
} }
) )
@ -108,7 +118,24 @@ const params = reactive(
const getCompletion = async (val) => { const getCompletion = async (val) => {
try { try {
params.prompt = `按照${val}的要求,针对${curNode.edustage}${curNode.edusubject}${modeType.value}${curNode.itemtitle}进行教学分析` params.prompt = `按照${val}的要求,针对${curNode.edustage}${curNode.edusubject}${modeType.value}${curNode.itemtitle}进行教学分析`
const { data } = await completion(params) params.template = props.item.prompt
let data = null;
//
if(props.curMode == 1){
const res = await sendChart({
content: params.prompt,
conversationId: props.conversation_id,
stream: false
})
data = res.data
}
else{
//
const res = await completion(params)
data = res.data
}
let answer = data.answer let answer = data.answer
msgList.value.push({ msgList.value.push({
type: 'robot', type: 'robot',

View File

@ -81,7 +81,7 @@
<!--编辑结果--> <!--编辑结果-->
<EditDialog v-model="isEdit" :item="editItem" /> <EditDialog v-model="isEdit" :item="editItem" />
<!--AI 对话调整--> <!--AI 对话调整-->
<AdjustDialog v-model="isAdjust" :type="type" :item="editItem" /> <AdjustDialog v-model="isAdjust" :type="type" :item="editItem" :curMode="curMode" :conversation_id="conversation_id"/>
<!--添加编辑提示词--> <!--添加编辑提示词-->
<keywordDialog v-model="isWordDialog" :item="editItem" /> <keywordDialog v-model="isWordDialog" :item="editItem" />
</template> </template>
@ -323,7 +323,7 @@ const againResult = async (index, item) => {
let data = null; let data = null;
// //
if (mode.value == 1) { if (curMode.value == 1) {
const res = await sendChart({ const res = await sendChart({
content: params.prompt, content: params.prompt,
conversationId: conversation_id.value, conversationId: conversation_id.value,

View File

@ -42,9 +42,10 @@
<script setup> <script setup>
import { ref, reactive, onMounted } from 'vue' import { ref, reactive, onMounted } from 'vue'
import { completion } from '@/api/mode/index' import { completion } from '@/api/mode/index'
import { dataSetJson } from '@/utils/comm.js'
import emitter from '@/utils/mitt'; import emitter from '@/utils/mitt';
import { sessionStore } from '@/utils/store' import { sessionStore } from '@/utils/store'
import { ElMessage } from 'element-plus' import { sendChart } from '@/api/ai/index'
const textarea = ref('') const textarea = ref('')
@ -56,6 +57,14 @@ const props = defineProps({
default: () => { default: () => {
return { name: '11' } return { name: '11' }
} }
},
curMode:{
type: Number,
default: 1
},
conversation_id: {
type: [Number, String],
default: ''
} }
}) })
@ -77,13 +86,36 @@ const send = () => {
} }
const curNode = reactive({}) const curNode = reactive({})
// ID const params = reactive(
{
prompt: '',
dataset_id: '',
template: ''
}
)
//
const getConversation = async (val) => { const getConversation = async (val) => {
try { try {
const { data } = await completion({ params.prompt = `按照${val}的要求,针对${curNode.edustage}${curNode.edusubject}课标,对${curNode.itemtitle}进行教学分析`
dataset_id: 'cee3062a9fcf11efa6910242ac140006', params.template = props.item.prompt
prompt: val
}) let data = null;
//
if(props.curMode == 1){
const res = await sendChart({
content: params.prompt,
conversationId: props.conversation_id,
stream: false
})
data = res.data
}
else{
//
const res = await completion(params)
data = res.data
}
msgList.value.push({ msgList.value.push({
type: 'robot', type: 'robot',
msg: data.answer, msg: data.answer,
@ -94,15 +126,16 @@ const getConversation = async (val) => {
} }
const saveAdjust = (item) => { const saveAdjust = (item) => {
// emit('saveAdjust', item.msg)
emitter.emit('changeAdjust', item.msg)
isDialog.value = false isDialog.value = false
ElMessage.success('操作成功') emitter.emit('onSaveAdjust', item.msg)
} }
onMounted(() => { onMounted(() => {
let data = sessionStore.get('subject.curNode') let data = sessionStore.get('subject.curNode')
Object.assign(curNode, data); Object.assign(curNode, data);
// dataset_id
let jsonKey = `课标-${data.edustage}-${data.edusubject}`
params.dataset_id = dataSetJson[jsonKey]
}) })

View File

@ -2,12 +2,12 @@
<div class="container-right flex"> <div class="container-right flex">
<div class="right-header flex"> <div class="right-header flex">
<div class="header-left"> <div class="header-left">
<el-button type="primary" link> <!-- <el-button type="primary" link>
<i class="iconfont icon-jiahao"></i>新活动 <i class="iconfont icon-jiahao"></i>新活动
</el-button> </el-button>
<el-button type="primary" link> <el-button type="primary" link>
<i class="iconfont icon-baocun"></i>保存为教学模式 <i class="iconfont icon-baocun"></i>保存为教学模式
</el-button> </el-button> -->
</div> </div>
<div class="header-right"> <div class="header-right">
<el-select v-model="curMode" placeholder="Select" class="mr-4 w-30"> <el-select v-model="curMode" placeholder="Select" class="mr-4 w-30">
@ -62,7 +62,7 @@
</div> </div>
</div> </div>
<EditDialog v-model="isEdit" :item="curItem" /> <EditDialog v-model="isEdit" :item="curItem" />
<AdjustDialog v-model="isAdjust" :item="curItem" /> <AdjustDialog v-model="isAdjust" :item="curItem" :curMode="curMode" :conversation_id="conversation_id" />
<PptDialog @add-success="addAiPPT" :dataList="resultList" v-model="pptDialog" /> <PptDialog @add-success="addAiPPT" :dataList="resultList" v-model="pptDialog" />
<progress-dialog v-model:visible="pgDialog.visible" v-bind="pgDialog" /> <progress-dialog v-model:visible="pgDialog.visible" v-bind="pgDialog" />
<!--添加编辑提示词--> <!--添加编辑提示词-->
@ -393,7 +393,7 @@ const againResult = async (index, item) => {
let data = null; let data = null;
// //
if (mode.value == 1) { if (curMode.value == 1) {
const res = await sendChart({ const res = await sendChart({
content: params.prompt, content: params.prompt,
conversationId: conversation_id.value, conversationId: conversation_id.value,
@ -421,11 +421,21 @@ const onAdjust = (index, item) => {
Object.assign(curItem, item) Object.assign(curItem, item)
isAdjust.value = true isAdjust.value = true
} }
emitter.on('changeAdjust', (item) => {
//
emitter.on('onSaveAdjust', (item) => {
resultList.value[curIndex.value].answer = item resultList.value[curIndex.value].answer = item
onEditSave(resultList.value[curIndex.value])
}) })
//
const onEditSave = async (item) => {
const { msg } = await editTempResult({ id: item.resultId, content: item.answer })
ElMessage.success(msg)
getChildTemplate()
}
// //
const onEdit = (index, item) => { const onEdit = (index, item) => {
curIndex.value = index curIndex.value = index
@ -585,7 +595,7 @@ onMounted(() => {
let data = sessionStore.get('subject.curNode') let data = sessionStore.get('subject.curNode')
Object.assign(curNode, data); Object.assign(curNode, data);
courseObj.node = data courseObj.node = data
// dataset_id
let jsonKey = `课标-${data.edustage}-${data.edusubject}` let jsonKey = `课标-${data.edustage}-${data.edusubject}`
params.dataset_id = commUtils.dataSetJson[jsonKey] params.dataset_id = commUtils.dataSetJson[jsonKey]
@ -605,7 +615,7 @@ onUnmounted(() => {
emitter.off('changeMode') emitter.off('changeMode')
emitter.off('changeResult') emitter.off('changeResult')
emitter.off('changeAdjust') emitter.off('changeAdjust')
emitter.off('onSaveAdjust');
}) })
@ -630,7 +640,7 @@ onUnmounted(() => {
background: #F6F6F6; background: #F6F6F6;
padding: 15px; padding: 15px;
flex-direction: column; flex-direction: column;
overflow-y: scroll; overflow-y: auto;
.con-item { .con-item {
width: 100%; width: 100%;