|
@@ -667,7 +667,9 @@
|
|
|
@click="openAiDialog(2, 'aiOutline')">生成大纲</button>
|
|
|
</el-tooltip>
|
|
|
<button class="c_pub_button_confirm" style="margin: 0 20px 0 auto;"
|
|
|
- @click="openAiDialog2(2, 'aiOutline')" v-if="panOutline() > 0">重新生成大纲</button>
|
|
|
+ @click="openAiDialog2(2, 'aiOutline')" v-if="panOutline() > 0 && templateid != '61c628b9-3d96-11ef-b873-005056b86db5'">重新生成大纲</button>
|
|
|
+ <button class="c_pub_button_confirm" style="margin: 0 20px 0 auto;"
|
|
|
+ @click="openAiDialog2(2, 'aiOutline2')" v-if="panOutline() > 0 && templateid == '61c628b9-3d96-11ef-b873-005056b86db5'">重新生成大纲</button>
|
|
|
<!-- <button class="c_pub_button_confirm" style="margin: 0 20px 0 auto;">AI优化</button> -->
|
|
|
</div>
|
|
|
<div class="task_outline">
|
|
@@ -679,14 +681,20 @@
|
|
|
</div>
|
|
|
<div class="outline_detail" v-loading="taskDetailLoading.indexOf('task-' + index) !== -1" element-loading-text="小可正在努力生成中,请稍等...">
|
|
|
<textarea v-autoHeight="100" rows="4" class="binfo_input binfo_textarea" cols
|
|
|
- placeholder="请输入任务描述" v-model="item.taskDetail2"></textarea>
|
|
|
+ placeholder="请输入任务描述" v-model="item.taskDetail2" v-if="item.isTask2"></textarea>
|
|
|
+ <div class="markBox vditor-reset" style="white-space:pre-wrap;" v-text="item.taskDetail2" v-else-if="ttaskDetailLoading.indexOf('task-' + index) !== -1"></div>
|
|
|
+ <div class="markBox vditor-reset" v-html="MarkdownT(item.taskDetail2)" v-else></div>
|
|
|
<div class="op_box">
|
|
|
<div class="op_remark">*可以将需要优化的建议添加在任务描述后,点击“智能优化”,自动进行修改</div>
|
|
|
- <el-tooltip effect="light" content="右键单击可配置提示词" placement="bottom">
|
|
|
- <div class="r_pub_button_op"
|
|
|
- @contextmenu.prevent="openAiDialog(1, 'aiDetail1', item, index)"
|
|
|
- @click="openAiDialog(2, 'aiDetail1', item, index)">智能优化</div>
|
|
|
- </el-tooltip>
|
|
|
+ <div style="display: flex;">
|
|
|
+ <el-tooltip effect="light" content="右键单击可配置提示词" placement="bottom">
|
|
|
+ <div class="r_pub_button_op"
|
|
|
+ @contextmenu.prevent="openAiDialog(1, 'aiDetail1', item, index)"
|
|
|
+ @click="openAiDialog(2, 'aiDetail1', item, index)">智能优化</div>
|
|
|
+ </el-tooltip>
|
|
|
+ <div class="r_pub_button_edit" style="margin-left:10px" @click="editTask2(index)">{{
|
|
|
+ item.isTask3 ? '确定' : '编辑'}}</div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -6884,7 +6892,7 @@ export default {
|
|
|
// if (this.cidType == 1) {
|
|
|
if (this.steps == 1) {
|
|
|
if (this.courseName != "") {
|
|
|
- if ((this.ttaskDetailLoading5.join(",").indexOf('task-') !== -1) || this.cpotetLoading.cpote1 || this.cpotetLoading.cpote2 || this.cpotetLoading.cpote3 || this.cpotetLoading.cpote4) {
|
|
|
+ if ((this.ttaskDetailLoading5.join(",").indexOf('task-') !== -1) || (this.ttaskDetailLoading.join(",").indexOf('task-') !== -1) || this.cpotetLoading.cpote1 || this.cpotetLoading.cpote2 || this.cpotetLoading.cpote3 || this.cpotetLoading.cpote4) {
|
|
|
this.$message({
|
|
|
message: "请回答完毕后再次发送",
|
|
|
type: "warning"
|
|
@@ -6893,7 +6901,11 @@ export default {
|
|
|
}
|
|
|
|
|
|
if (this.templateid != "4480d65a-1e48-11ef-bee5-005056b86db5" && !this.isOutline) {
|
|
|
- this.openAiDialog(clickType, 'aiOutline')
|
|
|
+ if(this.templateid == '61c628b9-3d96-11ef-b873-005056b86db5'){
|
|
|
+ this.openAiDialog(clickType, 'aiOutline2')
|
|
|
+ }else {
|
|
|
+ this.openAiDialog(clickType, 'aiOutline')
|
|
|
+ }
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -9660,6 +9672,10 @@ export default {
|
|
|
this.tipsJson = res.data[0][0]
|
|
|
this.aiJson = JSON.parse(res.data[0][0].tips)
|
|
|
this.aiJson.teacherDetail2 = this.aiJson.teacherDetail2 ? this.aiJson.teacherDetail2 : '请根据<任务名>、<任务描述>,<课程简要描述>,为该任务设计详细的教案,教案需要包含该任务的教学目标,教学过程(包含分步骤的教师活动和学生活动,教师活动与学生活动应该一一对应),相关知识点的讲解,练习(练习需要包含示例答案)。'
|
|
|
+ if(this.templateid == '61c628b9-3d96-11ef-b873-005056b86db5'){
|
|
|
+ this.aiJson.aiOutlineTask = this.aiJson.aiOutlineTask ? this.aiJson.aiOutlineTask : '请根据<课程名字>以及该课程的<课程简要描述>来为该课程生成100字以内的序列课程任务,序列任务要求彼此连结紧密且没有重复。'
|
|
|
+ this.aiJson.aiOutlineDetail = this.aiJson.aiOutlineDetail ? this.aiJson.aiOutlineDetail : '参考<课程名字>、<任务名>和<课程简要描述>的内容,为该序列生成任务详情。任务详情中需要包含教学目标,任务设计和评价标准。'
|
|
|
+ }
|
|
|
this.$forceUpdate();
|
|
|
}
|
|
|
})
|
|
@@ -11634,8 +11650,8 @@ export default {
|
|
|
}
|
|
|
if(res.data[0][0].setting){
|
|
|
try {
|
|
|
- this.courseJie = JSON.parse(res.data[0][0].setting).courseJie;
|
|
|
- this.courseTime = JSON.parse(res.data[0][0].setting).courseTime;
|
|
|
+ this.courseJie = JSON.parse(res.data[0][0].setting).courseJie ? JSON.parse(res.data[0][0].setting).courseJie : 1;
|
|
|
+ this.courseTime = JSON.parse(res.data[0][0].setting).courseTime ? JSON.parse(res.data[0][0].setting).courseTime : 45;
|
|
|
}catch(error){
|
|
|
console.error(error)
|
|
|
}
|
|
@@ -13618,6 +13634,14 @@ export default {
|
|
|
}
|
|
|
this.$forceUpdate();
|
|
|
},
|
|
|
+ editTask2(index){
|
|
|
+ if(this.unitJson[0].chapterInfo[0].taskJson[index].isTask2){
|
|
|
+ this.unitJson[0].chapterInfo[0].taskJson[index].isTask2 = false
|
|
|
+ }else {
|
|
|
+ this.unitJson[0].chapterInfo[0].taskJson[index].isTask2 = true
|
|
|
+ }
|
|
|
+ this.$forceUpdate();
|
|
|
+ },
|
|
|
editCpote(index){
|
|
|
if(this.cpote[index]){
|
|
|
this.cpote[index] = false
|
|
@@ -13691,6 +13715,10 @@ export default {
|
|
|
this.aitype = "aiOutline"
|
|
|
// this.aiText = `请根据${this.courseText}设计一个名为${this.courseName}的${sub.length ? sub.join(",") + "学科的" : ""},面向${this.getListClassC(this.checkboxList2)}的项目式学习课程设计序列教学活动(需要每个任务都需要至少50个token的详细描述),每个教学活动的活动设计(可以直接使用文件内容)以及每个教学活动的评价量规(学生能做到...)。`
|
|
|
this.aiText = this.aiJson.aiOutline
|
|
|
+ } else if (type == "aiOutline2") {
|
|
|
+ this.aitype = "aiOutline2"
|
|
|
+ // this.aiText = `请根据${this.courseText}设计一个名为${this.courseName}的${sub.length ? sub.join(",") + "学科的" : ""},面向${this.getListClassC(this.checkboxList2)}的项目式学习课程设计序列教学活动(需要每个任务都需要至少50个token的详细描述),每个教学活动的活动设计(可以直接使用文件内容)以及每个教学活动的评价量规(学生能做到...)。`
|
|
|
+ this.aiText = this.aiJson.aiOutlineTask
|
|
|
} else if (type == "aiTask") {
|
|
|
this.aitype = "aiTask"
|
|
|
var _text = ""
|
|
@@ -13893,6 +13921,33 @@ ${this.templatePan.includes(this.templateid) ? '课程时长:'+this.courseTime
|
|
|
this.loading = false
|
|
|
this.isOutline = true
|
|
|
})
|
|
|
+ } else if (this.aitype == "aiOutline2") {
|
|
|
+ this.loading = true
|
|
|
+ let message = `NOTICE
|
|
|
+Role: 你是创建课程的老师,可以利用file_search的方式完整的去分析文件内容(注:如果文件内容里面不包含需要检索的内容,就不引用文件内容),并生成需要的JSON数据。
|
|
|
+Language: Please use the same language as the user requirement, if the user speaks Chinese, the specific text of your answer should also be in Chinese.
|
|
|
+ATTENTION: Use '##' to SPLIT SECTIONS, not '#'. Output format carefully referenced "Format example".
|
|
|
+Instruction: Based on the context, follow "Format example", write content.
|
|
|
+
|
|
|
+# Context
|
|
|
+## 要求
|
|
|
+${msg} 以及##参考资料
|
|
|
+
|
|
|
+## 参考资料
|
|
|
+课程名字:${this.courseName}
|
|
|
+${this.courseText ? '课程简要描述:' + this.courseText : ''}
|
|
|
+${sub.length ? '学科:' + sub.join(",") : ''}
|
|
|
+${mclass.length ? '面向年级:' + mclass.join(",") : ''}
|
|
|
+${this.templatePan.includes(this.templateid) ? '课程节数:'+this.courseJie+'节' : ''}
|
|
|
+${this.templatePan.includes(this.templateid) ? '课程时长:'+this.courseTime+'min' : ''}
|
|
|
+
|
|
|
+# Format example
|
|
|
+[{"task": "任务1的名字"}, {"task": "任务2的名字"}, {"task": "任务2的名字"}, {"task": "任务n的名字"}]`
|
|
|
+
|
|
|
+ this.aiGetTask2(message, () => {
|
|
|
+ this.loading = false
|
|
|
+ this.isOutline = true
|
|
|
+ })
|
|
|
} else if (this.aitype == "aiTask") {
|
|
|
var _text = ""
|
|
|
for (var i = 0; i < this.unitJson[0].chapterInfo[0].taskJson.length; i++) {
|
|
@@ -14423,6 +14478,268 @@ ${this.courseText && this.aiCallback == 2 ? '注意,优化原有的<参考内
|
|
|
console.log(error);
|
|
|
});
|
|
|
},
|
|
|
+ async aiGetTask2(messages, callback) {
|
|
|
+ let _this = this
|
|
|
+
|
|
|
+ let fileid = _this.isFileSearch ? [..._this.fileIds] : []
|
|
|
+ if (_this.infoData.length) {
|
|
|
+ for (var i = 0; i < _this.infoData.length; i++) {
|
|
|
+ if(_this.infoData[i].fileid){
|
|
|
+ fileid.push(_this.infoData[i].fileid)
|
|
|
+ }else {
|
|
|
+ let _fileid = await _this.createFileid(_this.infoData[i].url)
|
|
|
+ if(_fileid){
|
|
|
+ _this.infoData[i].fileid = _fileid
|
|
|
+ _this.$forceUpdate();
|
|
|
+ fileid.push(_fileid)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ console.log('fileid=========',fileid)
|
|
|
+ // let params = JSON.stringify({
|
|
|
+ // // "model": "Chat",
|
|
|
+ // model: 'gpt-3.5-turbo',
|
|
|
+ // temperature: 0,
|
|
|
+ // max_tokens: 4096,
|
|
|
+ // top_p: 1,
|
|
|
+ // frequency_penalty: 0,
|
|
|
+ // presence_penalty: 0,
|
|
|
+ // messages: [{
|
|
|
+ // content: messages,
|
|
|
+ // role: 'user'
|
|
|
+ // }],
|
|
|
+ // stream: false,
|
|
|
+ // uid: this.userid,
|
|
|
+ // mind_map_question: "",
|
|
|
+ // })
|
|
|
+ // // let params = JSON.stringify({
|
|
|
+ // // message: {
|
|
|
+ // // anthropic_version: "bedrock-2023-05-31",
|
|
|
+ // // max_tokens: 4096,
|
|
|
+ // // temperature: 0,
|
|
|
+ // // top_p: 1,
|
|
|
+ // // messages: [{
|
|
|
+ // // content: messages,
|
|
|
+ // // role: 'user'
|
|
|
+ // // }], //
|
|
|
+ // // },
|
|
|
+ // // model: "Claude 3 Sonnet" // Claude 3 Sonnet或者Claude 3 Haiku
|
|
|
+ // // });
|
|
|
+
|
|
|
+ // _this.ajax.post('https://gpt4.cocorobo.cn/chat', params).then(function (response) {
|
|
|
+ // // _this.ajax.post('https://claude3.cocorobo.cn/claude3Chat', params).then(function (response) {
|
|
|
+ // console.log(response);
|
|
|
+ // let data = response.data.FunctionResponse
|
|
|
+ // if (data.choices && data.choices.length && data.choices[0].message) {
|
|
|
+ // console.log(data.choices[0].message.content);
|
|
|
+ // let dArray = JSON.parse(data.choices[0].message.content)
|
|
|
+ // _this.dArray = dArray
|
|
|
+ // _this.unitJson[0].chapterInfo[0].taskJson = []
|
|
|
+
|
|
|
+ // for (var i = 0; i < dArray.length; i++) {
|
|
|
+ // let _task = dArray[i]
|
|
|
+ // _this.unitJson[0].chapterInfo[0].taskJson.push({
|
|
|
+ // task: _task.task,
|
|
|
+ // taskDetail: "",
|
|
|
+ // taskDetail2: _task.detail,
|
|
|
+ // taskDetail3: "",
|
|
|
+ // chapterData: [],
|
|
|
+ // toolText: "",
|
|
|
+ // toolChoose: [
|
|
|
+ // {
|
|
|
+ // tool: [],
|
|
|
+ // toolDetail: "",
|
|
|
+ // toolType: 0,
|
|
|
+ // askCount: 1,
|
|
|
+ // askTitle: "",
|
|
|
+ // askJson: [{ askstitle: "", askItem: 1, checkList: [] }],
|
|
|
+ // },
|
|
|
+ // ],
|
|
|
+ // isShowTools: false,
|
|
|
+ // askCount: 1,
|
|
|
+ // isFold: 2,
|
|
|
+ // askTitle: "",
|
|
|
+ // askJson: [{ askstitle: "", askItem: 1, checkList: [] }],
|
|
|
+ // checkJson: [{ checkCount: [], checkPerent: [] }],
|
|
|
+ // homeworkList: [],
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ // _this.unitJson[0].chapterInfo[0].taskJson[0].chapterData = _this.infoData
|
|
|
+ // _this.unitJson2 = JSON.parse(JSON.stringify(_this.unitJson))
|
|
|
+ // _this.$forceUpdate();
|
|
|
+ // }
|
|
|
+ // // if (data.result) {
|
|
|
+ // // console.log(data.result);
|
|
|
+ // // let dArray = JSON.parse(data.result)
|
|
|
+ // // _this.dArray = dArray
|
|
|
+ // // _this.unitJson[0].chapterInfo[0].taskJson = []
|
|
|
+
|
|
|
+ // // for (var i = 0; i < dArray.length; i++) {
|
|
|
+ // // let _task = dArray[i]
|
|
|
+ // // _this.unitJson[0].chapterInfo[0].taskJson.push({
|
|
|
+ // // task: _task.task,
|
|
|
+ // // taskDetail: "",
|
|
|
+ // // taskDetail2: _task.detail,
|
|
|
+ // // taskDetail3: "",
|
|
|
+ // // chapterData: [],
|
|
|
+ // // toolText: "",
|
|
|
+ // // toolChoose: [
|
|
|
+ // // {
|
|
|
+ // // tool: [],
|
|
|
+ // // toolDetail: "",
|
|
|
+ // // toolType: 0,
|
|
|
+ // // askCount: 1,
|
|
|
+ // // askTitle: "",
|
|
|
+ // // askJson: [{ askstitle: "", askItem: 1, checkList: [] }],
|
|
|
+ // // },
|
|
|
+ // // ],
|
|
|
+ // // isShowTools: false,
|
|
|
+ // // askCount: 1,
|
|
|
+ // // isFold: 1,
|
|
|
+ // // askTitle: "",
|
|
|
+ // // askJson: [{ askstitle: "", askItem: 1, checkList: [] }],
|
|
|
+ // // checkJson: [{ checkCount: [], checkPerent: [] }],
|
|
|
+ // // homeworkList: [],
|
|
|
+ // // })
|
|
|
+ // // }
|
|
|
+ // // _this.unitJson2 = JSON.parse(JSON.stringify(_this.unitJson))
|
|
|
+ // // _this.$forceUpdate();
|
|
|
+ // // }
|
|
|
+ // callback ? callback() : ''
|
|
|
+ // }).catch(function (error) {
|
|
|
+ // _this.loading = false
|
|
|
+ // console.log(error);
|
|
|
+ // });
|
|
|
+
|
|
|
+ let parm = {
|
|
|
+ assistant_id: '6063369f-289a-11ef-8bf4-12e77c4cb76b',
|
|
|
+ message: [{"type":"text", "text":messages}],
|
|
|
+ session_name: uuidv4(),
|
|
|
+ userId: this.userid,
|
|
|
+ file_ids: fileid.length ? [...fileid] : '',
|
|
|
+ }
|
|
|
+ this.ajax
|
|
|
+ .post("https://gpt4.cocorobo.cn/ai_agent_park_chat", parm)
|
|
|
+ .then((response) => {
|
|
|
+ console.log(response);
|
|
|
+ let data = response.data.FunctionResponse
|
|
|
+ if (data.message) {
|
|
|
+ console.log(data.message);
|
|
|
+ let dArray = {}
|
|
|
+ try {
|
|
|
+ dArray = JSON.parse(data.message.replaceAll('```json','').replaceAll('```',''))
|
|
|
+ } catch (error) {
|
|
|
+ console.log("error_________________" + error);
|
|
|
+ try {
|
|
|
+ let regex = new RegExp("(?<=```json)([\\s\\S]*?)(?=```)");
|
|
|
+ let match = data.message.match(regex);
|
|
|
+ dArray = JSON.parse(match[0]);
|
|
|
+
|
|
|
+
|
|
|
+ // var message = data.message;
|
|
|
+ // var jsonStart = message.indexOf("```json") + 7; // `+ 7` 是为了跳过 ```json
|
|
|
+ // var jsonEnd = message.indexOf("```", jsonStart);
|
|
|
+ // var jsonString = message.substring(jsonStart, jsonEnd).trim();
|
|
|
+ // dArray = JSON.parse(jsonString);
|
|
|
+ } catch (error) {
|
|
|
+ console.log("error_________________" + error);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ _this.dArray = dArray
|
|
|
+
|
|
|
+ if(_this.panOutline() > 0){
|
|
|
+ for(var i = 0; i < _this.unitJson[0].chapterInfo[0].taskJson.length; i++){
|
|
|
+ _this.unitJson[0].chapterInfo[0].taskJson[i].task = ""
|
|
|
+ _this.unitJson[0].chapterInfo[0].taskJson[i].taskDetail2 = ""
|
|
|
+ }
|
|
|
+ for (var i = 0; i < dArray.length; i++) {
|
|
|
+ let _task = dArray[i]
|
|
|
+ if(_this.unitJson[0].chapterInfo[0].taskJson[i]){
|
|
|
+ _this.unitJson[0].chapterInfo[0].taskJson[i].task = _task.task
|
|
|
+ // _this.unitJson[0].chapterInfo[0].taskJson[i].taskDetail2 = _task.detail
|
|
|
+ }else {
|
|
|
+ _this.unitJson[0].chapterInfo[0].taskJson.push({
|
|
|
+ task: _task.task,
|
|
|
+ taskDetail: "",
|
|
|
+ taskDetail2: "",
|
|
|
+ taskDetail3: "",
|
|
|
+ chapterData: [],
|
|
|
+ toolText: "",
|
|
|
+ toolChoose: [
|
|
|
+ {
|
|
|
+ tool: [],
|
|
|
+ toolDetail: "",
|
|
|
+ toolType: 0,
|
|
|
+ askCount: 1,
|
|
|
+ askTitle: "",
|
|
|
+ askJson: [{ askstitle: "", askItem: 1, checkList: [] }],
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ isShowTools: false,
|
|
|
+ askCount: 1,
|
|
|
+ isFold: 2,
|
|
|
+ askTitle: "",
|
|
|
+ askJson: [{ askstitle: "", askItem: 1, checkList: [] }],
|
|
|
+ checkJson: [{ checkCount: [], checkPerent: [] }],
|
|
|
+ homeworkList: [],
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ _this.unitJson[0].chapterInfo[0].taskJson = []
|
|
|
+
|
|
|
+ for (var i = 0; i < dArray.length; i++) {
|
|
|
+ let _task = dArray[i]
|
|
|
+ _this.unitJson[0].chapterInfo[0].taskJson.push({
|
|
|
+ task: _task.task,
|
|
|
+ taskDetail: "",
|
|
|
+ taskDetail2: "",
|
|
|
+ taskDetail3: "",
|
|
|
+ chapterData: [],
|
|
|
+ toolText: "",
|
|
|
+ toolChoose: [
|
|
|
+ {
|
|
|
+ tool: [],
|
|
|
+ toolDetail: "",
|
|
|
+ toolType: 0,
|
|
|
+ askCount: 1,
|
|
|
+ askTitle: "",
|
|
|
+ askJson: [{ askstitle: "", askItem: 1, checkList: [] }],
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ isShowTools: false,
|
|
|
+ askCount: 1,
|
|
|
+ isFold: 2,
|
|
|
+ askTitle: "",
|
|
|
+ askJson: [{ askstitle: "", askItem: 1, checkList: [] }],
|
|
|
+ checkJson: [{ checkCount: [], checkPerent: [] }],
|
|
|
+ homeworkList: [],
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ _this.unitJson[0].chapterInfo[0].taskJson[0].chapterData = JSON.parse(JSON.stringify(_this.infoData))
|
|
|
+ _this.unitJson2 = JSON.parse(JSON.stringify(_this.unitJson))
|
|
|
+ _this.$forceUpdate();
|
|
|
+
|
|
|
+
|
|
|
+ setTimeout(()=>{
|
|
|
+ for (var i = 0; i < this.unitJson[0].chapterInfo[0].taskJson.length; i++) {
|
|
|
+ this.aiOutlineDetail('', i)
|
|
|
+ }
|
|
|
+ }, 0)
|
|
|
+ }
|
|
|
+ callback ? callback() : ''
|
|
|
+ })
|
|
|
+ .catch((error) => {
|
|
|
+ _this.loading = false
|
|
|
+ console.log(error);
|
|
|
+ });
|
|
|
+ },
|
|
|
async aiGet3(messages, callback) {
|
|
|
let _this = this
|
|
|
|
|
@@ -15442,6 +15759,166 @@ ${msg}
|
|
|
// this.$forceUpdate();
|
|
|
};
|
|
|
},
|
|
|
+ async aiOutlineDetail(msg, index) {
|
|
|
+ let _this = this
|
|
|
+ const _tindex = 'task-' + index
|
|
|
+ const _tindex2 = index
|
|
|
+
|
|
|
+ let fileid = _this.isFileSearch ? [..._this.fileIds] : []
|
|
|
+ if (_this.infoData.length) {
|
|
|
+ for (var i = 0; i < _this.infoData.length; i++) {
|
|
|
+ if(_this.infoData[i].fileid){
|
|
|
+ fileid.push(_this.infoData[i].fileid)
|
|
|
+ }else {
|
|
|
+ let _fileid = await _this.createFileid(_this.infoData[i].url)
|
|
|
+ if(_fileid){
|
|
|
+ _this.infoData[i].fileid = _fileid
|
|
|
+ _this.$forceUpdate();
|
|
|
+ fileid.push(_fileid)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ let url = []
|
|
|
+ if (this.infoData.length) {
|
|
|
+ for (var i = 0; i < this.infoData.length; i++) {
|
|
|
+ url.push(this.infoData[i].url)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let messages = `NOTICE
|
|
|
+Role: 你是创建课程的老师,内容不要以markdown形式出现,只需要口语化的形式。
|
|
|
+Language: Please use the same language as the user requirement, if the user speaks Chinese, the specific text of your answer should also be in Chinese.
|
|
|
+ATTENTION: Use '##' to SPLIT SECTIONS, not '#'. Output format carefully referenced "Format example".
|
|
|
+Instruction: Based on the context, follow "Format example", write content.
|
|
|
+
|
|
|
+#Context
|
|
|
+## 要求
|
|
|
+${_this.aiJson.aiOutlineDetail}
|
|
|
+
|
|
|
+## 参考信息
|
|
|
+课程名字:${_this.courseName}
|
|
|
+任务名称:${_this.aiCallBack.task}
|
|
|
+${_this.courseText ? '课程简要描述:' + _this.courseText : ''}
|
|
|
+
|
|
|
+# Format example
|
|
|
+教学目标:教学目标。
|
|
|
+任务设计:任务设计。
|
|
|
+评价标准:评价标准。 内容不要以markdown形式出现,只需要口语化的形式
|
|
|
+`
|
|
|
+
|
|
|
+// -------- #补充参考资料和
|
|
|
+// ## 补充参考资料
|
|
|
+// - 补充资料:${url.join(",")}
|
|
|
+// - 补充描述:${_this.courseText2}
|
|
|
+ _this.taskDetailLoading.push(_tindex)
|
|
|
+ _this.ttaskDetailLoading.push(_tindex)
|
|
|
+ let _uuid = uuidv4();
|
|
|
+ // let params = JSON.stringify({
|
|
|
+ // // "model": "Chat",
|
|
|
+ // model: 'gpt-3.5-turbo',
|
|
|
+ // temperature: 0,
|
|
|
+ // max_tokens: 4096,
|
|
|
+ // top_p: 1,
|
|
|
+ // frequency_penalty: 0,
|
|
|
+ // presence_penalty: 0,
|
|
|
+ // messages: [{
|
|
|
+ // content: messages,
|
|
|
+ // role: 'user'
|
|
|
+ // }],
|
|
|
+ // uid: _uuid,
|
|
|
+ // mind_map_question: "",
|
|
|
+ // })
|
|
|
+ let params = {
|
|
|
+ assistant_id: 'f8e1ebb2-2e0d-11ef-8bf4-12e77c4cb76b',
|
|
|
+ message: [{"type":"text", "text":messages.replaceAll('\n', " ").replaceAll('*', "")}],
|
|
|
+ session_name: _uuid,
|
|
|
+ userId: _this.userid,
|
|
|
+ uid: _uuid,
|
|
|
+ file_ids: fileid.length ? [...fileid] : '',
|
|
|
+ }
|
|
|
+ // let params = JSON.stringify({
|
|
|
+ // message: {
|
|
|
+ // anthropic_version: "bedrock-2023-05-31",
|
|
|
+ // max_tokens: 4096,
|
|
|
+ // temperature: 0,
|
|
|
+ // top_p: 1,
|
|
|
+ // messages: [{
|
|
|
+ // "role": "user",
|
|
|
+ // "content": messages
|
|
|
+ // }] ,
|
|
|
+ // },
|
|
|
+ // uid: _uuid,
|
|
|
+ // model: "Claude 3 Sonnet" // Claude 3 Sonnet或者Claude 3 Haiku
|
|
|
+ // });
|
|
|
+ // _this.ajax.post('https://gpt4.cocorobo.cn/chat', params).then(function (response) {
|
|
|
+ _this.ajax.post('https://gpt4.cocorobo.cn/ai_agent_park_chat_new', params).then(function (response) {
|
|
|
+ // _this.ajax.post('https://claude3.cocorobo.cn/chat', params).then(function (response) {
|
|
|
+ console.log(response);
|
|
|
+ // let data = response.data.FunctionResponse
|
|
|
+ // if (data.choices && data.choices.length && data.choices[0].message) {
|
|
|
+ // console.log(data.choices[0].message.content);
|
|
|
+ // _this.unitJson[0].chapterInfo[0].taskJson[_tindex2].taskDetail2 = data.choices[0].message.content
|
|
|
+ // _this.$forceUpdate()
|
|
|
+ // }
|
|
|
+
|
|
|
+ if (converter(response.data.FunctionResponse.result) == converter("发送成功")) {
|
|
|
+ } else {
|
|
|
+ this.$message.warning(response.data.FunctionResponse.result);
|
|
|
+ }
|
|
|
+
|
|
|
+ // _this.taskDetailLoading.splice(_this.taskDetailLoading.indexOf(_tindex), 1)
|
|
|
+ }).catch(function (error) {
|
|
|
+ _this.taskDetailLoading.splice(_this.taskDetailLoading.indexOf(_tindex), 1)
|
|
|
+ _this.ttaskDetailLoading.splice(_this.ttaskDetailLoading.indexOf(_tindex), 1)
|
|
|
+ console.log(error);
|
|
|
+ });
|
|
|
+ await _this.aiOutlineDetailgetAiContent(_uuid, _tindex, _tindex2)
|
|
|
+ },
|
|
|
+ aiOutlineDetailgetAiContent(_uid, loading, _tindex2) {
|
|
|
+ // let _source = new EventSource(`https://gpt4.cocorobo.cn/stream/${_uid}`); //http://gpt4.cocorobo.cn:8011/stream/ https://gpt4.cocorobo.cn/stream/
|
|
|
+ let _source = new EventSource(`https://gpt4.cocorobo.cn/question/${_uid}`); //http://gpt4.cocorobo.cn:8011/stream/ https://gpt4.cocorobo.cn/stream/
|
|
|
+ // let _source = new EventSource(`https://claude3.cocorobo.cn/streamChat/${_uid}`); //http://gpt4.cocorobo.cn:8011/stream/ https://gpt4.cocorobo.cn/stream/
|
|
|
+ let _allText = "";
|
|
|
+ let _mdText = "";
|
|
|
+ let _iindex = 0
|
|
|
+ _source.onmessage = _e => {
|
|
|
+ let _eData = JSON.parse(_e.data).content;
|
|
|
+ if (_eData.replace("'", "").replace("'", "") == "[DONE]") {
|
|
|
+ //对话已经完成
|
|
|
+ _mdText = _mdText.replace("_", "");
|
|
|
+ _source.close();
|
|
|
+ this.unitJson[0].chapterInfo[0].taskJson[_tindex2].taskDetail2 = _mdText;
|
|
|
+ this.taskDetailLoading.splice(this.taskDetailLoading.indexOf(loading), 1)
|
|
|
+ this.ttaskDetailLoading.splice(this.ttaskDetailLoading.indexOf(loading), 1)
|
|
|
+ return;
|
|
|
+ } else {
|
|
|
+ _iindex++
|
|
|
+ //对话还在继续
|
|
|
+ let _text = "";
|
|
|
+ _text = _eData.replaceAll("'", "");
|
|
|
+ if (_allText == "") {
|
|
|
+ _allText = _text.replace(/^\n+/, ""); //去掉回复消息中偶尔开头就存在的连续换行符
|
|
|
+ } else {
|
|
|
+ _allText += _text;
|
|
|
+ }
|
|
|
+ _mdText = _allText + "_";
|
|
|
+ _mdText = _mdText.replace(/\\n/g, "\n");
|
|
|
+ _mdText = _mdText.replace(/\\/g, "");
|
|
|
+ if (_allText.split("```").length % 2 == 0) _mdText += "\n```\n";
|
|
|
+ //转化返回的回复流数据.
|
|
|
+ if(_iindex == 10){
|
|
|
+ this.unitJson[0].chapterInfo[0].taskJson[_tindex2].taskDetail2 = _mdText;
|
|
|
+ _iindex = 0
|
|
|
+ }
|
|
|
+ if(this.taskDetailLoading.indexOf(loading) !== -1){
|
|
|
+ this.taskDetailLoading.splice(this.taskDetailLoading.indexOf(loading), 1)
|
|
|
+ }
|
|
|
+ // 处理流数据
|
|
|
+ }
|
|
|
+ // this.$forceUpdate();
|
|
|
+ };
|
|
|
+ },
|
|
|
async aiDetail2(msg, index) {
|
|
|
let _this = this
|
|
|
const _tindex = 'task-' + index
|