|
...
|
...
|
@@ -71,9 +71,10 @@ class ChatLogic extends BaseLogic |
|
|
|
$chunk = $stream->read(1);
|
|
|
|
$chunk = str_replace(chr(1), '', $chunk);
|
|
|
|
if ($chunk !== false) {
|
|
|
|
$aiResponse .= $chunk; // 累积完整的 AI 回复
|
|
|
|
$chunk = json_decode($chunk,true);
|
|
|
|
$aiResponse .= $chunk['text']; // 累积完整的 AI 回复
|
|
|
|
// 使用 en_sse_data 格式化流数据
|
|
|
|
echo $gptService->en_sse_data(trim($chunk));
|
|
|
|
echo $gptService->en_sse_data(trim($chunk['text']));
|
|
|
|
ob_flush();
|
|
|
|
flush();
|
|
|
|
}
|
...
|
...
|
|