chore: build rollback

This commit is contained in:
ChenZhaoYu
2023-03-28 16:06:11 +08:00
parent 78bcf7f4ce
commit 76cef650b4
2 changed files with 88 additions and 99 deletions

View File

@@ -25,21 +25,12 @@ router.post('/chat-process', [auth, limiter], async (req, res) => {
try {
const { prompt, options = {}, systemMessage } = req.body as RequestProps
let firstChunk = true
let chatLength = 0
let newChatLength = 0
await chatReplyProcess({
message: prompt,
lastContext: options,
process: (chat: ChatMessage) => {
if (firstChunk) {
res.write(`${JSON.stringify(chat)}t1h1i4s5i1s4a1s9i1l9l8y1s0plit`)
firstChunk = false
}
else if (chatLength !== chat.text.length) {
newChatLength = chat.text.length
res.write(chat.text.substring(chatLength, newChatLength))
chatLength = newChatLength
}
res.write(firstChunk ? JSON.stringify(chat) : `\n${JSON.stringify(chat)}`)
firstChunk = false
},
systemMessage,
})