更改输出方式
This commit is contained in:
@@ -219,13 +219,12 @@ app.post("/v1/messages", apiKeyAuth, (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
console.log(chunk);
|
|
||||||
if (chunk.indexOf("event: youChatToken\n") != -1) {
|
if (chunk.indexOf("event: youChatToken\n") != -1) {
|
||||||
chunk.split("\n").forEach((line) => {
|
chunk.split("\n").forEach((line) => {
|
||||||
if (line.startsWith(`data: {"youChatToken"`)) {
|
if (line.startsWith(`data: {"youChatToken"`)) {
|
||||||
let data = line.substring(6);
|
let data = line.substring(6);
|
||||||
let json = JSON.parse(data);
|
let json = JSON.parse(data);
|
||||||
//console.log(json);
|
process.stdout.write(json.youChatToken);
|
||||||
chunkJSON = JSON.stringify({
|
chunkJSON = JSON.stringify({
|
||||||
type: "content_block_delta",
|
type: "content_block_delta",
|
||||||
index: 0,
|
index: 0,
|
||||||
@@ -234,6 +233,8 @@ app.post("/v1/messages", apiKeyAuth, (req, res) => {
|
|||||||
res.write(createEvent("content_block_delta", chunkJSON));
|
res.write(createEvent("content_block_delta", chunkJSON));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}else{
|
||||||
|
console.log(chunk);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
|
|||||||
Reference in New Issue
Block a user