Merge branch 'main' of http://27.128.240.72:3000/zhuhao/AIx_Smarttalk_WS into zdg_dev
This commit is contained in:
commit
6fa0aa6e5f
|
@ -10,11 +10,10 @@ export const createChart = ({ headers, data }) => {
|
|||
})
|
||||
}
|
||||
// 大模型对话
|
||||
export const sendChart = ({ headers, data }) => {
|
||||
export const sendChart = (data) => {
|
||||
return request({
|
||||
url: '/qf/sendTalk',
|
||||
method: 'post',
|
||||
headers,
|
||||
data,
|
||||
})
|
||||
}
|
|
@ -30,7 +30,7 @@
|
|||
</div>
|
||||
</el-scrollbar>
|
||||
<div class="file-list">
|
||||
<el-dropdown @command="changeFile">
|
||||
<el-dropdown @command="changeFile" v-if="type == 3">
|
||||
<span class="el-dropdown-link">
|
||||
{{ curFile.fileName }}
|
||||
<i class="iconfont icon-xiangxia"></i>
|
||||
|
@ -54,7 +54,7 @@
|
|||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted, onUnmounted, watch } from 'vue'
|
||||
import { ref, reactive, onMounted, onUnmounted } from 'vue'
|
||||
import { completion, docList } from '@/api/mode/index'
|
||||
import { sessionStore } from '@/utils/store'
|
||||
import { dataSetJson } from '@/utils/comm.js'
|
||||
|
@ -71,7 +71,7 @@ const props = defineProps({
|
|||
item: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
return { name: '11' }
|
||||
return { name: '' }
|
||||
}
|
||||
},
|
||||
type: {
|
||||
|
@ -125,19 +125,6 @@ const saveAdjust = (item) =>{
|
|||
emitter.emit('onSaveAdjust', item.msg)
|
||||
}
|
||||
|
||||
const modeType = ref('课标')
|
||||
watch(() => props.type, (newVal) => {
|
||||
if (newVal == 1){
|
||||
modeType.value = '课标'
|
||||
}
|
||||
if (newVal == 2){
|
||||
modeType.value = '教材'
|
||||
}
|
||||
if (newVal == 2){
|
||||
modeType.value = '考试'
|
||||
}
|
||||
|
||||
}, { immediate: false })
|
||||
|
||||
const curFile = reactive({})
|
||||
const dataset_id = ref('')
|
||||
|
@ -160,11 +147,12 @@ const changeFile = (val) =>{
|
|||
params.document_ids = val.docId
|
||||
}
|
||||
|
||||
|
||||
const modeType = ref('')
|
||||
onMounted(() => {
|
||||
let data = sessionStore.get('subject.curNode')
|
||||
|
||||
Object.assign(curNode, data);
|
||||
|
||||
modeType.value = props.type == 1 ? '课标' : props.type == 2 ? '教材' : '考试'
|
||||
let jsonKey = `${modeType.value}-${data.edustage}-${data.edusubject}`
|
||||
params.dataset_id = dataSetJson[jsonKey]
|
||||
if(props.type == 3){
|
||||
|
|
|
@ -14,7 +14,10 @@
|
|||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
<div>
|
||||
<div class="flex">
|
||||
<el-select v-model="curMode" placeholder="Select" class="mr-4 w-30">
|
||||
<el-option v-for="item in modeOptions" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
<el-button type="danger" link :disabled="!(templateList.length)" @click="removeItem(curTemplate, false)">
|
||||
删除
|
||||
</el-button>
|
||||
|
@ -52,7 +55,8 @@
|
|||
<i class="iconfont icon-ai"></i>
|
||||
</div>
|
||||
<div class="item-answer">
|
||||
<TypingEffect v-if="isStarted[index]" :text="item.answer" :delay="10" :aiShow="item.aiShow" @complete="handleCompleteText($event,index)" @updateScroll="scrollToBottom($event,index)" />
|
||||
<TypingEffect v-if="isStarted[index]" :text="item.answer" :delay="10" :aiShow="item.aiShow"
|
||||
@complete="handleCompleteText($event, index)" @updateScroll="scrollToBottom($event, index)" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="ai-btn" v-if="item.answer">
|
||||
|
@ -86,6 +90,7 @@
|
|||
import { ref, reactive, onMounted, onUnmounted, nextTick } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { tempSave, completion, modelList, removeChildTemp, tempResult, editTempResult } from '@/api/mode/index'
|
||||
import { createChart, sendChart } from '@/api/ai/index'
|
||||
import { sessionStore } from '@/utils/store'
|
||||
import keywordDialog from './keyword-dialog.vue';
|
||||
import AdjustDialog from './adjust-dialog.vue'
|
||||
|
@ -94,10 +99,23 @@ import TypingEffect from '@/components/typing-effect/index.vue'
|
|||
import useUserStore from '@/store/modules/user'
|
||||
import emitter from '@/utils/mitt';
|
||||
import { dataSetJson } from '@/utils/comm.js'
|
||||
import { cloneDeep } from 'lodash'
|
||||
|
||||
const props = defineProps(['type'])
|
||||
const { user } = useUserStore()
|
||||
|
||||
const curMode = ref(1)
|
||||
const modeOptions = ref([
|
||||
{
|
||||
label: '教学大模型',
|
||||
value: 1
|
||||
},
|
||||
{
|
||||
label: '知识库模型',
|
||||
value: 2
|
||||
}
|
||||
])
|
||||
|
||||
/*****************提示词相关****************/
|
||||
|
||||
/**
|
||||
|
@ -252,7 +270,6 @@ const removeItem = async (item, isChild) => {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// Ai对话调整
|
||||
const curIndex = ref(-1)
|
||||
const isAdjust = ref(false)
|
||||
|
@ -277,6 +294,7 @@ const params = reactive(
|
|||
dataset_id: ''
|
||||
}
|
||||
)
|
||||
const prompt = ref('')
|
||||
|
||||
// 重新研读
|
||||
const isAgain = ref(false)
|
||||
|
@ -296,8 +314,28 @@ const againResult = async (index, item) => {
|
|||
await nextTick()
|
||||
childTempList.value[index].loading = true
|
||||
item.aiShow = true
|
||||
params.prompt = `按照${item.prompt}的要求,针对${curNode.edustage}${curNode.edusubject}${modeType.value} 对${curNode.itemtitle}进行教学分析`
|
||||
const { data } = await completion(params)
|
||||
|
||||
let str = cloneDeep(prompt.value)
|
||||
str = str.replace('{模板标题}',item.name)
|
||||
str = str.replace('{模板内容}',item.prompt)
|
||||
params.prompt = str
|
||||
params.template = item.prompt
|
||||
|
||||
let data = null;
|
||||
// 教学大模型
|
||||
if (mode.value == 1) {
|
||||
const res = await sendChart({
|
||||
content: params.prompt,
|
||||
conversationId: conversation_id.value,
|
||||
stream: false
|
||||
})
|
||||
data = res.data
|
||||
} else {
|
||||
// 知识库模型
|
||||
const res = await completion(params)
|
||||
data = res.data
|
||||
}
|
||||
|
||||
childTempList.value[index].answer = getResult(data.answer);
|
||||
isStarted.value[index] = true
|
||||
|
||||
|
@ -305,6 +343,7 @@ const againResult = async (index, item) => {
|
|||
childTempList.value[index].loading = false
|
||||
}
|
||||
}
|
||||
|
||||
// 一键研读
|
||||
const getCompletion = async () => {
|
||||
isStarted.value = new Array(childTempList.length).fill(false)
|
||||
|
@ -320,8 +359,27 @@ const getCompletion = async () => {
|
|||
try {
|
||||
item.loading = true
|
||||
item.aiShow = true
|
||||
params.prompt = `按照${item.prompt}的要求,针对${curNode.edustage}${curNode.edusubject}${modeType.value} 对${curNode.itemtitle}进行教学分析`
|
||||
const { data } = await completion(params)
|
||||
let str = cloneDeep(prompt.value)
|
||||
str = str.replace('{模板标题}',item.name)
|
||||
str = str.replace('{模板内容}',item.prompt)
|
||||
params.prompt = str
|
||||
params.template = item.prompt
|
||||
// 教学大模型
|
||||
let data = null
|
||||
if (curMode.value == 1) {
|
||||
const res = await sendChart({
|
||||
content: params.prompt,
|
||||
conversationId: conversation_id.value,
|
||||
stream: false
|
||||
})
|
||||
data = res.data
|
||||
}
|
||||
// 知识库模型
|
||||
else {
|
||||
const res = await completion(params)
|
||||
data = res.data
|
||||
}
|
||||
|
||||
item.answer = getResult(data.answer)
|
||||
onSaveTemp(item)
|
||||
} finally {
|
||||
|
@ -386,6 +444,30 @@ emitter.on('onGetMain', () => {
|
|||
})
|
||||
|
||||
|
||||
// 创建对话
|
||||
const conversation_id = ref('')
|
||||
const getChartId = () => {
|
||||
createChart({ app_id: '712ff0df-ed6b-470f-bf87-8cfbaf757be5' }).then(res => {
|
||||
localStorage.setItem("conversation_id", res.data.conversation_id);
|
||||
conversation_id.value = res.data.conversation_id;
|
||||
})
|
||||
}
|
||||
|
||||
// 查询prompt 替换
|
||||
const getPrompt = async () => {
|
||||
const { rows } = await modelList({ model: 5 })
|
||||
let str = rows.find(item => item.name.indexOf(modeType.value) != -1).prompt
|
||||
str = str.replace('{学段}', curNode.edustage)
|
||||
str = str.replace('{学科}', curNode.edusubject)
|
||||
let bookV = curNode.roottitle.split('-')[1] + '版本'
|
||||
str = str.replace('{教材版本}', bookV)
|
||||
str = str.replace('{课程名称}', `《${curNode.itemtitle}》`)
|
||||
if(modeType.value == '课标'){
|
||||
str = str.replace('{课标名称}', `${curNode.edustage}${curNode.edusubject}课标`)
|
||||
}
|
||||
prompt.value = str
|
||||
}
|
||||
|
||||
const curNode = reactive({})
|
||||
const modeType = ref('')
|
||||
onMounted(() => {
|
||||
|
@ -396,6 +478,15 @@ onMounted(() => {
|
|||
getTemplateList()
|
||||
let jsonKey = `${modeType.value}-${data.edustage}-${data.edusubject}`
|
||||
params.dataset_id = dataSetJson[jsonKey]
|
||||
// 获取百度千帆会话ID
|
||||
conversation_id.value = localStorage.getItem('conversation_id')
|
||||
if (!conversation_id.value) {
|
||||
getChartId();
|
||||
}
|
||||
|
||||
// 获取prompt
|
||||
getPrompt()
|
||||
|
||||
})
|
||||
|
||||
// 解绑
|
||||
|
|
|
@ -83,7 +83,7 @@ export const constantRoutes = [
|
|||
path: 'questionUpload',
|
||||
component: () => import('@/views/classTask/newClassTaskAssign/questionUpload/index.vue'),
|
||||
name: 'questionUpload',
|
||||
meta: { title: '习题上传' }
|
||||
meta: { title: '习题上传', showBread: true }
|
||||
},
|
||||
{
|
||||
path: 'aiKolors',
|
||||
|
|
|
@ -5,6 +5,7 @@ import { JYApiListCT, JYApiListOriginYear, JYApiListSO} from "@/utils/examQuesti
|
|||
|
||||
const useClassTaskStore = defineStore('classTask',{
|
||||
state: () => ({
|
||||
isOpenQuestUploadView: false, // 是否打开习题上传的页面
|
||||
classListIds: [],
|
||||
entpCourseWorkTypeList: [
|
||||
{value: 0, label: "不限"},
|
||||
|
|
|
@ -149,10 +149,14 @@ import { useGetHomework } from '@/hooks/useGetHomework'
|
|||
import { sessionStore } from '@/utils/store'
|
||||
import { useRouter, useRoute } from 'vue-router'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
import useClassTaskStore from '@/store/modules/classTask'
|
||||
|
||||
const userStore = useUserStore().user
|
||||
const route = useRoute();
|
||||
const router = useRouter()
|
||||
const { proxy } = getCurrentInstance()
|
||||
const useClassTaskStores = useClassTaskStore();
|
||||
|
||||
const props = defineProps({
|
||||
currentCourse: Object,
|
||||
})
|
||||
|
@ -189,6 +193,7 @@ const boardLoading = ref(false);
|
|||
const fileLoading = ref(false); // 常规作业loading
|
||||
|
||||
onMounted(() => {
|
||||
console.log("----onMounted-------")
|
||||
currentRow.value = {id:0};
|
||||
if(propsQueryCourseObj){
|
||||
if(JSON.parse(propsQueryCourseObj)){
|
||||
|
@ -216,7 +221,28 @@ onMounted(() => {
|
|||
}
|
||||
}
|
||||
initHomeWork();
|
||||
isInToMyQuestion(); // 如果是上传习题后返回的,跳转到个人题库
|
||||
})
|
||||
// 是否进入个人题库
|
||||
const isInToMyQuestion = () => {
|
||||
console.log('isOpenQuestUploadView',useClassTaskStores.isOpenQuestUploadView);
|
||||
if(useClassTaskStores.isOpenQuestUploadView){
|
||||
useClassTaskStores.isOpenQuestUploadView = false;
|
||||
|
||||
currentRow.value = {id:1}; // 作业设计
|
||||
activeAptTab.value = "个人题库";
|
||||
//提交内容清空 重置
|
||||
classWorkForm.id = 0;
|
||||
classWorkForm.uniquekey = ""; // 作业唯一标识 作业名称
|
||||
classWorkForm.worktype = "习题训练"; //作业类型
|
||||
classWorkForm.title = ""; // 作业说明
|
||||
classWorkForm.quizlist = []; // 作业习题列表内容
|
||||
classWorkForm.chooseWorkLists = []; // 作业框架梳理list
|
||||
classWorkForm.fileHomeworkList = []; // 常规作业文件列表
|
||||
classWorkForm.whiteboardObj = ""; // 作业资源 - 课堂展示 白板
|
||||
classWorkForm.question = ""; // 作业资源 - 课堂展示 输入的问题
|
||||
}
|
||||
}
|
||||
watch(() => props.currentCourse, (newVal, oldVal) => {
|
||||
if(newVal){
|
||||
courseObj.textbookId = newVal.textbookId // 版本
|
||||
|
|
|
@ -74,7 +74,7 @@
|
|||
<script setup>
|
||||
import "vue-cropper/dist/index.css";
|
||||
import { VueCropper } from "vue-cropper";
|
||||
import { onMounted, ref,watch, reactive, getCurrentInstance,nextTick } from 'vue'
|
||||
import { onMounted, ref,watch, reactive, getCurrentInstance,nextTick, onUnmounted } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { cloneDeep } from 'lodash'
|
||||
|
||||
|
@ -88,6 +88,8 @@ import { useRouter, useRoute } from 'vue-router'
|
|||
|
||||
import { ocrImg2ExamByManualUpl, ocrImg2ItemByManualUpl } from "@/views/classTask/newClassTaskAssign/questionUpload/ocrImg2ExamQues";
|
||||
import QuesItem from "@/views/classTask/newClassTaskAssign/questionUpload/quesItem/index.vue";
|
||||
import useClassTaskStore from '@/store/modules/classTask'
|
||||
|
||||
|
||||
// const Remote = require('@electron/remote')
|
||||
// const fs = require('fs');
|
||||
|
@ -96,7 +98,9 @@ import useUserStore from '@/store/modules/user'
|
|||
const userStore = useUserStore().user
|
||||
const route = useRoute();
|
||||
const router = useRouter()
|
||||
const { proxy } = getCurrentInstance()
|
||||
const { proxy } = getCurrentInstance();
|
||||
const useClassTaskStores = useClassTaskStore();
|
||||
|
||||
const props = defineProps({
|
||||
})
|
||||
|
||||
|
@ -151,6 +155,7 @@ const cropOption = reactive({
|
|||
|
||||
|
||||
onMounted(() => {
|
||||
useClassTaskStores.isOpenQuestUploadView = true; // 打开过习题上传界面
|
||||
console.log('propsQueryCourseObj', JSON.parse(propsQueryCourseObj));
|
||||
if(propsQueryCourseObj&&JSON.parse(propsQueryCourseObj)){
|
||||
courseObj.textbookId = JSON.parse(propsQueryCourseObj).bookObj // 版本
|
||||
|
@ -161,7 +166,13 @@ onMounted(() => {
|
|||
}
|
||||
initHomeWork();
|
||||
})
|
||||
|
||||
onUnmounted(()=>{
|
||||
// 延迟1s 关闭习题上传界面,作业管理界面需要根据 isOpenQuestUploadView 来进行判断
|
||||
setTimeout(()=>{
|
||||
useClassTaskStores.isOpenQuestUploadView = false; // 关闭习题上传界面
|
||||
console.log('onUnmounted 习题上传');
|
||||
}, 1000)
|
||||
})
|
||||
|
||||
/**
|
||||
* 获取 entpcourseid 获取作业列表
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { ElMessageBox, ElMessage } from "element-plus";
|
||||
import qs from "qs";
|
||||
import axios from 'axios'
|
||||
import request from '@/utils/request'
|
||||
import { pyOCRAPI } from "@/api/education/entpcoursework";
|
||||
|
||||
|
||||
|
@ -16,6 +17,13 @@ const baidubceConfig = {
|
|||
'client_secret': 'oWb0M0YWMmZPMQIhIUkJX99ddr7h61qf',
|
||||
};
|
||||
|
||||
export function getOcrContent(data) {
|
||||
return request({
|
||||
url: '/ocr/exam',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -226,30 +234,36 @@ const ocrImg2Json = async (urlBase64) => {
|
|||
ElMessage.error("未检测到截图图片, 请截取图片后再识别");
|
||||
return null;
|
||||
}
|
||||
const resToken = await bdyAPI_getToken();
|
||||
if (resToken.status !== 200) {
|
||||
ElMessage.error("百度智能云用户标识有误");
|
||||
return null;
|
||||
}
|
||||
|
||||
const token = resToken.data?.access_token;
|
||||
let base64Code = urlBase64.split(",")[1];
|
||||
const query = {
|
||||
image: base64Code, //图片地址(base64)
|
||||
line_probability: false, //是否返回每行识别结果的置信度。默认为false
|
||||
disp_line_poly: false, //是否返回每行的四角点坐标。默认为false
|
||||
words_type: 'handprint_mix', //文字类型。 默认:印刷文字识别 = handwring_only:手写文字识别 = handprint_mix: 手写印刷混排识别
|
||||
layout_analysis: false, //是否分析文档版面:包括layout(图、表、标题、段落、目录);attribute(栏、页眉、页脚、页码、脚注)的分析输出
|
||||
recg_long_division: false, //是否检测并识别手写竖式
|
||||
recg_formula: true, //控制是否检测并识别公式,默认为false
|
||||
}
|
||||
|
||||
|
||||
const resOcr = await bdyAPI_getOcrContent(token, base64Code, query);
|
||||
if (resOcr.status !== 200) {
|
||||
ElMessage.error("百度智能云图片识别错误");
|
||||
const resOcr = await getOcrContent({ base64Code: base64Code });
|
||||
if (resOcr.code !== 200) {
|
||||
ElMessage.error("图片识别错误");
|
||||
return null;
|
||||
}
|
||||
// const resToken = await bdyAPI_getToken();
|
||||
// if (resToken.status !== 200) {
|
||||
// ElMessage.error("百度智能云用户标识有误");
|
||||
// return null;
|
||||
// }
|
||||
|
||||
// const token = resToken.data?.access_token;
|
||||
// let base64Code = urlBase64.split(",")[1];
|
||||
// const query = {
|
||||
// image: base64Code, //图片地址(base64)
|
||||
// line_probability: false, //是否返回每行识别结果的置信度。默认为false
|
||||
// disp_line_poly: false, //是否返回每行的四角点坐标。默认为false
|
||||
// words_type: 'handprint_mix', //文字类型。 默认:印刷文字识别 = handwring_only:手写文字识别 = handprint_mix: 手写印刷混排识别
|
||||
// layout_analysis: false, //是否分析文档版面:包括layout(图、表、标题、段落、目录);attribute(栏、页眉、页脚、页码、脚注)的分析输出
|
||||
// recg_long_division: false, //是否检测并识别手写竖式
|
||||
// recg_formula: true, //控制是否检测并识别公式,默认为false
|
||||
// }
|
||||
|
||||
|
||||
// const resOcr = await bdyAPI_getOcrContent(token, base64Code, query);
|
||||
// if (resOcr.status !== 200) {
|
||||
// ElMessage.error("百度智能云图片识别错误");
|
||||
// return null;
|
||||
// }
|
||||
|
||||
return resOcr;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,9 @@
|
|||
</el-button>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<el-select v-model="curMode" placeholder="Select" class="mr-4 w-30">
|
||||
<el-option v-for="item in modeOptions" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
<el-button type="primary" :disabled="!(resultList.length)" @click="getCompletion">一键研读</el-button>
|
||||
<el-button type="primary">生成大纲</el-button>
|
||||
<el-button type="danger" @click="pptDialog = true">生成PPT</el-button>
|
||||
|
@ -35,7 +38,8 @@
|
|||
<div class="item-prompt">{{ item.prompt }}</div>
|
||||
<div class="item-answer" v-if="item.answer">
|
||||
<div class="answer-text">
|
||||
<TypingEffect v-if="isStarted[index]" :text="item.answer" :delay="10" :aiShow="item.aiShow" @complete="handleCompleteText($event,index)" @updateScroll="scrollToBottom($event,index)" />
|
||||
<TypingEffect v-if="isStarted[index]" :text="item.answer" :delay="10" :aiShow="item.aiShow"
|
||||
@complete="handleCompleteText($event, index)" @updateScroll="scrollToBottom($event, index)" />
|
||||
</div>
|
||||
<div class="item-btn flex">
|
||||
<el-button type="primary" link @click="againResult(index, item)">
|
||||
|
@ -73,12 +77,14 @@ import emitter from '@/utils/mitt'
|
|||
import EditDialog from './edit-dialog.vue'
|
||||
import AdjustDialog from './adjust-dialog.vue'
|
||||
import progressDialog from './progress-dialog.vue'
|
||||
import { completion, tempResult, tempSave, removeChildTemp, editTempResult } from '@/api/mode/index.js'
|
||||
import { completion, tempResult, tempSave, removeChildTemp, editTempResult, modelList } from '@/api/mode/index.js'
|
||||
import { createChart, sendChart } from '@/api/ai/index'
|
||||
// import { dataSetJson } from '@/utils/comm.js'
|
||||
import * as commUtils from '@/utils/comm.js'
|
||||
import PptDialog from '@/views/prepare/container/pptist-dialog.vue'
|
||||
import keywordDialog from './keyword-dialog.vue'
|
||||
import TypingEffect from '@/components/typing-effect/index.vue'
|
||||
import { cloneDeep } from 'lodash'
|
||||
|
||||
import useUserStore from '@/store/modules/user'
|
||||
import { PPTXFileToJson } from '@/AixPPTist/src/hooks/useImport' // ppt转json
|
||||
|
@ -110,6 +116,19 @@ const pgDialog = reactive({ // 弹窗-进度条
|
|||
]
|
||||
}
|
||||
})
|
||||
|
||||
const curMode = ref(1)
|
||||
const modeOptions = ref([
|
||||
{
|
||||
label: '教学大模型',
|
||||
value: 1
|
||||
},
|
||||
{
|
||||
label: '知识库模型',
|
||||
value: 2
|
||||
}
|
||||
])
|
||||
|
||||
emitter.on('changeMode', (item) => {
|
||||
resultList.value = item.child
|
||||
getTempResult(item.id)
|
||||
|
@ -131,8 +150,28 @@ const getCompletion = async () => {
|
|||
try {
|
||||
item.loading = true
|
||||
item.aiShow = true
|
||||
params.prompt = `按照${item.prompt}的要求,针对${curNode.edustage}${curNode.edusubject} 对${curNode.itemtitle}进行教学分析`
|
||||
const { data } = await completion(params)
|
||||
|
||||
let str = cloneDeep(prompt.value)
|
||||
str = str.replace(/{模板名称}/g, item.name)
|
||||
params.prompt = str
|
||||
params.template = item.prompt
|
||||
|
||||
// 教学大模型
|
||||
let data = null
|
||||
if (curMode.value == 1) {
|
||||
const res = await sendChart({
|
||||
content: params.prompt,
|
||||
conversationId: conversation_id.value,
|
||||
stream: false
|
||||
})
|
||||
data = res.data
|
||||
}
|
||||
// 知识库模型
|
||||
else {
|
||||
const res = await completion(params)
|
||||
data = res.data
|
||||
}
|
||||
|
||||
item.answer = getResult(data.answer)
|
||||
onSaveTemp(item)
|
||||
} finally {
|
||||
|
@ -265,9 +304,12 @@ let getResult = (str) => {
|
|||
const params = reactive(
|
||||
{
|
||||
prompt: '',
|
||||
dataset_id: ''
|
||||
dataset_id: '',
|
||||
template: ''
|
||||
}
|
||||
)
|
||||
const prompt = ref('')
|
||||
|
||||
|
||||
const addAiPPT = async (res) => {
|
||||
let node = courseObj.node
|
||||
|
@ -343,8 +385,27 @@ const againResult = async (index, item) => {
|
|||
await nextTick()
|
||||
resultList.value[index].loading = true
|
||||
item.aiShow = true
|
||||
params.prompt = `按照${item.prompt}的要求,针对${curNode.edustage}${curNode.edusubject}课标对${curNode.itemtitle}进行教学分析`
|
||||
const { data } = await completion(params)
|
||||
|
||||
let str = cloneDeep(prompt.value)
|
||||
str = str.replace(/{模板名称}/g, item.name)
|
||||
params.prompt = str
|
||||
params.template = item.prompt
|
||||
|
||||
let data = null;
|
||||
// 教学大模型
|
||||
if (mode.value == 1) {
|
||||
const res = await sendChart({
|
||||
content: params.prompt,
|
||||
conversationId: conversation_id.value,
|
||||
stream: false
|
||||
})
|
||||
data = res.data
|
||||
} else {
|
||||
// 知识库模型
|
||||
const res = await completion(params)
|
||||
data = res.data
|
||||
}
|
||||
|
||||
resultList.value[index].answer = getResult(data.answer)
|
||||
isStarted.value[index] = true
|
||||
} finally {
|
||||
|
@ -498,6 +559,27 @@ const toRousrceUrl = async(o) => {
|
|||
}
|
||||
// ======== zdg end ============
|
||||
|
||||
// 创建对话
|
||||
const conversation_id = ref('')
|
||||
const getChartId = () => {
|
||||
createChart({ app_id: '712ff0df-ed6b-470f-bf87-8cfbaf757be5' }).then(res => {
|
||||
localStorage.setItem("conversation_id", res.data.conversation_id);
|
||||
conversation_id.value = res.data.conversation_id;
|
||||
})
|
||||
}
|
||||
|
||||
// 查询prompt 替换
|
||||
const getPrompt = async () => {
|
||||
const { rows } = await modelList({ model: 5 })
|
||||
let str = rows.find(item => item.name.indexOf('框架设计') != -1).prompt
|
||||
str = str.replace('{学段}', curNode.edustage)
|
||||
str = str.replace('{学科}', curNode.edusubject)
|
||||
let bookV = curNode.roottitle.split('-')[1] + '版本'
|
||||
str = str.replace('{教材版本}', bookV)
|
||||
str = str.replace('{课程名称}', `《${curNode.itemtitle}》`)
|
||||
prompt.value = str
|
||||
}
|
||||
|
||||
const curNode = reactive({})
|
||||
onMounted(() => {
|
||||
let data = sessionStore.get('subject.curNode')
|
||||
|
@ -506,6 +588,15 @@ onMounted(() => {
|
|||
|
||||
let jsonKey = `课标-${data.edustage}-${data.edusubject}`
|
||||
params.dataset_id = commUtils.dataSetJson[jsonKey]
|
||||
|
||||
// 获取百度千帆会话ID
|
||||
conversation_id.value = localStorage.getItem('conversation_id')
|
||||
if (!conversation_id.value) {
|
||||
getChartId();
|
||||
}
|
||||
|
||||
// 获取prompt
|
||||
getPrompt()
|
||||
})
|
||||
|
||||
|
||||
|
@ -548,6 +639,7 @@ onUnmounted(() => {
|
|||
position: relative;
|
||||
padding-left: 15px;
|
||||
box-sizing: border-box;
|
||||
|
||||
&::after {
|
||||
content: '';
|
||||
width: 15px;
|
||||
|
@ -558,6 +650,7 @@ onUnmounted(() => {
|
|||
left: -8px;
|
||||
top: 5px;
|
||||
}
|
||||
|
||||
&::before {
|
||||
content: '';
|
||||
width: 2px;
|
||||
|
@ -567,16 +660,19 @@ onUnmounted(() => {
|
|||
left: -1px;
|
||||
top: 5px;
|
||||
}
|
||||
|
||||
&:last-child {
|
||||
&::before {
|
||||
content: '';
|
||||
width: 0
|
||||
}
|
||||
}
|
||||
|
||||
.item-top {
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 5px;
|
||||
|
||||
.icon-shenglvehao {
|
||||
font-weight: bold
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue