lh 3 месяцев назад
Родитель
Сommit
76296160f5
1 измененных файлов с 10 добавлено и 0 удалено
  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) {
             if (isset($chunk['type'])) {
                 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) {
             if (isset($chunk['type'])) {
                 if ($chunk['type'] === 'done') {