Benchmark: käytä thinking-kenttää fallbackina jos content tyhjä

qwen3.5 palauttaa vastauksen thinking-kentässä kun content on tyhjä.
Lisätty debug-logi thinking-malleille.
This commit is contained in:
2026-04-14 08:45:06 +03:00
parent 62c9b6e17e
commit 25b9ab0c37

View File

@@ -81,8 +81,10 @@ async function ollamaChat(model, prompt, systemPrompt, maxTokens = 2048) {
const elapsed = Date.now() - start;
// Ollama: jotkin mallit (qwen3.5) palauttavat ajattelun erillisessä thinking-kentässä
const rawContent = (data.message?.content || '').trim();
const text = stripThinking(rawContent);
const thinking = (data.message?.thinking || '').trim();
const text = stripThinking(rawContent || thinking);
const evalCount = data.eval_count || 0;
if (!rawContent && thinking) console.log(` ⚠ thinking-malli: ${thinking.length} merkkiä ajattelua, content tyhjä`);
const evalDurationNs = data.eval_duration || 1;
const tokPerSec = evalCount / (evalDurationNs / 1e9);
return { text, tokens: evalCount, durationMs: elapsed, tokPerSec };