Skip to content

Commit

Permalink
fix line end with new-line in some backend (Chanzhaoyu#474)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
2 people authored and jingChen55 committed Mar 27, 2023
1 parent 4a9cc7d commit 776dfe3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/views/chat/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 776dfe3

Please sign in to comment.