perf: 优化AI回答 #132 (#155)

This commit is contained in:
shaohuzhang1 2024-04-18 15:01:54 +08:00 committed by GitHub
parent 1a291997f3
commit d214e31f71
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -51,19 +51,23 @@ export class ChatRecordManage {
this.loading.value = true
}
this.id = setInterval(() => {
const s = this.chat.buffer.shift()
if (s !== undefined) {
this.chat.answer_text = this.chat.answer_text + s
if (this.chat.buffer.length > 20) {
this.chat.answer_text =
this.chat.answer_text + this.chat.buffer.splice(0, this.chat.buffer.length - 20).join('')
} else if (this.is_close) {
this.chat.answer_text = this.chat.answer_text + this.chat.buffer.join('')
this.chat.write_ed = true
this.write_ed = true
if (this.loading) {
this.loading.value = false
}
if (this.id) {
clearInterval(this.id)
}
} else {
if (this.is_close) {
this.chat.write_ed = true
this.write_ed = true
if (this.loading) {
this.loading.value = false
}
if (this.id) {
clearInterval(this.id)
}
const s = this.chat.buffer.shift()
if (s !== undefined) {
this.chat.answer_text = this.chat.answer_text + s
}
}
}, this.ms)