From 6170666ff3f5c90816814dd8346798974a9e2590 Mon Sep 17 00:00:00 2001 From: Jie Ma Date: Wed, 4 Feb 2026 13:42:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9F=90=E4=BA=9B=E5=AE=A2?= =?UTF-8?q?=E6=88=B7=E7=AB=AF=E6=B2=A1=E6=9C=89=E6=8E=A5=E6=94=B6=E5=88=B0?= =?UTF-8?q?=E6=B5=81=E7=BB=93=E6=9D=9F=E4=BF=A1=E6=81=AF=E5=90=8E=E7=9A=84?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/common.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/utils/common.js b/src/utils/common.js index 4d65d28..ccbde75 100644 --- a/src/utils/common.js +++ b/src/utils/common.js @@ -491,6 +491,17 @@ export async function handleStreamRequest(res, service, model, requestBody, from responseClosed = true; } finally { if (!responseClosed) { + // 根据客户端协议发送相应的流式结束标记 + const clientProtocol = getProtocolPrefix(fromProvider); + if (clientProtocol === MODEL_PROTOCOL_PREFIX.OPENAI) { + res.write('data: [DONE]\n\n'); + } else if (clientProtocol === MODEL_PROTOCOL_PREFIX.OPENAI_RESPONSES) { + res.write('event: done\n'); + res.write('data: {}\n\n'); + } else if (clientProtocol === MODEL_PROTOCOL_PREFIX.CLAUDE) { + res.write('event: message_stop\n'); + res.write('data: {"type":"message_stop"}\n\n'); + } res.end(); } await logConversation('output', fullResponseText, PROMPT_LOG_MODE, PROMPT_LOG_FILENAME);