Просмотр исходного кода

1.调整提示词前后顺序尽量保证命中大模型缓存2.优化解析分段剧本公共方法

lh 1 месяц назад
Родитель
Сommit
7a3b6173f1
2 измененных файлов с 220 добавлено и 11 удалено
  1. 6 6
      app/Libs/Helpers.php
  2. 214 5
      app/Services/DeepSeek/DeepSeekService.php

+ 6 - 6
app/Libs/Helpers.php

@@ -3439,7 +3439,8 @@ function handleEpisodeContentForAce($originalContent) {
     }
     
     // 提取主体列表 - 兼容多种格式
-    if (preg_match('/###\s*主体列表\s*\n(.*?)(?=\n\s*###[^#]|\z)/s', $originalContent, $charactersMatch)) {
+    // if (preg_match('/###\s*主体列表\s*\n(.*?)(?=\n\s*###[^#]|\z)/s', $originalContent, $charactersMatch)) {
+    if (preg_match('/###[ \t]*主体列表[ \t]*\r?\n(.*?)(?=###[^#\n]|\z)/s', $originalContent, $charactersMatch)) {
         $charactersText = trim($charactersMatch[1]);
         $characterLines = explode("\n", $charactersText);
         
@@ -3550,7 +3551,8 @@ function handleEpisodeContentForAce($originalContent) {
     }
     
     // 提取场景列表 - 兼容多种格式
-    if (preg_match('/###\s*场景列表\s*\n(.*?)(?=\n\s*###[^#]|\z)/s', $originalContent, $scenesMatch)) {
+    // if (preg_match('/###\s*场景列表\s*\n(.*?)(?=\n\s*###[^#]|\z)/s', $originalContent, $scenesMatch)) {
+    if (preg_match('/###[ \t]*场景列表[ \t]*\r?\n(.*?)(?=###[^#\n]|\z)/s', $originalContent, $scenesMatch)) {
         $scenesText = trim($scenesMatch[1]);
         $sceneLines = explode("\n", $scenesText);
         
@@ -3587,7 +3589,7 @@ function handleEpisodeContentForAce($originalContent) {
     }
     
     // 提取道具列表 - 兼容多种格式
-    if (preg_match('/###\s*道具列表\s*\n(.*?)(?=\n\s*###[^#]|\z)/s', $originalContent, $propsMatch)) {
+    if (preg_match('/###[ \t]*道具列表[ \t]*\r?\n(.*?)(?=###[^#\n]|\z)/s', $originalContent, $propsMatch)) {
         $propsText = trim($propsMatch[1]);
         $propLines = explode("\n", $propsText);
         
@@ -3613,12 +3615,10 @@ function handleEpisodeContentForAce($originalContent) {
                     'description' => $description
                 ];
                 
-                // 如果有道具图片提示词,添加到数组中
                 if ($picPrompt) {
                     $propData['pic_prompt'] = $picPrompt;
+                    $result['props'][] = $propData;
                 }
-                
-                $result['props'][] = $propData;
             }
         }
     }

Разница между файлами не показана из-за своего большого размера
+ 214 - 5
app/Services/DeepSeek/DeepSeekService.php