feat: costo OCR en dashboard, logs correctos y fix de thinking tokens
- OcrExtractionService: registra cada llamada en ai_usage_logs (servicio=ocr, costo=5 COP/foto) y ahora tambien loggea cuando SI funciona, no solo cuando falla (antes era imposible confirmar por log que el OCR corrio). - GeminiVisionService: el log decia siempre "[Gemini Vision]" sin importar si la llamada fue de imagen o de texto post-OCR, haciendo imposible distinguir cual camino se uso realmente. Ahora usa el servicio real. - GeminiVisionService: agrega thinkingConfig.thinkingBudget=0 (igual que GeminiIntentService) para que el modelo no gaste tokens narrando su razonamiento en texto plano antes del JSON final -- se estaba colando ese razonamiento en la respuesta y comiendose el presupuesto de tokens. - GeminiIntentService: resultado ya no queda forzado a 'ok'; ahora filtra bloques 'thought' igual que vision, y guarda tokens/raw en el detalle para poder diagnosticar sin acceso al servidor. - ShowAiLogs: card y filtro de costo OCR en el dashboard de consumo. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
7b21cd9773
commit
5e0c0367d9
@@ -58,6 +58,7 @@ class GeminiVisionService
|
||||
'generationConfig' => [
|
||||
'temperature' => 0.1,
|
||||
'maxOutputTokens' => 2048,
|
||||
'thinkingConfig' => ['thinkingBudget' => 0],
|
||||
],
|
||||
];
|
||||
|
||||
@@ -85,7 +86,7 @@ class GeminiVisionService
|
||||
$tiempoMs = (int) ((microtime(true) - $inicio) * 1000);
|
||||
|
||||
if (! $response) {
|
||||
Log::warning('[Gemini Vision] API failed: ' . $lastError);
|
||||
Log::warning("[Gemini {$servicio}] API failed: " . $lastError);
|
||||
AiUsageLog::registrar([
|
||||
'servicio' => $servicio,
|
||||
'canal' => $canal,
|
||||
@@ -108,7 +109,7 @@ class GeminiVisionService
|
||||
'text'
|
||||
));
|
||||
|
||||
Log::info('[Gemini Vision] raw response: ' . substr($text, 0, 500));
|
||||
Log::info("[Gemini {$servicio}] raw response: " . substr($text, 0, 500));
|
||||
|
||||
$resultado = $this->parseRespuesta($text);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user