作者 李宇航

合并分支 'lyh-server' 到 'master'

gx



查看合并请求 !1702
... ... @@ -69,12 +69,17 @@ class ChatLogic extends BaseLogic
while (!$stream->eof()) {
$chunk = $stream->read(1024);
if ($chunk !== false) {
$aiResponse .= $chunk; // 累积完整的 AI 回复
// 使用 en_sse_data 格式化流数据
echo $gptService->en_sse_data(trim($chunk));
ob_flush();
flush();
}
}
// 确保数据不是空的
if (!empty(trim($aiResponse)) && $chatId) {
$this->saveChatItem($chatId, trim($aiResponse), 1); // 存入数据库
}
return true;
}
... ...