option('model') || !$this->option('channel') ) { $this->error('model,article,channel is requested'); return; } // // ===== 创建 Service ===== $service = app(ArticleTranslateService::class); $articleService = app(ArticleService::class); // ===== 执行 ===== if ($this->option('article')) { $this->info('article translate start'); $total = $service->setModel($this->option('model')) ->setChannel($this->option('channel')) ->translateArticle($this->option('article')) ->saveRpc($this->option('endpoint'), $this->option('token')); $this->info("{$total} sentences saved"); } if ($this->option('anthology')) { $this->info('anthology translate start'); $articleIds = $articleService->articlesInAnthology($this->option('anthology')); foreach ($articleIds as $article) { $this->info('article translate start'); $total = $service->setModel($this->option('model')) ->setChannel($this->option('channel')) ->translateArticle($article) ->saveRpc($this->option('endpoint'), $this->option('token')); $this->info("{$total} sentences saved"); } $this->info(count($articleIds) . " article saved"); } } }