|
...
|
...
|
@@ -66,15 +66,15 @@ class ChatLogic extends BaseLogic |
|
|
|
header('Content-Type: text/event-stream');
|
|
|
|
header('Cache-Control: no-cache');
|
|
|
|
header('Connection: keep-alive');
|
|
|
|
while (!feof($stream)) {
|
|
|
|
$chunk = fread($stream, 1024);
|
|
|
|
while (!$stream->eof()) {
|
|
|
|
$chunk = $stream->read(1024);
|
|
|
|
if ($chunk !== false) {
|
|
|
|
echo "data: " . trim($chunk) . "\n\n";
|
|
|
|
// 使用 en_sse_data 格式化流数据
|
|
|
|
echo $gptService->en_sse_data(trim($chunk));
|
|
|
|
ob_flush();
|
|
|
|
flush();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose($stream);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
...
|
...
|
|