Add AI usage logs for Gemini and Whisper
- Migration + AiUsageLog model with tokens, duration, time, cost fields - GeminiIntentService and GeminiVisionService log every API call with input/output token counts from usageMetadata and response time - TelegramBotService logs Whisper calls with audio duration (from Telegram) and calculates cost at $1/second - Whisper voice duration now passed from TelegramWebhookController - Free text in Telegram now tries Gemini intent detection before showing menu - /chat/ia-logs: Livewire component with summary cards + filterable table - Whisper connection test button in config panel - "Logs IA" link added to Chat/Bot nav section Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
ff109a5608
commit
44297aa0bb
Regular → Executable
+24
@@ -16,6 +16,7 @@ class ShowConfiguracionChat extends Component
|
||||
public string $mensaje_bienvenida = '';
|
||||
public string $mensaje_transferencia = '';
|
||||
public string $webhookResult = '';
|
||||
public string $whisperResult = '';
|
||||
|
||||
// ── Gemini IA ─────────────────────────────────────────────
|
||||
public string $gemini_api_key = '';
|
||||
@@ -85,6 +86,29 @@ class ShowConfiguracionChat extends Component
|
||||
$this->alert('success', 'Configuracion guardada correctamente.');
|
||||
}
|
||||
|
||||
public function resetearWhisper(): void
|
||||
{
|
||||
$url = trim($this->whisper_url ?: ChatConfig::get('whisper_url'));
|
||||
$token = trim($this->whisper_token ?: ChatConfig::get('whisper_token'));
|
||||
|
||||
if (! $url) {
|
||||
$this->whisperResult = '⚠️ La URL de Whisper está vacía.';
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$response = Http::timeout(10)
|
||||
->withBasicAuth('whisper', $token)
|
||||
->get(rtrim($url, '/asr')); // ping al servidor
|
||||
|
||||
$this->whisperResult = $response->successful()
|
||||
? '✅ Conexión con Whisper establecida correctamente.'
|
||||
: '❌ Whisper respondió con error ' . $response->status() . '.';
|
||||
} catch (\Throwable $e) {
|
||||
$this->whisperResult = '❌ No se pudo conectar con Whisper: ' . $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
public function registrarWebhook(): void
|
||||
{
|
||||
$token = trim($this->telegram_token);
|
||||
|
||||
Reference in New Issue
Block a user