Browse Source

课堂助手

SanHQin 11 months ago
parent
commit
1fab13f6ed

+ 26 - 3
src/components/classRoomHelper/component/levitatedSphere.vue

@@ -1,6 +1,6 @@
 <template>
   <div class="levitatedSphere" v-show="show">
-    <div :class="['ls_hello']" v-show="showIndex == 0">
+    <div :class="['ls_hello']" v-show="showIndex == 0" @click="stopOne()" @dblclick="stopTwo()">
       <el-image
         style="width: 110%; height: 110%"
         v-show="aiStatus == 1"
@@ -62,8 +62,8 @@ export default {
   data() {
     return {
       show: false,
-      showIndex: 0, //0 :在说话 1 : 接收 2:待命
-      aiStatus: 0,
+      showIndex: 0,
+      aiStatus: 0, //0 :在说话 1 : 接收 2:待命
       aiText: "您好,我是小可,有什么可以帮助您的?",
       userText: "",
       showTextIndex: 0, //0:ai,1:用户, 2:组织语言  3: 无
@@ -85,6 +85,27 @@ export default {
     }
   },
   methods: {
+		stopTwo(){
+			this.show = false;
+      this.showTextIndex = 3;
+      this.aiStatus = 2;
+      this.aiText = "";
+      this.userText = "";
+      this.stopRecord();
+		},
+		stopOne(){
+			if(this.source){
+				this.source.close();
+			}
+			if (this.talkLoading) {
+        this.stopTalk();
+      }
+			this.showIndex = 0;
+			this.showTextIndex = 0;
+			this.aiText = "您好,我是小可,有什么可以帮助您的?";
+			this.aiStatus = 0;
+			this.chatLoading = false;
+		},
     recordStart(_text) {
       var OpenCC = require("opencc-js");
       let converter = OpenCC.Converter({
@@ -376,6 +397,7 @@ export default {
       // const md = new MarkdownIt();
       this.source.onmessage = _e => {
 				this.showIndex = 0;
+				this.aiStatus = 0
         let _eData = JSON.parse(_e.data);
         if (_eData.content.replace("'", "").replace("'", "") == "[DONE]") {
           let _result = [];
@@ -485,6 +507,7 @@ export default {
   position: absolute;
   top: 0;
   right: 0;
+	cursor: pointer;
   animation: smallToBig 1s both;
 }
 

+ 28 - 19
src/components/classRoomHelper/index.vue

@@ -400,47 +400,56 @@ Instruction: Based on the context, follow "Format example", write content
 你需要根据我提供的信息,推测分析,之后给出3个具体的操作步骤的建议。
 
 ##工作流程
-
 1. 仔细阅读并分析我提供的课堂信息或课堂实录内容。
 2. 观察课堂上学生的行为和反应,推测他们的认知状态。
 3. 通过教师的言行和教学安排,推测教师当前的思路和教学目标。
 4. 根据教师的思路和学生的认知状态,提出一个教学建议,并给出3个具体的操作步骤。只需要描述对应的动作,不需要指出该动作的目标和作用。
 
 ##输出
-
 ###输出要求
 1. 最终输出仅包含具体操作步骤。
 2. 具体操作步骤以数组形式输出,包含3个步骤。
-3. 严格按照Format example里的格式输出
-
-##Format example
-["(使用1句话描述)","(使用1句话描述)","(使用1句话描述)"]
+3. 每个步骤用一句话描述,详细一些
 
 ##课堂内容
 当前进行到:${nowTask}
 
+##Format example
+["步骤的描述","步骤的描述","步骤的描述"]
 ${_textData}
 `
 let params = {
-        assistant_id: "6063369f-289a-11ef-8bf4-12e77c4cb76b",
-        userId: this.userid,
-        message: [{ type: "text", text: _msg }],
-        session_name: uuidv4(),
-        // uid: _uuid,
-        file_ids: this.fileId,
-				model: "gpt-4o-2024-08-06",
+        // assistant_id: "6063369f-289a-11ef-8bf4-12e77c4cb76b",
+        // userId: this.userid,
+        // message: [{ type: "text", text: _msg }],
+        // session_name: uuidv4(),
+        // // uid: _uuid,
+        // file_ids: this.fileId,
+				// model: "gpt-4o-2024-08-06",
+					model: "gpt-4o-2024-08-06",
+					temperature: 0,
+					max_tokens: 4096,
+					top_p: 1,
+					frequency_penalty: 0,
+					presence_penalty: 0,
+					messages: [{ role: "user", content: _msg }],
+					uid: uuidv4(),
+					mind_map_question: "",
+					stream: false,
       };
-			console.log(params)
       this.ajax
         // .post("https://gpt4.cocorobo.cn/chat", params)
         // .post("https://claude3.cocorobo.cn/chat", params)
-        .post("https://gpt4.cocorobo.cn/ai_agent_park_chat", params)
+        .post("https://gpt4.cocorobo.cn/chat", params)
         .then(res => {
-          let _data = res.data.FunctionResponse.message;
+          let _data = res.data.FunctionResponse.choices[0].message.content;
           _data = _data.replaceAll("```json", "").replaceAll("```", "");
+					console.log(_data)
           const match = _data.match(/\[\s*[^]*\s*\]/);
           let _result = JSON.parse(match[0]) || [];
+					
 					this.tipsList.push(_result)
+					
           this.showTipsLoading = false;
 					this.canShowTips = true;
         })
@@ -592,8 +601,8 @@ let params = {
         this.$refs.levitatedSphereRef.recordStart();
       } else if (this.recordType == 1) {
         // this.$message.info("关闭")
-        // this.changeRecordType(0)
-        this.$refs.levitatedSphereRef.stopRecord();
+        this.$refs.levitatedSphereRef.stopTwo();
+				// this.changeRecordType(0)
       }
     },
     changeMegaphone() {
@@ -627,7 +636,7 @@ let params = {
       this.$refs.levitatedSphereRef.startRecord();
     },
     stopRecord() {
-      this.$refs.levitatedSphereRef.stopRecord();
+      this.$refs.levitatedSphereRef.stopTwo();
     },
     // 语音合成
     startSpeak() {