fix: AI聊天缺少最后一句话的情况

This commit is contained in:
kuaifan 2024-11-20 16:57:35 +08:00
parent 1f187ba8fb
commit d4cccbeb09

View File

@ -3423,24 +3423,25 @@ export default {
} }
const sse = new SSEClient(streamUrl) const sse = new SSEClient(streamUrl)
sse.subscribe(['append', 'replace', 'done'], (type, e) => { sse.subscribe(['append', 'replace', 'done'], (type, e) => {
const data = {
id: e.lastEventId,
text: e.data,
type: 'replace',
};
switch (type) { switch (type) {
case 'append': case 'append':
Store.set('dialogMsgChange', { data.type = 'append';
id: e.lastEventId, Store.set('dialogMsgChange', data);
type: 'append',
text: e.data
});
break; break;
case 'replace': case 'replace':
Store.set('dialogMsgChange', { Store.set('dialogMsgChange', data);
id: e.lastEventId,
type: 'replace',
text: e.data
});
break; break;
case 'done': case 'done':
if (data.text) {
Store.set('dialogMsgChange', data);
}
const index = state.dialogSseList.findIndex(item => sse === item.sse) const index = state.dialogSseList.findIndex(item => sse === item.sse)
if (index > -1) { if (index > -1) {
state.dialogSseList.splice(index, 1) state.dialogSseList.splice(index, 1)