|
|
@@ -280,51 +280,6 @@ class DeepSeekController extends BaseController
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 测试流式输出(简化版本)
|
|
|
- */
|
|
|
- public function testStream(Request $request) {
|
|
|
- return response()->stream(function () {
|
|
|
- // 禁用所有输出缓冲
|
|
|
- if (ob_get_level()) {
|
|
|
- ob_end_clean();
|
|
|
- }
|
|
|
-
|
|
|
- ini_set('output_buffering', 'off');
|
|
|
- ini_set('zlib.output_compression', 'off');
|
|
|
-
|
|
|
- // 发送测试数据
|
|
|
- for ($i = 1; $i <= 5; $i++) {
|
|
|
- $data = [
|
|
|
- 'type' => 'content',
|
|
|
- 'content' => "测试消息 #{$i}\n",
|
|
|
- 'full_content' => "累积内容到第 {$i} 条\n"
|
|
|
- ];
|
|
|
-
|
|
|
- echo "data: " . json_encode($data, JSON_UNESCAPED_UNICODE) . "\n\n";
|
|
|
-
|
|
|
- if (ob_get_level() > 0) {
|
|
|
- ob_flush();
|
|
|
- }
|
|
|
- flush();
|
|
|
-
|
|
|
- sleep(1); // 每秒发送一条
|
|
|
- }
|
|
|
-
|
|
|
- // 发送结束标记
|
|
|
- echo "data: [DONE]\n\n";
|
|
|
- if (ob_get_level() > 0) {
|
|
|
- ob_flush();
|
|
|
- }
|
|
|
- flush();
|
|
|
- }, 200, [
|
|
|
- 'Content-Type' => 'text/event-stream',
|
|
|
- 'Cache-Control' => 'no-cache',
|
|
|
- 'Connection' => 'keep-alive',
|
|
|
- 'X-Accel-Buffering' => 'no'
|
|
|
- ]);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
* 与DeepSeek对话(带文件上传 - 流式输出版本)
|
|
|
* @param Request $request
|
|
|
* @return \Symfony\Component\HttpFoundation\StreamedResponse
|