diff --git a/wp-content/plugins/automatic-ai-posts/src/Modules/Ai/AiService.php b/wp-content/plugins/automatic-ai-posts/src/Modules/Ai/AiService.php index a69f3aa..0552d19 100644 --- a/wp-content/plugins/automatic-ai-posts/src/Modules/Ai/AiService.php +++ b/wp-content/plugins/automatic-ai-posts/src/Modules/Ai/AiService.php @@ -86,7 +86,7 @@ final class AiService { } $prompt = PromptLibrary::select_topics($articles, $min, $max, $recent_titles); - $raw = $this->ask($prompt, 'topic selection', 2048, 0.2); + $raw = $this->ask($prompt, 'topic selection', 8192, 0.2); if ($raw === null) { return []; @@ -117,7 +117,7 @@ final class AiService { */ public function rewrite(array $article, string $language): ?array { $prompt = PromptLibrary::rewrite($article, $language); - $raw = $this->ask($prompt, 'article rewrite', 8192, 0.8); + $raw = $this->ask($prompt, 'article rewrite', 16384, 0.8); if ($raw === null) { return null; @@ -148,7 +148,7 @@ final class AiService { } $prompt = PromptLibrary::choose_category($title, $content, $categories, $language); - $raw = $this->ask($prompt, 'category choice', 2048, 0.2); + $raw = $this->ask($prompt, 'category choice', 8192, 0.2); if ($raw === null) { return 0; @@ -182,7 +182,7 @@ final class AiService { */ public function image_plan(string $title, string $content, string $language): ?array { $prompt = PromptLibrary::image_plan($title, $content, $language); - $raw = $this->ask($prompt, 'image plan', 4000, 0.7); + $raw = $this->ask($prompt, 'image plan', 8192, 0.7); if ($raw === null) { return null; @@ -205,7 +205,14 @@ final class AiService { ]; } - /** Calls the provider with retries. Returns null when every attempt failed. */ + /** + * Calls the provider with retries. Returns null when every attempt failed. + * + * Budgets are generous on purpose: reasoning models (e.g. Nemotron on + * NVIDIA Build) spend tokens on reasoning_content before answering, and an + * exhausted budget returns empty content with finish_reason "length". + * max_tokens is only a cap — the cost is per generated token. + */ private function ask(string $prompt, string $label, int $max_tokens, float $temperature): ?string { if (!$this->provider) { Logger::error('No AI provider configured.', 'ai');