Feat: The chat feature supports streaming output, displaying results one by one. #12490 (#12493)

### What problem does this PR solve?

Feat: The chat feature supports streaming output, displaying results one
by one.

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2026-01-08 09:43:57 +08:00
committed by GitHub
parent 23a9544b73
commit de27c006d8
5 changed files with 33 additions and 14 deletions

View File

@ -274,10 +274,23 @@ export const useSendMessageWithSse = (
const val = JSON.parse(value?.data || '');
const d = val?.data;
if (typeof d !== 'boolean') {
setAnswer({
...d,
conversationId: body?.conversation_id,
chatBoxId: body.chatBoxId,
setAnswer((prev) => {
let newAnswer = (prev.answer || '') + (d.answer || '');
if (d.start_to_think === true) {
newAnswer = newAnswer + '<think>';
}
if (d.end_to_think === true) {
newAnswer = newAnswer + '</think>';
}
return {
...d,
answer: newAnswer,
conversationId: body?.conversation_id,
chatBoxId: body.chatBoxId,
};
});
}
} catch (e) {