修复GLM流式输出内容问题
This commit is contained in:
@@ -164,7 +164,7 @@ export class ChatGLM extends BaseModel {
|
||||
const prompt = history.pop()
|
||||
const url = ChatGLM.base + "/model/v1/open/engines/sse/chatGLM/chatGLM"
|
||||
return await axios.post(url, JSON.stringify({
|
||||
history, prompt, temperature: 1, top_p: 0.6, requestTaskNo: this.taskId
|
||||
history, prompt, temperature: 0.2, requestTaskNo: this.taskId
|
||||
}), {
|
||||
headers: this.headers,
|
||||
}).then(res => res?.body?.getReader());
|
||||
@@ -193,11 +193,9 @@ export class ChatGLM extends BaseModel {
|
||||
return;
|
||||
}
|
||||
const decode = new TextDecoder().decode(value)
|
||||
const contents = decode.split("event:finish")[0].split("\n")
|
||||
if (contents.length > 0) {
|
||||
console.log(contents)
|
||||
chat.msg = contents.filter(e => e.startsWith("data:") && e.trim() != "data:")?.map(e => e.replace(/data:/, '')).join("\n") || ""
|
||||
}
|
||||
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)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user