|
|
@ -153,6 +153,7 @@
|
|
|
|
import presetQuestion from './presetQuestion.vue';
|
|
|
|
import presetQuestion from './presetQuestion.vue';
|
|
|
|
import { DeleteOutlined, ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
|
|
|
import { DeleteOutlined, ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
|
|
|
import { message, Modal, Tabs } from 'ant-design-vue';
|
|
|
|
import { message, Modal, Tabs } from 'ant-design-vue';
|
|
|
|
|
|
|
|
import { isObject, isString } from '/@/utils/is';
|
|
|
|
import '../style/github-markdown.less';
|
|
|
|
import '../style/github-markdown.less';
|
|
|
|
import '../style/highlight.less';
|
|
|
|
import '../style/highlight.less';
|
|
|
|
import '../style/style.less';
|
|
|
|
import '../style/style.less';
|
|
|
@ -250,7 +251,8 @@
|
|
|
|
// 当从事件源接收到数据时触发
|
|
|
|
// 当从事件源接收到数据时触发
|
|
|
|
evtSource.onmessage = function (e) {
|
|
|
|
evtSource.onmessage = function (e) {
|
|
|
|
const data = e.data;
|
|
|
|
const data = e.data;
|
|
|
|
// console.log(e);
|
|
|
|
let delay = 0;
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
if (data === '[DONE]') {
|
|
|
|
if (data === '[DONE]') {
|
|
|
|
updateChatSome(uuid, props.chatData.length - 1, { loading: false });
|
|
|
|
updateChatSome(uuid, props.chatData.length - 1, { loading: false });
|
|
|
|
scrollToBottom();
|
|
|
|
scrollToBottom();
|
|
|
@ -273,17 +275,22 @@
|
|
|
|
});
|
|
|
|
});
|
|
|
|
scrollToBottom();
|
|
|
|
scrollToBottom();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
updateChatSome(uuid.value, props.chatData.length - 1, { loading: false });
|
|
|
|
// updateChatSome(uuid.value, props.chatData.length - 1, { loading: false });
|
|
|
|
scrollToBottom();
|
|
|
|
// scrollToBottom();
|
|
|
|
handleStop();
|
|
|
|
// handleStop();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (error: any) {
|
|
|
|
|
|
|
|
console.log('ai 聊天:::', error);
|
|
|
|
|
|
|
|
if (isObject(error) && isString(error.message) && error.message.endsWith('is not valid JSON')) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (error) {
|
|
|
|
|
|
|
|
updateChatSome(uuid.value, props.chatData.length - 1, { loading: false });
|
|
|
|
updateChatSome(uuid.value, props.chatData.length - 1, { loading: false });
|
|
|
|
scrollToBottom();
|
|
|
|
scrollToBottom();
|
|
|
|
handleStop();
|
|
|
|
handleStop();
|
|
|
|
evtSource.close(); // 关闭连接
|
|
|
|
evtSource.close(); // 关闭连接
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}, delay);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
// 与事件源的连接无法打开时触发
|
|
|
|
// 与事件源的连接无法打开时触发
|
|
|
|
evtSource.onerror = function (e) {
|
|
|
|
evtSource.onerror = function (e) {
|
|
|
@ -347,6 +354,7 @@
|
|
|
|
};
|
|
|
|
};
|
|
|
|
// 停止响应
|
|
|
|
// 停止响应
|
|
|
|
const handleStop = () => {
|
|
|
|
const handleStop = () => {
|
|
|
|
|
|
|
|
console.log('ai 聊天:::---停止响应');
|
|
|
|
if (loading.value) {
|
|
|
|
if (loading.value) {
|
|
|
|
loading.value = false;
|
|
|
|
loading.value = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|