|
@@ -51,6 +51,7 @@
|
|
|
src="https://beta.cloud.cocorobo.cn/browser/public/index1.html"
|
|
|
ref="iiframe2"
|
|
|
v-show="false"
|
|
|
+ v-if="show"
|
|
|
></iframe>
|
|
|
|
|
|
<mini-audio
|
|
@@ -97,7 +98,7 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
stopTwo(){
|
|
|
- this.show = false;
|
|
|
+ this.show = false;
|
|
|
this.showTextIndex = 3;
|
|
|
this.aiStatus = 2;
|
|
|
this.aiText = "";
|
|
@@ -156,7 +157,7 @@ export default {
|
|
|
console.log("👇");
|
|
|
console.log(_msg);
|
|
|
// _msg = converter(_msg)
|
|
|
- if (!_msg) return console.log("输出为空");
|
|
|
+ if (!_msg || _msg == '.') return console.log("输出为空");
|
|
|
// if (_msg.indexOf(converter("可可同学")) != -1 && !this.show) {
|
|
|
// this.aiText = "您好,我是小可,有什么可以帮助您的?";
|
|
|
// this.aiStatus = 0;
|
|
@@ -234,19 +235,22 @@ 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"
|
|
|
+ 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 +271,33 @@ 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;
|
|
|
+ _this.userText = '';
|
|
|
} 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 +310,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();
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -326,6 +332,8 @@ export default {
|
|
|
},
|
|
|
onclose(){
|
|
|
_this.$forceUpdate();
|
|
|
+ _this.userText = '';
|
|
|
+
|
|
|
// _this.stopTalkToken = null;
|
|
|
// // _this.faloading = false;
|
|
|
_this.curRequestController = null;
|
|
@@ -403,28 +411,34 @@ export default {
|
|
|
// this.$parent.changeRecordType(0);
|
|
|
// this.$message.success("已关闭语音助手")
|
|
|
// return
|
|
|
- let iiframe = this.$refs["iiframe"];
|
|
|
- iiframe.contentWindow.window.document
|
|
|
- .getElementById("scenarioStopButton")
|
|
|
- .click();
|
|
|
- if (this.talkLoading) {
|
|
|
- this.stopTalk();
|
|
|
- }
|
|
|
- // this.stopTalk();
|
|
|
- // 录音借宿
|
|
|
- iiframe.contentWindow.onSessionStopped = (s, e) => {
|
|
|
- this.isOpen = false;
|
|
|
- this.show = false;
|
|
|
- this.showTextIndex = 3;
|
|
|
- this.showIndex = 2;
|
|
|
+ try {
|
|
|
+ let iiframe = this.$refs["iiframe"];
|
|
|
+ iiframe.contentWindow.window.document
|
|
|
+ .getElementById("scenarioStopButton")
|
|
|
+ .click();
|
|
|
+ if (this.talkLoading) {
|
|
|
+ this.$refs.iiframe2.contentWindow.closesynthesizer();
|
|
|
+ }
|
|
|
+ // this.stopTalk();
|
|
|
+ // 录音借宿
|
|
|
+ iiframe.contentWindow.onSessionStopped = (s, e) => {
|
|
|
+ this.isOpen = false;
|
|
|
+ this.show = false;
|
|
|
+ this.showTextIndex = 3;
|
|
|
+ this.showIndex = 2;
|
|
|
+ this.$parent.changeRecordType(0);
|
|
|
+ this.$message.success("已关闭语音助手");
|
|
|
+ if (this.talkLoading) {
|
|
|
+ this.stopTalk();
|
|
|
+ }
|
|
|
+ this.userText = "";
|
|
|
+ this.aiText = "";
|
|
|
+ };
|
|
|
+
|
|
|
+ } catch (error) {
|
|
|
this.$parent.changeRecordType(0);
|
|
|
- this.$message.success("已关闭语音助手");
|
|
|
- if (this.talkLoading) {
|
|
|
- this.$refs.iiframe2.contentWindow.closesynthesizer();
|
|
|
- }
|
|
|
- this.userText = "";
|
|
|
- this.aiText = "";
|
|
|
- };
|
|
|
+ }
|
|
|
+
|
|
|
},
|
|
|
chineseToNumber(chinese) {
|
|
|
var OpenCC = require("opencc-js");
|