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:
parent
1edf591721
commit
e30217542d
|
@ -115,7 +115,7 @@ async function onConversation() {
|
||||||
const xhr = event.target
|
const xhr = event.target
|
||||||
const { responseText } = xhr
|
const { responseText } = xhr
|
||||||
// Always process the final line
|
// Always process the final line
|
||||||
const lastIndex = responseText.lastIndexOf('\n')
|
const lastIndex = responseText.lastIndexOf('\n', responseText.length - 2)
|
||||||
let chunk = responseText
|
let chunk = responseText
|
||||||
if (lastIndex !== -1)
|
if (lastIndex !== -1)
|
||||||
chunk = responseText.substring(lastIndex)
|
chunk = responseText.substring(lastIndex)
|
||||||
|
@ -245,7 +245,7 @@ async function onRegenerate(index: number) {
|
||||||
const xhr = event.target
|
const xhr = event.target
|
||||||
const { responseText } = xhr
|
const { responseText } = xhr
|
||||||
// Always process the final line
|
// Always process the final line
|
||||||
const lastIndex = responseText.lastIndexOf('\n')
|
const lastIndex = responseText.lastIndexOf('\n', responseText.length - 2)
|
||||||
let chunk = responseText
|
let chunk = responseText
|
||||||
if (lastIndex !== -1)
|
if (lastIndex !== -1)
|
||||||
chunk = responseText.substring(lastIndex)
|
chunk = responseText.substring(lastIndex)
|
||||||
|
|
Loading…
Reference in New Issue