chore(addon/aikefu): 优化最后关闭sse的处理,刷新输出

This commit is contained in:
2025-12-10 18:13:00 +08:00
parent 3cafaae451
commit c63fce1ce8

View File

@@ -749,6 +749,11 @@ class Kefu extends BaseApi
'content' => $assistant_content,
];
echo "event: done\ndata: " . json_encode($done_data) . "\n\n";
// 只在有输出缓冲时才刷新
if (ob_get_level() > 0) {
ob_flush();
}
flush();
// 发送连接关闭事件,让客户端知道连接已正常结束
echo "event: close\ndata: {\"status\":\"completed\"}\n\n";