From 1a0a2f9a6730f974dfec6ab1f587481c89e4f0d7 Mon Sep 17 00:00:00 2001 From: lyc Date: Wed, 20 Nov 2024 15:23:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/src/api/mode/index.js | 52 ++++++++++++++--- .../template-study/container/edit-dialog.vue | 9 ++- .../template-study/container/header.vue | 6 +- .../container/keyword-dialog.vue | 24 +++++--- .../template-study/container/result.vue | 57 +++++++++++++++---- 5 files changed, 115 insertions(+), 33 deletions(-) diff --git a/src/renderer/src/api/mode/index.js b/src/renderer/src/api/mode/index.js index 5af6b1a..3f2288a 100644 --- a/src/renderer/src/api/mode/index.js +++ b/src/renderer/src/api/mode/index.js @@ -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', + }) +} \ No newline at end of file diff --git a/src/renderer/src/components/template-study/container/edit-dialog.vue b/src/renderer/src/components/template-study/container/edit-dialog.vue index f8b8172..fa7ff5d 100644 --- a/src/renderer/src/components/template-study/container/edit-dialog.vue +++ b/src/renderer/src/components/template-study/container/edit-dialog.vue @@ -28,6 +28,7 @@ diff --git a/src/renderer/src/components/template-study/container/header.vue b/src/renderer/src/components/template-study/container/header.vue index 2747619..94af579 100644 --- a/src/renderer/src/components/template-study/container/header.vue +++ b/src/renderer/src/components/template-study/container/header.vue @@ -10,7 +10,7 @@ {{ curTemplate.name }} - + @@ -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) diff --git a/src/renderer/src/components/template-study/container/keyword-dialog.vue b/src/renderer/src/components/template-study/container/keyword-dialog.vue index 7ecd927..01330b6 100644 --- a/src/renderer/src/components/template-study/container/keyword-dialog.vue +++ b/src/renderer/src/components/template-study/container/keyword-dialog.vue @@ -2,17 +2,18 @@
+

*当前模板为系统预设,不支持直接操作。会复制一份为自己的然后再操作

- + @@ -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; +} \ No newline at end of file diff --git a/src/renderer/src/components/template-study/container/result.vue b/src/renderer/src/components/template-study/container/result.vue index a685aae..d12aae1 100644 --- a/src/renderer/src/components/template-study/container/result.vue +++ b/src/renderer/src/components/template-study/container/result.vue @@ -53,9 +53,9 @@ - + - +
@@ -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({