fix(ai): adaptive max_tokens per backend (reasoning profiles get 1024+, native llama.cpp stays compact; per-profile max_tokens override); include entry texts in ai_status SSE notify so journal updates live without reload; audit log action filter; links pagination; settings validation & UI improvements

This commit is contained in:
dev
2026-09-17 14:12:36 +03:00
parent a93e37a6b1
commit 57e48a9d4f
12 changed files with 676 additions and 211 deletions
+4 -1
View File
@@ -96,15 +96,18 @@ function createEntryAutoChecker({ pool, getSetting, logAudit, aiUrl, defaultProm
const headers = { 'Content-Type': 'application/json' };
let url;
let model;
let maxTokens;
if (profile) {
const base = normalizeOpenAiBase(profile.base_url);
if (!base) throw new Error('Некорректный base_url профиля ИИ');
url = `${base}/chat/completions`;
model = profile.model;
if (profile.api_key) headers.Authorization = `Bearer ${profile.api_key}`;
maxTokens = parseInt(profile.max_tokens, 10) || Math.min(4096, Math.max(1024, text.length * 2 + 512));
} else {
url = `${AI_URL.replace(/\/+$/, '')}/v1/chat/completions`;
model = MODEL;
maxTokens = Math.min(256, Math.max(128, text.length + 64));
}
const controller = new AbortController();
const timer = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
@@ -120,7 +123,7 @@ function createEntryAutoChecker({ pool, getSetting, logAudit, aiUrl, defaultProm
{ role: 'user', content: text },
],
temperature: 0.1,
max_tokens: Math.min(512, Math.max(64, text.length + 32)),
max_tokens: maxTokens,
}),
});
if (!res.ok) throw new Error(`AI service error: ${res.status}`);