fix: corrigido limite de max_tokens no classificador do OpenRouter

This commit is contained in:
2026-05-26 17:12:31 +00:00
parent 9c2ec032b1
commit 297c329923
+16 -5
View File
@@ -286,18 +286,29 @@ app.post('/api/chat', requireAuth, async (req, res) => {
{ role: 'system', content: systemDetector }, { role: 'system', content: systemDetector },
{ role: 'user', content: promptText } { role: 'user', content: promptText }
], ],
max_tokens: 5, max_tokens: 20,
temperature: 0.0 temperature: 0.0
}) })
}); });
if (detectResponse.ok) { if (detectResponse.ok) {
const detectData = await detectResponse.json(); const detectData = await detectResponse.json();
const detectedText = detectData.choices?.[0]?.message?.content?.trim() || 'TEXT'; const detectedText = detectData.choices?.[0]?.message?.content?.toUpperCase() || 'TEXT';
if (['TEXT', 'IMAGE', 'AUDIO', 'VIDEO'].includes(detectedText)) { console.log(`[Smart Router] Resposta crua do detector: "${detectedText}"`);
intent = detectedText;
console.log(`[Smart Router] Intenção detectada para o prompt "${promptText.substring(0, 40)}...": ${intent}`); if (detectedText.includes('IMAGE')) {
intent = 'IMAGE';
} else if (detectedText.includes('AUDIO') || detectedText.includes('MUSIC')) {
intent = 'AUDIO';
} else if (detectedText.includes('VIDEO')) {
intent = 'VIDEO';
} else {
intent = 'TEXT';
} }
console.log(`[Smart Router] Intenção detectada para o prompt "${promptText.substring(0, 40)}...": ${intent}`);
} else {
const errText = await detectResponse.text();
console.error('[Smart Router] Chamada de detecção retornou erro:', errText);
} }
} catch (err) { } catch (err) {
console.error('Erro no classificador de intenções (usando fallback TEXT):', err); console.error('Erro no classificador de intenções (usando fallback TEXT):', err);