feat: version 4.1.0 -- Consumo de IA por usuario en Configuracion

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Milton Gonzalez
2026-10-23 17:48:49 -05:00
parent f497da836c
commit 120e54283e
17 changed files with 158 additions and 5 deletions
@@ -0,0 +1,15 @@
-- Consumo de la IA por llamada (para el resumen por usuario en Configuracion -> IA). El costo es
-- una estimacion con los precios por millon de tokens vigentes al registrar. Idempotente.
CREATE TABLE IF NOT EXISTS ai_usage (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NULL,
action VARCHAR(40) NOT NULL,
model VARCHAR(60) NOT NULL,
input_tokens INT UNSIGNED NOT NULL DEFAULT 0,
output_tokens INT UNSIGNED NOT NULL DEFAULT 0,
cost_usd DECIMAL(12,6) NOT NULL DEFAULT 0,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
KEY idx_ai_usage_created (created_at),
KEY idx_ai_usage_user (user_id),
CONSTRAINT fk_ai_usage_user FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;