更改输出方式

This commit is contained in:
Archeb
2024-05-15 13:24:44 +08:00
committed by 蚊子
parent 2224bf0059
commit 1e9ec66c70
+3 -2
View File
@@ -219,13 +219,12 @@ app.post("/v1/messages", apiKeyAuth, (req, res) => {
}
try {
console.log(chunk);
if (chunk.indexOf("event: youChatToken\n") != -1) {
chunk.split("\n").forEach((line) => {
if (line.startsWith(`data: {"youChatToken"`)) {
let data = line.substring(6);
let json = JSON.parse(data);
//console.log(json);
process.stdout.write(json.youChatToken);
chunkJSON = JSON.stringify({
type: "content_block_delta",
index: 0,
@@ -234,6 +233,8 @@ app.post("/v1/messages", apiKeyAuth, (req, res) => {
res.write(createEvent("content_block_delta", chunkJSON));
}
});
}else{
console.log(chunk);
}
} catch (e) {
console.log(e);