This commit is contained in:
josc146 2024-04-30 21:55:24 +08:00
parent 2d853f92b9
commit 40c5368deb
3 changed files with 11 additions and 8 deletions

View File

@ -599,14 +599,15 @@ const ChatPanel: FC = observer(() => {
if (data.model)
commonStore.setLastModelName(data.model);
if (data.choices && Array.isArray(data.choices) && data.choices.length > 0) {
if (data.choices[0]?.finish_reason) {
finish();
return;
}
answer += data.choices[0]?.delta?.content || '';
commonStore.conversation[answerId!].content = answer;
commonStore.setConversation(commonStore.conversation);
commonStore.setConversationOrder([...commonStore.conversationOrder]);
if (data.choices[0]?.finish_reason) {
finish();
return;
}
}
},
async onopen(response) {

View File

@ -125,12 +125,13 @@ const CompletionPanel: FC = observer(() => {
if (data.model)
commonStore.setLastModelName(data.model);
if (data.choices && Array.isArray(data.choices) && data.choices.length > 0) {
answer += data.choices[0]?.text || data.choices[0]?.delta?.content || '';
setPrompt(prompt + answer.replace(/\s+$/, '') + params.injectEnd.replaceAll('\\n', '\n'));
if (data.choices[0]?.finish_reason) {
finish();
return;
}
answer += data.choices[0]?.text || data.choices[0]?.delta?.content || '';
setPrompt(prompt + answer.replace(/\s+$/, '') + params.injectEnd.replaceAll('\\n', '\n'));
}
},
async onopen(response) {

View File

@ -230,12 +230,13 @@ const CompositionPanel: FC = observer(() => {
if (data.model)
commonStore.setLastModelName(data.model);
if (data.choices && Array.isArray(data.choices) && data.choices.length > 0) {
answer += data.choices[0]?.text || data.choices[0]?.delta?.content || '';
setPrompt(prompt + answer.replace(/\s+$/, ''));
if (data.choices[0]?.finish_reason) {
finish();
return;
}
answer += data.choices[0]?.text || data.choices[0]?.delta?.content || '';
setPrompt(prompt + answer.replace(/\s+$/, ''));
}
},
async onopen(response) {