接入语音
This commit is contained in:
@@ -198,7 +198,7 @@ export class ChatGLM extends BaseModel {
|
||||
} else return Promise.reject("没有权限或者网络异常,请重新尝试!")
|
||||
}
|
||||
|
||||
streamOutput(reader, chat) {
|
||||
streamOutput(reader, chat, cb) {
|
||||
return reader.read().then(({done, value}) => {
|
||||
if (done) {
|
||||
return;
|
||||
@@ -206,8 +206,13 @@ export class ChatGLM extends BaseModel {
|
||||
const decode = new TextDecoder().decode(value)
|
||||
const dialogue = decode.split("event:").at(-1)
|
||||
const msg = dialogue.split("\n").filter(e => e.startsWith("data:"))?.map(e => e.replace("data:", '')).join("\n")
|
||||
if (msg?.length > 0) chat.msg = msg
|
||||
return this.streamOutput(reader, chat)
|
||||
if (msg?.length > 0) {
|
||||
chat.msg = msg
|
||||
if (typeof cb == "function") {
|
||||
cb(msg)
|
||||
}
|
||||
}
|
||||
return this.streamOutput(reader, chat, cb)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user