add chat and completion error messages
This commit is contained in:
parent
bae9ae6551
commit
f998ff239a
@ -96,7 +96,7 @@ const ChatPanel: FC = observer(() => {
|
|||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
if (e.type === 'click' || (e.keyCode === 13 && !e.shiftKey)) {
|
if (e.type === 'click' || (e.keyCode === 13 && !e.shiftKey)) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (commonStore.status.status === ModelStatus.Offline) {
|
if (commonStore.status.status === ModelStatus.Offline && !commonStore.settings.apiUrl) {
|
||||||
toast(t('Please click the button in the top right corner to start the model'), { type: 'warning' });
|
toast(t('Please click the button in the top right corner to start the model'), { type: 'warning' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -194,14 +194,26 @@ const ChatPanel: FC = observer(() => {
|
|||||||
commonStore.setConversationOrder([...commonStore.conversationOrder]);
|
commonStore.setConversationOrder([...commonStore.conversationOrder]);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
async onopen(response) {
|
||||||
|
if (response.status !== 200) {
|
||||||
|
commonStore.conversation[answerId].content += '\n[ERROR]\n```\n' + response.statusText + '\n' + (await response.text()) + '\n```';
|
||||||
|
commonStore.setConversation(commonStore.conversation);
|
||||||
|
commonStore.setConversationOrder([...commonStore.conversationOrder]);
|
||||||
|
setTimeout(scrollToBottom);
|
||||||
|
}
|
||||||
|
},
|
||||||
onclose() {
|
onclose() {
|
||||||
console.log('Connection closed');
|
console.log('Connection closed');
|
||||||
},
|
},
|
||||||
onerror(err) {
|
onerror(err) {
|
||||||
commonStore.conversation[answerId].type = MessageType.Error;
|
commonStore.conversation[answerId].type = MessageType.Error;
|
||||||
commonStore.conversation[answerId].done = true;
|
commonStore.conversation[answerId].done = true;
|
||||||
|
err = err.message || err;
|
||||||
|
if (err && !err.includes('ReadableStreamDefaultReader'))
|
||||||
|
commonStore.conversation[answerId].content += '\n[ERROR]\n```\n' + err + '\n```';
|
||||||
commonStore.setConversation(commonStore.conversation);
|
commonStore.setConversation(commonStore.conversation);
|
||||||
commonStore.setConversationOrder([...commonStore.conversationOrder]);
|
commonStore.setConversationOrder([...commonStore.conversationOrder]);
|
||||||
|
setTimeout(scrollToBottom);
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -180,7 +180,7 @@ const CompletionPanel: FC = observer(() => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onSubmit = (prompt: string) => {
|
const onSubmit = (prompt: string) => {
|
||||||
if (commonStore.status.status === ModelStatus.Offline) {
|
if (commonStore.status.status === ModelStatus.Offline && !commonStore.settings.apiUrl) {
|
||||||
toast(t('Please click the button in the top right corner to start the model'), { type: 'warning' });
|
toast(t('Please click the button in the top right corner to start the model'), { type: 'warning' });
|
||||||
commonStore.setCompletionGenerating(false);
|
commonStore.setCompletionGenerating(false);
|
||||||
return;
|
return;
|
||||||
@ -231,10 +231,22 @@ const CompletionPanel: FC = observer(() => {
|
|||||||
setPrompt(prompt + answer.trim() + params.injectEnd.replaceAll('\\n', '\n'));
|
setPrompt(prompt + answer.trim() + params.injectEnd.replaceAll('\\n', '\n'));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
async onopen(response) {
|
||||||
|
if (response.status !== 200) {
|
||||||
|
toast(response.statusText + '\n' + (await response.text()), {
|
||||||
|
type: 'error'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
onclose() {
|
onclose() {
|
||||||
console.log('Connection closed');
|
console.log('Connection closed');
|
||||||
},
|
},
|
||||||
onerror(err) {
|
onerror(err) {
|
||||||
|
err = err.message || err;
|
||||||
|
if (err && !err.includes('ReadableStreamDefaultReader'))
|
||||||
|
toast(err, {
|
||||||
|
type: 'error'
|
||||||
|
});
|
||||||
commonStore.setCompletionGenerating(false);
|
commonStore.setCompletionGenerating(false);
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user