mirror of
https://github.com/LLM-Red-Team/glm-free-api.git
synced 2024-11-11 04:49:25 +08:00
响应为json时将错误输出
This commit is contained in:
parent
26e1735795
commit
0dd4fa0d07
@ -215,12 +215,13 @@ async function createCompletion(
|
|||||||
responseType: "stream",
|
responseType: "stream",
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
if (result.headers["content-type"].indexOf("text/event-stream") == -1) {
|
||||||
if (result.headers["content-type"].indexOf("text/event-stream") == -1)
|
result.data.on("data", buffer => logger.error(buffer.toString()));
|
||||||
throw new APIException(
|
throw new APIException(
|
||||||
EX.API_REQUEST_FAILED,
|
EX.API_REQUEST_FAILED,
|
||||||
`Stream response Content-Type invalid: ${result.headers["content-type"]}`
|
`Stream response Content-Type invalid: ${result.headers["content-type"]}`
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const streamStartTime = util.timestamp();
|
const streamStartTime = util.timestamp();
|
||||||
// 接收流为输出文本
|
// 接收流为输出文本
|
||||||
@ -316,6 +317,7 @@ async function createCompletionStream(
|
|||||||
`Invalid response Content-Type:`,
|
`Invalid response Content-Type:`,
|
||||||
result.headers["content-type"]
|
result.headers["content-type"]
|
||||||
);
|
);
|
||||||
|
result.data.on("data", buffer => logger.error(buffer.toString()));
|
||||||
const transStream = new PassThrough();
|
const transStream = new PassThrough();
|
||||||
transStream.end(
|
transStream.end(
|
||||||
`data: ${JSON.stringify({
|
`data: ${JSON.stringify({
|
||||||
|
Loading…
Reference in New Issue
Block a user