LLM refine: 2dp prompt, mixed 64/32 frames, full proxy log, low reasoning

- spec.js: round all songSpec + extended summary/tempo/normalization to
  r2 (2dp) so high-precision 0.6607… stops wasting tokens; hoist r2/r3
  above specForPrompt to fix ReferenceError; FULL control wording kept.
- thumbs.js: border detection — first/last + 0.5s of any section start
  → 64×64 (borders), interior → 32×32 (between). Back-compat shim for
  old {size:N} callers. Returns size+role per frame for attachFrames.
- vite.config.js: raise sanitizeBodyForLog to 64k for __llm so 8×
  vision frames aren't truncated (was 16384, only 2 images logged).
  Also log reasoningEffort via providerOptions.
- llmTweak.js: set providerOptions reasoningEffort:'low' for both
  streamObject and generateObject fallback to cut 2459 → faster
  streaming progress, temperature 0.7 kept for variety.

Verification: build+lint:scenes green, tests 18/18.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Dejvino
2026-09-13 22:21:09 +02:00
co-authored by Claude
parent b0989169e2
commit 49914fd4ad
4 changed files with 66 additions and 30 deletions
+7 -6
View File
@@ -118,19 +118,20 @@ function llmGatewayProxy() {
}
function sanitizeBodyForLog(ct, raw) {
// Don't log if content-type is missing or body is binary
// Allow __llm JSON (which includes images) to be larger — spec asked
// for full logging. 64k keeps 8× images plus schema without truncation.
const limit = 65536;
if (!ct || !ct.includes('json')) {
if (raw && raw.length > 4096) return `[${ct || 'unknown'} body ${raw.length} bytes, not logged]`;
try { return raw ? raw.toString('utf8').slice(0, 4096) : ''; } catch { return '[unprintable]'; }
if (raw && raw.length > limit) return `[${ct || 'unknown'} body ${raw.length} bytes, not logged]`;
try { return raw ? raw.toString('utf8').slice(0, limit) : ''; } catch { return '[unprintable]'; }
}
try {
const text = raw ? raw.toString('utf8') : '';
const parsed = JSON.parse(text);
// Redact sensitive keys if they somehow appear in JSON body
const redacted = redactJsonForLog(parsed);
return JSON.stringify(redacted).slice(0, 16384);
return JSON.stringify(redacted).slice(0, limit);
} catch {
return raw ? raw.toString('utf8').slice(0, 4096) : '';
return raw ? raw.toString('utf8').slice(0, limit) : '';
}
}