This commit is contained in:
sirius422
2024-06-25 00:38:09 +08:00
parent 79078fccc1
commit 73bbf9e70c
+5 -5
View File
@@ -30,12 +30,12 @@ const modelMappping = {
"claude-2.0": "claude_2", "claude-2.0": "claude_2",
}; };
// import config.js // import config.mjs
try { try {
var { config } = await import("./config.mjs"); var { config } = await import("./config.mjs");
} catch (e) { } catch (e) {
console.error(e); console.error(e);
console.error("config.js 不存在或者有错误,请检查"); console.error("config.mjs 不存在或者有错误,请检查");
process.exit(1); process.exit(1);
} }
var provider = new YouProvider(config); var provider = new YouProvider(config);
@@ -122,7 +122,7 @@ app.post("/v1/messages", apiKeyAuth, (req, res) => {
res.write(createEvent("ping", { type: "ping" })); res.write(createEvent("ping", { type: "ping" }));
} }
}); });
completion.on("completion", (id, text) => { completion.on("completion", (id, text) => {
if (jsonBody.stream) { if (jsonBody.stream) {
// send message delta // send message delta
@@ -162,7 +162,7 @@ app.post("/v1/messages", apiKeyAuth, (req, res) => {
res.end(); res.end();
} }
}); });
completion.on("end", () => { completion.on("end", () => {
if (jsonBody.stream) { if (jsonBody.stream) {
res.write(createEvent("content_block_stop", { type: "content_block_stop", index: 0 })); res.write(createEvent("content_block_stop", { type: "content_block_stop", index: 0 }));
@@ -177,7 +177,7 @@ app.post("/v1/messages", apiKeyAuth, (req, res) => {
res.end(); res.end();
} }
}); });
res.on("close", () => { res.on("close", () => {
console.log(" > [Client closed]"); console.log(" > [Client closed]");
completion.removeAllListeners(); completion.removeAllListeners();