fix: version 4.0.5 -- Propuestas de IA grandes ya no quedan cortadas
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -40,7 +40,9 @@ export async function askStructured({ system, prompt, toolName, schema, maxToken
|
||||
throw new HttpError(502, `Servicio de IA: ${detail}`);
|
||||
}
|
||||
// Consumo real de cada llamada (para estimar costos: ver precios del modelo en la consola).
|
||||
console.log(`[ai] ${config.model} tokens entrada=${body?.usage?.input_tokens} salida=${body?.usage?.output_tokens}`);
|
||||
console.log(`[ai] ${config.model} tokens entrada=${body?.usage?.input_tokens} salida=${body?.usage?.output_tokens} fin=${body?.stop_reason}`);
|
||||
// Respuesta cortada por el tope de tokens: el JSON de la herramienta llega incompleto.
|
||||
if (body?.stop_reason === 'max_tokens') throw new HttpError(502, 'La respuesta de la IA fue demasiado larga y quedo incompleta. Intenta con un objetivo mas acotado.');
|
||||
const tool = body?.content?.find((c) => c.type === 'tool_use');
|
||||
if (!tool?.input) throw new HttpError(502, 'La IA no devolvio un resultado valido');
|
||||
return tool.input;
|
||||
|
||||
Reference in New Issue
Block a user