Skip to content

Commit e302175

Browse files
liutChanzhaoyu
andauthored
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>
1 parent 1edf591 commit e302175

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/views/chat/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ async function onConversation() {
115115
const xhr = event.target
116116
const { responseText } = xhr
117117
// Always process the final line
118-
const lastIndex = responseText.lastIndexOf('\n')
118+
const lastIndex = responseText.lastIndexOf('\n', responseText.length - 2)
119119
let chunk = responseText
120120
if (lastIndex !== -1)
121121
chunk = responseText.substring(lastIndex)
@@ -245,7 +245,7 @@ async function onRegenerate(index: number) {
245245
const xhr = event.target
246246
const { responseText } = xhr
247247
// Always process the final line
248-
const lastIndex = responseText.lastIndexOf('\n')
248+
const lastIndex = responseText.lastIndexOf('\n', responseText.length - 2)
249249
let chunk = responseText
250250
if (lastIndex !== -1)
251251
chunk = responseText.substring(lastIndex)

0 commit comments

Comments
 (0)