mirror of
https://github.com/Chanzhaoyu/chatgpt-web.git
synced 2025-07-21 03:44:21 +00:00
pref: message output optimization (#935)
* Update index.ts 修改后端,让保留打字机效果的同时优化前后端之间传输的内容,节省流量和性能 * Update index.vue 修改前端,和之前修改的后端匹配,保留打字机效果同时优化性能和流量传输 * chore: lint fix --------- Co-authored-by: ChenZhaoYu <790348264@qq.com>
This commit is contained in:
@@ -29,8 +29,16 @@ router.post('/chat-process', [auth, limiter], async (req, res) => {
|
||||
message: prompt,
|
||||
lastContext: options,
|
||||
process: (chat: ChatMessage) => {
|
||||
res.write(firstChunk ? JSON.stringify(chat) : `\n${JSON.stringify(chat)}`)
|
||||
firstChunk = false
|
||||
if (firstChunk) {
|
||||
res.write(`${JSON.stringify(chat)}t1h1i4s5i1s4a1s9i1l9l8y1s0plit`)
|
||||
firstChunk = false
|
||||
}
|
||||
else {
|
||||
let tmp = chat.delta
|
||||
if (!(chat.delta))
|
||||
tmp = ''
|
||||
res.write(tmp)
|
||||
}
|
||||
},
|
||||
systemMessage,
|
||||
})
|
||||
|
Reference in New Issue
Block a user