improve sse fetch
This commit is contained in:
@@ -219,7 +219,7 @@ const CompletionPanel: FC = observer(() => {
|
||||
signal: completionSseController?.signal,
|
||||
onmessage(e) {
|
||||
scrollToBottom();
|
||||
if (e.data === '[DONE]') {
|
||||
if (e.data.trim() === '[DONE]') {
|
||||
commonStore.setCompletionGenerating(false);
|
||||
return;
|
||||
}
|
||||
@@ -231,8 +231,8 @@ const CompletionPanel: FC = observer(() => {
|
||||
return;
|
||||
}
|
||||
if (data.choices && Array.isArray(data.choices) && data.choices.length > 0) {
|
||||
answer += data.choices[0].text;
|
||||
setPrompt(prompt + answer.trim() + params.injectEnd.replaceAll('\\n', '\n'));
|
||||
answer += data.choices[0]?.text || data.choices[0]?.delta?.content || '';
|
||||
setPrompt(prompt + answer.replace(/\s+$/, '') + params.injectEnd.replaceAll('\\n', '\n'));
|
||||
}
|
||||
},
|
||||
async onopen(response) {
|
||||
|
||||
Reference in New Issue
Block a user