浏览代码

add count of $sentences

visuddhinanda 6 天之前
父节点
当前提交
f75e6db309

+ 2 - 2
api-v12/app/Console/Commands/TestAIArticleTranslate.php

@@ -49,8 +49,8 @@ class TestAIArticleTranslate extends Command
             $this->info('anthology translate start');
             $this->info('anthology translate start');
             $total = $service->setModel($this->option('model'))
             $total = $service->setModel($this->option('model'))
                 ->setChannel($this->option('channel'))
                 ->setChannel($this->option('channel'))
-                ->translateAnthology($this->option('anthology'), function ($article) {
-                    $this->info('translating article ' . $article);
+                ->translateAnthology($this->option('anthology'), function ($article, $sentences) {
+                    $this->info("translate article {$article} sentences {$sentences}");
                 });
                 });
             $this->info("{$total} article saved");
             $this->info("{$total} article saved");
         }
         }

+ 2 - 2
api-v12/app/Services/AIAssistant/ArticleTranslateService.php

@@ -87,10 +87,10 @@ class ArticleTranslateService
         $articles = $this->articleService->articlesInAnthology($anthologyId);
         $articles = $this->articleService->articlesInAnthology($anthologyId);
 
 
         foreach ($articles as $article) {
         foreach ($articles as $article) {
+            $sentences = $this->translateArticle($article)->save();
             if ($fn) {
             if ($fn) {
-                $fn($article);
+                $fn($article, $sentences);
             }
             }
-            $this->translateArticle($article)->save();
         }
         }
 
 
         return count($articles);
         return count($articles);