|
@@ -19,23 +19,32 @@
|
|
|
<span v-else>Ai</span>
|
|
|
</div>
|
|
|
<div class="d_t_c_a_right">
|
|
|
- <div class="d_t_c_a_r_content" style="display: flex;justify-content: space-between;flex-wrap: wrap;" v-if="item.content.includes('图片')">
|
|
|
+ <div
|
|
|
+ class="d_t_c_a_r_content"
|
|
|
+ style="display: flex;justify-content: space-between;flex-wrap: wrap;"
|
|
|
+ v-if="item.content.includes('图片')"
|
|
|
+ >
|
|
|
<div
|
|
|
v-if="!pan(item.aiContent).length"
|
|
|
class="d_t_c_a_r_content"
|
|
|
v-loading="item.loading"
|
|
|
v-html="item.aiContent"
|
|
|
></div>
|
|
|
-
|
|
|
+
|
|
|
<div v-else v-for="i in pan(item.aiContent)">
|
|
|
- <img style="width: 120px;height: 120px;" :src="i.image" alt="" @click="previewImg(i.image)">
|
|
|
+ <img
|
|
|
+ style="width: 120px;height: 120px;"
|
|
|
+ :src="i.image"
|
|
|
+ alt=""
|
|
|
+ @click="previewImg(i.image)"
|
|
|
+ />
|
|
|
</div>
|
|
|
</div>
|
|
|
<div
|
|
|
v-else
|
|
|
class="d_t_c_a_r_content"
|
|
|
v-loading="item.loading"
|
|
|
- v-html="item.aiContent"
|
|
|
+ v-html="htmlContent(item.aiContent)"
|
|
|
></div>
|
|
|
<div class="d_t_c_a_r_time">{{ item.createtime }}</div>
|
|
|
</div>
|
|
@@ -244,97 +253,25 @@ export default {
|
|
|
rightRole: -1,
|
|
|
loading: false,
|
|
|
chatLoading: false,
|
|
|
- roleList2: [
|
|
|
- {
|
|
|
- id: 3,
|
|
|
- avatar: require("../../../assets/icon/course/aiAvatar.png"),
|
|
|
- name: "莱昂纳多·达芬奇",
|
|
|
- bir: "我是莱昂纳多·达芬奇"
|
|
|
- },
|
|
|
- {
|
|
|
- id: 4,
|
|
|
- avatar: require("../../../assets/icon/course/aiAvatar.png"),
|
|
|
- name: "列文虎克",
|
|
|
- bir: "我是列文虎克"
|
|
|
- },
|
|
|
- {
|
|
|
- id: 5,
|
|
|
- avatar: require("../../../assets/icon/course/aiAvatar.png"),
|
|
|
- name: "詹姆斯·瓦特",
|
|
|
- bir: "我是詹姆斯·瓦特"
|
|
|
- },
|
|
|
- {
|
|
|
- id: 6,
|
|
|
- avatar: require("../../../assets/icon/course/aiAvatar.png"),
|
|
|
- name: "瑞秋·卡森",
|
|
|
- bir: "我是瑞秋·卡森"
|
|
|
- },
|
|
|
- {
|
|
|
- id: 7,
|
|
|
- avatar: require("../../../assets/icon/course/aiAvatar.png"),
|
|
|
- name: "尼古拉·特斯拉",
|
|
|
- bir: "我是尼古拉·特斯拉"
|
|
|
- },
|
|
|
- {
|
|
|
- id: 8,
|
|
|
- avatar: require("../../../assets/icon/course/aiAvatar.png"),
|
|
|
- name: "约翰·穆尔",
|
|
|
- bir: "我是约翰·穆尔"
|
|
|
- }
|
|
|
- ],
|
|
|
- roleList: [
|
|
|
- {
|
|
|
- id: 0,
|
|
|
- avatar: require("../../../assets/icon/course/aiAvatar.png"),
|
|
|
- name: "爱因斯坦",
|
|
|
- bir: "我是爱因斯坦"
|
|
|
- },
|
|
|
- {
|
|
|
- id: 1,
|
|
|
- avatar: require("../../../assets/icon/course/aiAvatar.png"),
|
|
|
- name: "居里夫人",
|
|
|
- bir: "我是居里夫人"
|
|
|
- },
|
|
|
- {
|
|
|
- id: 2,
|
|
|
- avatar: require("../../../assets/icon/course/aiAvatar.png"),
|
|
|
- name: "达尔文",
|
|
|
- bir: "我是达尔文"
|
|
|
- }
|
|
|
- // {id:3,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"莱昂纳多·达芬奇"},
|
|
|
- // {id:4,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"列文虎克"},
|
|
|
- // {id:5,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"詹姆斯·瓦特"},
|
|
|
- // {id:6,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"瑞秋·卡森"},
|
|
|
- // {id:7,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"尼古拉·特斯拉"},
|
|
|
- // {id:8,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"约翰·穆尔"},
|
|
|
- // {id:9,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"艾萨克·牛顿"},
|
|
|
- // {id:10,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"伽利略"},
|
|
|
- // {id:11,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"格雷戈尔·孟德尔"},
|
|
|
- // {id:12,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"张衡"},
|
|
|
- // {id:13,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"李时珍"},
|
|
|
- // {id:14,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"钱学森"},
|
|
|
- // {id:15,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"阿基米德"},
|
|
|
- // {id:16,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"霍金"},
|
|
|
- // {id:17,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"蔡伦"},
|
|
|
- // {id:18,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"詹姆斯·瓦特"},
|
|
|
- // {id:19,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"路易·巴斯德"},
|
|
|
- // {id:20,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"阿尔弗雷德·诺贝尔"},
|
|
|
- // {id:21,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"詹姆斯·麦克斯韦"},
|
|
|
- // {id:22,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"亚历山大·格拉汉姆·贝尔"},
|
|
|
- // {id:23,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"约翰内斯·开普勒"},
|
|
|
- // {id:24,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"安德烈·安培"},
|
|
|
- ],
|
|
|
- chatList: []
|
|
|
+ roleList2: [],
|
|
|
+ chatList: [],
|
|
|
+ nowChatList:[],
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
|
pan() {
|
|
|
- return (content) => {
|
|
|
+ return content => {
|
|
|
try {
|
|
|
- return JSON.parse(content)
|
|
|
- } catch (error) {
|
|
|
- return []
|
|
|
- }
|
|
|
+ return JSON.parse(content);
|
|
|
+ } catch (error) {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+ };
|
|
|
+ },
|
|
|
+ htmlContent() {
|
|
|
+ const md = new MarkdownIt();
|
|
|
+ return _md => {
|
|
|
+ return md.render(_md);
|
|
|
};
|
|
|
}
|
|
|
},
|
|
@@ -390,7 +327,7 @@ export default {
|
|
|
assistant_id: this.choseRoleItem.assistant_id,
|
|
|
userId: this.userid,
|
|
|
message: _text,
|
|
|
- session_name: `${this.courseId}-studyStudent`,
|
|
|
+ session_name: `${this.courseId}-studyStudent-md`,
|
|
|
uid: _uid,
|
|
|
file_ids: []
|
|
|
};
|
|
@@ -411,8 +348,6 @@ export default {
|
|
|
} else {
|
|
|
let _uuid = uuidv4();
|
|
|
|
|
|
-
|
|
|
-
|
|
|
this.chatList.push({
|
|
|
role: "user",
|
|
|
content: `${_text}`,
|
|
@@ -427,6 +362,34 @@ export default {
|
|
|
loading: true
|
|
|
});
|
|
|
this.scrollBottom();
|
|
|
+ let history = [];
|
|
|
+ this.nowChatList.forEach(i => {
|
|
|
+ if (i.content == "wanSearch") {
|
|
|
+ return history.push({
|
|
|
+ role: "assistant",
|
|
|
+ content: JSON.stringify(i.aiContent)
|
|
|
+ });
|
|
|
+ } else if (i.content == "getImage") {
|
|
|
+ return history.push({
|
|
|
+ role: "assistant",
|
|
|
+ content: i.aiContent
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (i.content) {
|
|
|
+ history.push({
|
|
|
+ role: "user",
|
|
|
+ content: i.content
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (i.aiContent) {
|
|
|
+ history.push({
|
|
|
+ role: "assistant",
|
|
|
+ content: i.aiContent
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ history.push({ role: "user", content: _text });
|
|
|
+ // history.pop();
|
|
|
let params = {
|
|
|
model: "gpt-3.5-turbo",
|
|
|
temperature: 0,
|
|
@@ -434,12 +397,12 @@ export default {
|
|
|
top_p: 1,
|
|
|
frequency_penalty: 0,
|
|
|
presence_penalty: 0,
|
|
|
- messages: [{ role: "user", content: _text }],
|
|
|
+ messages: history,
|
|
|
uid: _uuid,
|
|
|
- mind_map_question: ""
|
|
|
+ mind_map_question: _text
|
|
|
};
|
|
|
this.text = "";
|
|
|
- console.log('发送信息',params);
|
|
|
+ console.log("发送信息", params);
|
|
|
|
|
|
this.ajax
|
|
|
.post("https://gpt4.cocorobo.cn/chat", params)
|
|
@@ -462,7 +425,7 @@ export default {
|
|
|
let _source = new EventSource(`https://gpt4.cocorobo.cn/stream/${_uid}`); //http://gpt4.cocorobo.cn:8011/stream/ https://gpt4.cocorobo.cn/stream/
|
|
|
let _allText = "";
|
|
|
let _mdText = "";
|
|
|
- const md = new MarkdownIt();
|
|
|
+ // const md = new MarkdownIt();
|
|
|
_source.onmessage = _e => {
|
|
|
if (_e.data.replace("'", "").replace("'", "") == "[DONE]") {
|
|
|
//对话已经完成
|
|
@@ -474,6 +437,7 @@ export default {
|
|
|
this.chatList.find(i => i.uid == _uid).isalltext = true;
|
|
|
this.chatList.find(i => i.uid == _uid).isShowSynchronization = true;
|
|
|
this.chatList.find(i => i.uid == _uid).loading = false;
|
|
|
+ this.nowChatList.push(this.chatList.find(i=>i.uid==_uid));
|
|
|
// 这里保存对话
|
|
|
this.insertChat(_uid);
|
|
|
return;
|
|
@@ -491,7 +455,7 @@ export default {
|
|
|
_mdText = _mdText.replace(/\\/g, "");
|
|
|
if (_allText.split("```").length % 2 == 0) _mdText += "\n```\n";
|
|
|
//转化返回的回复流数据
|
|
|
- _mdText = md.render(_mdText);
|
|
|
+ // _mdText = md.render(_mdText);
|
|
|
this.chatList.find(i => i.uid == _uid).aiContent = _mdText;
|
|
|
this.chatList.find(i => i.uid == _uid).loading = false;
|
|
|
this.scrollBottom();
|
|
@@ -505,7 +469,7 @@ export default {
|
|
|
); //http://gpt4.cocorobo.cn:8011/question/ https://gpt4.cocorobo.cn/question/
|
|
|
let _allText = "";
|
|
|
let _mdText = "";
|
|
|
- const md = new MarkdownIt();
|
|
|
+ // const md = new MarkdownIt();
|
|
|
_source.onmessage = _e => {
|
|
|
let _eData = JSON.parse(_e.data);
|
|
|
if (_eData.content.replace("'", "").replace("'", "") == "[DONE]") {
|
|
@@ -522,7 +486,7 @@ export default {
|
|
|
this.chatList.find(i => i.uid == _uid).isalltext = true;
|
|
|
this.chatList.find(i => i.uid == _uid).isShowSynchronization = true;
|
|
|
this.chatList.find(i => i.uid == _uid).loading = false;
|
|
|
-
|
|
|
+ this.nowChatList.push(this.chatList.find(i=>i.uid==_uid));
|
|
|
this.insertChat(_uid);
|
|
|
} else {
|
|
|
let _text = _eData.content.replace("'", "").replace("'", "");
|
|
@@ -536,7 +500,7 @@ export default {
|
|
|
_mdText = _mdText.replace(/\\/g, "");
|
|
|
if (_allText.split("```").length % 2 == 0) _mdText += "\n```\n";
|
|
|
//转化返回的回复流数据
|
|
|
- _mdText = md.render(_mdText);
|
|
|
+ // _mdText = md.render(_mdText);
|
|
|
this.chatList.find(i => i.uid == _uid).aiContent = _mdText;
|
|
|
this.chatList.find(i => i.uid == _uid).loading = false;
|
|
|
this.$nextTick(() => {
|
|
@@ -560,7 +524,7 @@ export default {
|
|
|
alltext: _data.aiContent,
|
|
|
type: "chat",
|
|
|
filename: _data.filename,
|
|
|
- session_name: `${this.courseId}-studyStudent` //这是对话记录位置
|
|
|
+ session_name: `${this.courseId}-studyStudent-md` //这是对话记录位置
|
|
|
};
|
|
|
this.ajax
|
|
|
.post("https://gpt4.cocorobo.cn/insert_chat", params)
|
|
@@ -577,7 +541,7 @@ export default {
|
|
|
userid: this.userid,
|
|
|
groupid: "602def61-005d-11ee-91d8-005056b8q12w",
|
|
|
// session_name:``
|
|
|
- session_name: `${this.courseId}-studyStudent`
|
|
|
+ session_name: `${this.courseId}-studyStudent-md`
|
|
|
};
|
|
|
this.ajax
|
|
|
.post("https://gpt4.cocorobo.cn/get_agent_park_chat", params)
|
|
@@ -670,6 +634,7 @@ export default {
|
|
|
// this.rightRole = this.roleType;
|
|
|
if (this.choseRoleItem.assistant_id) {
|
|
|
this.chatList = [];
|
|
|
+ this.nowChatList = [];
|
|
|
let _uuid = uuidv4();
|
|
|
this.chatList.push({
|
|
|
role: "user",
|
|
@@ -686,6 +651,7 @@ export default {
|
|
|
is_mind_map: false,
|
|
|
loading: false
|
|
|
});
|
|
|
+
|
|
|
this.scrollBottom();
|
|
|
}
|
|
|
|
|
@@ -852,6 +818,7 @@ export default {
|
|
|
this.getChatList().then(_ => {
|
|
|
this.scrollBottom();
|
|
|
});
|
|
|
+ this.nowChatList = [];
|
|
|
}
|
|
|
};
|
|
|
</script>
|