automatic-ai-posts: raise max_tokens for reasoning models (NVIDIA Build)
Nemotron spends the token budget on reasoning_content before answering; a 2048 budget was exhausted by ~7761 reasoning chars, returning empty content with finish_reason=length. Topic selection and category choice go 2048 -> 8192, image plan 4000 -> 8192, article rewrite 8192 -> 16384. max_tokens is only a cap, so concise answers cost the same as before.
This commit is contained in:
1 parent
dc50c99dd9
commit
0bb30696de
1 file changed
+12
-5
@@ -86,7 +86,7 @@ final class AiService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$prompt = PromptLibrary::select_topics($articles, $min, $max, $recent_titles);
|
$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) {
|
if ($raw === null) {
|
||||||
return [];
|
return [];
|
||||||
@@ -117,7 +117,7 @@ final class AiService {
|
|||||||
*/
|
*/
|
||||||
public function rewrite(array $article, string $language): ?array {
|
public function rewrite(array $article, string $language): ?array {
|
||||||
$prompt = PromptLibrary::rewrite($article, $language);
|
$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) {
|
if ($raw === null) {
|
||||||
return null;
|
return null;
|
||||||
@@ -148,7 +148,7 @@ final class AiService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$prompt = PromptLibrary::choose_category($title, $content, $categories, $language);
|
$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) {
|
if ($raw === null) {
|
||||||
return 0;
|
return 0;
|
||||||
@@ -182,7 +182,7 @@ final class AiService {
|
|||||||
*/
|
*/
|
||||||
public function image_plan(string $title, string $content, string $language): ?array {
|
public function image_plan(string $title, string $content, string $language): ?array {
|
||||||
$prompt = PromptLibrary::image_plan($title, $content, $language);
|
$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) {
|
if ($raw === null) {
|
||||||
return 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 {
|
private function ask(string $prompt, string $label, int $max_tokens, float $temperature): ?string {
|
||||||
if (!$this->provider) {
|
if (!$this->provider) {
|
||||||
Logger::error('No AI provider configured.', 'ai');
|
Logger::error('No AI provider configured.', 'ai');
|
||||||
|
|||||||
Reference in new issue
Block a user