fix line end with new-line in some backend (#474)

* fix line end with new-line in some backend

In backend with golang (like https://github.com/sashabaranov/go-openai), the responseText always has '\n'.

* feat: 补全遗漏

---------

Co-authored-by: ChenZhaoYu <790348264@qq.com>
This commit is contained in:
Liut 2023-03-22 18:49:40 +08:00 committed by GitHub
parent 1edf591721
commit e30217542d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -115,7 +115,7 @@ async function onConversation() {
const xhr = event.target
const { responseText } = xhr
// Always process the final line
const lastIndex = responseText.lastIndexOf('\n')
const lastIndex = responseText.lastIndexOf('\n', responseText.length - 2)
let chunk = responseText
if (lastIndex !== -1)
chunk = responseText.substring(lastIndex)
@ -245,7 +245,7 @@ async function onRegenerate(index: number) {
const xhr = event.target
const { responseText } = xhr
// Always process the final line
const lastIndex = responseText.lastIndexOf('\n')
const lastIndex = responseText.lastIndexOf('\n', responseText.length - 2)
let chunk = responseText
if (lastIndex !== -1)
chunk = responseText.substring(lastIndex)