lh hace 3 meses
padre
commit
76296160f5
Se han modificado 1 ficheros con 10 adiciones y 0 borrados
  1. 10 0
      app/Services/DeepSeek/DeepSeekService.php

+ 10 - 0
app/Services/DeepSeek/DeepSeekService.php

@@ -2428,6 +2428,11 @@ class DeepSeekService
         }
         }
 
 
         // 处理流式输出
         // 处理流式输出
+        if (!is_iterable($streamGenerator)) {
+            dLog('deepseek')->error('addChat流式生成器无效', ['generator_type' => gettype($streamGenerator)]);
+            Utils::throwError('20003:接口返回数据异常,请重新请求');
+        }
+        
         foreach ($streamGenerator as $chunk) {
         foreach ($streamGenerator as $chunk) {
             if (isset($chunk['type'])) {
             if (isset($chunk['type'])) {
                 if ($chunk['type'] === 'done') {
                 if ($chunk['type'] === 'done') {
@@ -3272,6 +3277,11 @@ class DeepSeekService
         }
         }
 
 
         // 处理流式输出
         // 处理流式输出
+        if (!is_iterable($streamGenerator)) {
+            dLog('deepseek')->error('chat流式生成器无效', ['generator_type' => gettype($streamGenerator)]);
+            Utils::throwError('20003:接口返回数据异常,请重新请求');
+        }
+        
         foreach ($streamGenerator as $chunk) {
         foreach ($streamGenerator as $chunk) {
             if (isset($chunk['type'])) {
             if (isset($chunk['type'])) {
                 if ($chunk['type'] === 'done') {
                 if ($chunk['type'] === 'done') {