Procházet zdrojové kódy

1.新增全能模式下的新建对话和调整大纲接口2.优化全能模式下上述接口的提示词

lh před 3 měsíci
rodič
revize
18ea905315

+ 148 - 0
app/Http/Controllers/DeepSeek/DeepSeekController.php

@@ -741,6 +741,154 @@ class DeepSeekController extends BaseController
         ]);
     }
 
+    // 新建对话
+    public function addChatForAce(Request $request) {
+        // 忽略所有超时限制
+        set_time_limit(0);
+        ini_set('max_execution_time', '0');
+
+
+        $data = $request->all();
+        return response()->stream(function () use ($data) {
+            // 禁用所有输出缓冲
+            if (ob_get_level()) {
+                ob_end_clean();
+            }
+            
+            // 设置输出缓冲为关闭
+            ini_set('output_buffering', 'off');
+            ini_set('zlib.output_compression', 'off');
+            
+            // 立即刷新
+            if (function_exists('apache_setenv')) {
+                apache_setenv('no-gzip', '1');
+            }
+
+            try {
+                $generator = $this->deepseekService->addChatForAce($data);
+                
+                foreach ($generator as $chunk) {
+                    // 发送 SSE 格式的数据
+                    $jsonData = json_encode($chunk, JSON_UNESCAPED_UNICODE);
+                    echo "data: {$jsonData}\n\n";
+                    
+                    // 强制刷新输出缓冲区
+                    if (ob_get_level() > 0) {
+                        ob_flush();
+                    }
+                    flush();
+                    
+                    // 检查客户端是否断开连接
+                    if (connection_aborted()) {
+                        break;
+                    }
+                }
+                
+                // 发送结束标记
+                echo "data: [DONE]\n\n";
+                if (ob_get_level() > 0) {
+                    ob_flush();
+                }
+                flush();
+                
+            } catch (\Exception $e) {
+                // 发送错误信息
+                $error = [
+                    'type' => 'error',
+                    'msg' => $e->getMessage(),
+                    'code' => $e->getCode()
+                ];
+                $jsonError = json_encode($error, JSON_UNESCAPED_UNICODE);
+                echo "data: {$jsonError}\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', // 防止 Nginx 缓冲
+            'Access-Control-Allow-Origin' => '*',
+            'Access-Control-Allow-Credentials' => 'true'
+        ]);
+    }
+
+    // 调整大纲
+    public function reGenerateAnimeForAce(Request $request) {
+        // 忽略所有超时限制
+        set_time_limit(0);
+        ini_set('max_execution_time', '0');
+
+
+        $data = $request->all();
+        return response()->stream(function () use ($data) {
+            // 禁用所有输出缓冲
+            if (ob_get_level()) {
+                ob_end_clean();
+            }
+            
+            // 设置输出缓冲为关闭
+            ini_set('output_buffering', 'off');
+            ini_set('zlib.output_compression', 'off');
+            
+            // 立即刷新
+            if (function_exists('apache_setenv')) {
+                apache_setenv('no-gzip', '1');
+            }
+
+            try {
+                $generator = $this->deepseekService->reGenerateAnimeForAce($data);
+                
+                foreach ($generator as $chunk) {
+                    // 发送 SSE 格式的数据
+                    $jsonData = json_encode($chunk, JSON_UNESCAPED_UNICODE);
+                    echo "data: {$jsonData}\n\n";
+                    
+                    // 强制刷新输出缓冲区
+                    if (ob_get_level() > 0) {
+                        ob_flush();
+                    }
+                    flush();
+                    
+                    // 检查客户端是否断开连接
+                    if (connection_aborted()) {
+                        break;
+                    }
+                }
+                
+                // 发送结束标记
+                echo "data: [DONE]\n\n";
+                if (ob_get_level() > 0) {
+                    ob_flush();
+                }
+                flush();
+                
+            } catch (\Exception $e) {
+                // 发送错误信息
+                $error = [
+                    'type' => 'error',
+                    'msg' => $e->getMessage(),
+                    'code' => $e->getCode()
+                ];
+                $jsonError = json_encode($error, JSON_UNESCAPED_UNICODE);
+                echo "data: {$jsonError}\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', // 防止 Nginx 缓冲
+            'Access-Control-Allow-Origin' => '*',
+            'Access-Control-Allow-Credentials' => 'true'
+        ]);
+    }
+
     public function chatForAce(Request $request) {
         // 忽略所有超时限制
         set_time_limit(0);

+ 0 - 1
app/Services/AIGeneration/AIVideoGenerationService.php

@@ -2389,7 +2389,6 @@ class AIVideoGenerationService
 
             $responseData = json_decode($response->getBody(), true);
             dLog('generate')->info('统一API任务状态查询响应: ', $responseData);
-            logDB('generate', 'info', '统一API任务状态查询', ['id' => $task->id, 'response' => $responseData]);
 
             // 检查响应code
             if (!isset($responseData['code']) || $responseData['code'] !== 0) {

+ 12 - 0
app/Services/Anime/AnimeService.php

@@ -202,6 +202,12 @@ class AnimeService
         $bid = getProp($data, 'bid', 0);
         $script_id = getProp($data, 'script_id', 0);
         $ace_mode = getProp($data, 'ace_mode', 0);
+        $extra_products = getProp($data, 'products', []);
+        if (is_string($extra_products)) $extra_products = json_decode($extra_products, true);
+        if (!is_array($extra_products)) {
+            Utils::throwError('20003:传入的资产格式不正确');
+        }
+        
         // 替换美术风格
         $mappedArtStyle = $this->DeepSeekService->getArtStylePromptByInput($input_art_style);
 
@@ -233,6 +239,7 @@ class AnimeService
             'is_multi'      => getProp($data, 'is_multi', 1),
             'content'       => $content,
             'ace_mode'      => $ace_mode,
+            'extra_products'    => json_encode($extra_products, 256),
             'created_at'    => date('Y-m-d H:i:s'),
             'updated_at'    => date('Y-m-d H:i:s'),
         ];
@@ -5534,6 +5541,8 @@ class AnimeService
         $cpid = Site::getCpid();
         $product_name = trim(getProp($data, 'product_name'));
         if (!$product_name) Utils::throwError('20003:名称不能为空');
+        $exists_id = DB::table('mp_products')->where('cpid', $cpid)->where('type', 1)->where('product_name', $product_name)->where('is_deleted', 0)->value('id');
+        if ($exists_id) Utils::throwError('20003:名称不能重复,请修改');
         $url = trim(getProp($data, 'url'));
         if (!$url) Utils::throwError('20003:图片地址不能为空');
         $versions = getProp($data, 'versions');
@@ -5626,6 +5635,9 @@ class AnimeService
         if ($product_name) {
             $updateData['product_name'] = $product_name;
         }
+
+        $exists_id = DB::table('mp_products')->where('cpid', $cpid)->where('type', 1)->where('product_name', $product_name)->where('is_deleted', 0)->value('id');
+        if ($exists_id && $exists_id != $id) Utils::throwError('20003:名称不能重复,请修改');
         
         // 图片地址
         $url = trim(getProp($data, 'url'));

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1606 - 0
app/Services/DeepSeek/DeepSeekService.php


+ 5 - 3
routes/api.php

@@ -156,7 +156,6 @@ Route::group(['middleware' => ['bindToken', 'bindExportToken', 'checkLogin']], f
             Route::get('chatList', [AnimeController::class, 'chatList']);                           // 动漫列表
             Route::get('chatHistory', [AnimeController::class, 'chatHistory']);                     // 动漫对话历史
             Route::post('chat', [DeepSeekController::class, 'chat']);                               // 动漫对话
-            Route::post('chatForAce', [DeepSeekController::class, 'chatForAce']);                   // 动漫对话(全能模式)
             Route::get('detail', [AnimeController::class, 'animeDetail']);                          // 动漫大纲
             Route::get('episodeInfo', [AnimeController::class, 'episodeInfo']);                     // 动漫剧集
             Route::get('episodeInfoForAce', [AnimeController::class, 'episodeInfoForAce']);         // 动漫剧集(全能模式)
@@ -191,9 +190,12 @@ Route::group(['middleware' => ['bindToken', 'bindExportToken', 'checkLogin']], f
             Route::post('applyAudioData', [AnimeController::class, 'applyAudioData']);                  // 修改分镜音频参数
             Route::post('previewAudio', [AnimeController::class, 'previewAudio']);                      // 音频试听
             Route::get('episodePicsInfo', [AnimeController::class, 'episodePicsInfo']);                 // 获取主体和场景图片生成信息
-            Route::get('clipSegmentVideo', [AnimeController::class, 'clipSegmentVideo']);                       // 裁剪视频
+            Route::get('clipSegmentVideo', [AnimeController::class, 'clipSegmentVideo']);               // 裁剪视频
+            Route::post('addChatForAce', [DeepSeekController::class, 'addChatForAce']);                 // 新增动漫对话
+            Route::post('reGenerateAnimeForAce', [DeepSeekController::class, 'reGenerateAnimeForAce']); // 调整动漫大纲
+            Route::post('chatForAce', [DeepSeekController::class, 'chatForAce']);                       // 动漫对话(全能模式)
             Route::get('actChatHistory', [AnimeController::class, 'actChatHistory']);                   // 片段对话历史记录
-            Route::get('confirmActs', [AnimeController::class, 'confirmActs']);                        // 确认片段分镜
+            Route::get('confirmActs', [AnimeController::class, 'confirmActs']);                         // 确认片段分镜
             Route::post('createActVideoTask', [AnimeController::class, 'createActVideoTask']);          // 片段转视频
             Route::post('batchSetActVideos', [AnimeController::class, 'batchSetActVideos']);            // 片段一键转视频