Pārlūkot izejas kodu

Merge branch 'beta' of https://git.cocorobo.cn/CocoRoboLabs/pbl-student-table into beta

SanHQin 3 nedēļas atpakaļ
vecāks
revīzija
cdea616021

+ 43 - 32
src/components/classRoomHelper/component/levitatedSphere.vue

@@ -234,19 +234,29 @@ export default {
 								let msgList = [];
 
 								msgList.push({
-									type:"text",
-									text: `请在150字以内回答以下问题:\n${this.userText}`
+									role:"user",
+									content: `请在150字以内回答以下问题:\n${this.userText}`
 								})
                 this.chatLoading = true;
                 const _uuid = uuidv4();
                 let params = {
-                  assistant_id: "f8e1ebb2-2e0d-11ef-8bf4-12e77c4cb76b",
-                  userId: this.userId,
-                  message: msgList,
-                  session_name: _uuid + "-qgt",
-                  uid: _uuid,
-                  file_ids: [],
-									model: "gpt-4o-2024-11-20"
+                  // assistant_id: "f8e1ebb2-2e0d-11ef-8bf4-12e77c4cb76b",
+                  // userId: this.userId,
+                  // message: msgList,
+                  // session_name: _uuid + "-qgt",
+                  // uid: _uuid,
+                  // file_ids: [],
+									// model: "gpt-4o-2024-11-20"
+                  model: "gpt-4o-2024-11-20",
+                  temperature: 0,
+                  max_tokens: 4096,
+                  top_p: 1,
+                  frequency_penalty: 0,
+                  presence_penalty: 0,
+                  messages: msgList,
+                  uid: this.userId,
+                  mind_map_question: "",
+                  stream:true
                 };
 
                   const md = new MarkdownIt();
@@ -267,31 +277,32 @@ export default {
                     onmessage(_e){
                       console.log('_e',_e)
 
-                      this.showIndex = 0;
-                      let _eData = JSON.parse(_e.data);
-                      if (_eData.content.replace("'", "").replace("'", "") == "[DONE]") {
+                      _this.showIndex = 0;
+                      if(!_e.data)return
+                      let _eData = _e.data;
+                      if (_eData.replace("'", "").replace("'", "") == "[DONE]") {
                         // this.source.close();
                         // this.source = null;
-                        let _result = [];
-                        if ("result" in _eData) {
-                          _result = _eData.result;
-                          for (let i = 0; i < _result.length; i++) {
-                            _mdText = _mdText.replace(_result[i].text, _result[i].fileName);
-                          }
-                        }
+                        // let _result = [];
+                        // if ("result" in _eData) {
+                        //   _result = _eData.result;
+                        //   for (let i = 0; i < _result.length; i++) {
+                        //     _mdText = _mdText.replace(_result[i].text, _result[i].fileName);
+                        //   }
+                        // }
                         _mdText = _mdText.replace("_", "");
-                        this.aiText = _mdText;
-                        this.scrollBottom();
+                        _this.aiText = _mdText;
+                        // _this.scrollBottom();
                         if (_talkText != "") {
-                          let _resultText = this.removeMarkdown(_talkText);
-                          this.talkTextList.push(_resultText);
+                          let _resultText = _this.removeMarkdown(_talkText);
+                          _this.talkTextList.push(_resultText);
                           _talkText = "";
-                          if (!this.talkLoading) this.talkText();
+                          if (!_this.talkLoading) _this.talkText();
                         }
-                        this.chatLoading = false;
+                        _this.chatLoading = false;
                       } else {
                         // _talkIndex+=1;
-                        let _text = _eData.content.replace("'", "").replace("'", "");
+                        let _text = _eData.replace("'", "").replace("'", "");
                         if (_allText == "") {
                           _allText = _text.replace(/^\n+/, ""); //去掉回复消息中偶尔开头就存在的连续换行符
                           _talkText += _text.replace(/^\n+/, "");
@@ -304,14 +315,14 @@ export default {
                         _mdText = _mdText.replace(/\\n/g, "\n");
                         _mdText = _mdText.replace(/\\/g, "");
                         if (_allText.split("```").length % 2 == 0) _mdText += "\n```\n";
-                        this.aiText = _mdText;
-                        this.showTextIndex = 0;
-                        this.scrollBottom();
+                        _this.aiText = _mdText;
+                        _this.showTextIndex = 0;
+                        // _this.scrollBottom();
                         if (/[,。:;?!)]/.test(_talkText)) {
-                          let _resultText = this.removeMarkdown(_talkText);
-                          this.talkTextList.push(_resultText);
+                          let _resultText = _this.removeMarkdown(_talkText);
+                          _this.talkTextList.push(_resultText);
                           _talkText = "";
-                          if (!this.talkLoading) this.talkText();
+                          if (!_this.talkLoading) _this.talkText();
                         }
                       }