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
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('ai_usage_logs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('servicio', 30);
|
||||
$table->string('canal', 20)->default('telegram');
|
||||
$table->unsignedBigInteger('usuario_id')->nullable();
|
||||
$table->integer('input_tokens')->nullable();
|
||||
$table->integer('output_tokens')->nullable();
|
||||
$table->integer('audio_segundos')->nullable();
|
||||
$table->integer('tiempo_ms')->default(0);
|
||||
$table->decimal('costo', 10, 2)->default(0);
|
||||
$table->string('resultado', 10)->default('ok');
|
||||
$table->text('detalle')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['servicio', 'created_at']);
|
||||
$table->index('usuario_id');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('ai_usage_logs');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user