feat(umind): mide el consumo de IA, OCR y transcripción por tenant
Es la base del cobro por uso: hasta ahora no había ninguna medición de consumo en todo el repo. - UmindUso registra cada evento facturable con el costo YA calculado al precio vigente del plan. Congelarlo evita que subir un precio revalúe consumo pasado, que haría indefendible una factura ante un reclamo. - callAI devuelve los tokens que reportó el proveedor (campo usage, igual en todos los OpenAI-compatibles; input+output en Anthropic). Se mide cada ronda de tool-calling, no solo la última: todas gastan tokens. - ExtraerTextoOCR y TranscribirAudioSelfHosted reciben agenteID; 0 = no medir, que es lo que pasan los botones "Probar" del panel de staff. - Aviso al superar el tope del plan, una vez por mes y sin cortar el servicio. El flag de "ya avisé" es en memoria a propósito. - GET /app/umind/uso con filtros de fecha: resumen por tipo + detalle. - Test del cálculo de costo por tipo, incluida fracción de 1k tokens y tenant sin plan. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
96cd24f17d
commit
08265510ea
@@ -401,7 +401,9 @@ func DownloadEntregable(c *fiber.Ctx) error {
|
||||
|
||||
func UpdateEntregableVisibilidad(c *fiber.Ctx) error {
|
||||
entID, _ := strconv.ParseUint(c.Params("entID"), 10, 32)
|
||||
type Req struct{ Visible bool `json:"visible"` }
|
||||
type Req struct {
|
||||
Visible bool `json:"visible"`
|
||||
}
|
||||
var req Req
|
||||
if err := c.BodyParser(&req); err != nil {
|
||||
return c.Status(400).JSON(fiber.Map{"error": err.Error()})
|
||||
@@ -530,7 +532,9 @@ func GetTickets(c *fiber.Ctx) error {
|
||||
|
||||
func UpdateTicketEstadoAdmin(c *fiber.Ctx) error {
|
||||
ticketID, _ := strconv.ParseUint(c.Params("ticketID"), 10, 32)
|
||||
type Req struct{ Estado string `json:"estado"` }
|
||||
type Req struct {
|
||||
Estado string `json:"estado"`
|
||||
}
|
||||
var req Req
|
||||
if err := c.BodyParser(&req); err != nil {
|
||||
return c.Status(400).JSON(fiber.Map{"error": err.Error()})
|
||||
@@ -543,7 +547,9 @@ func UpdateTicketEstadoAdmin(c *fiber.Ctx) error {
|
||||
|
||||
func AdminResponderTicket(c *fiber.Ctx) error {
|
||||
ticketID, _ := strconv.ParseUint(c.Params("ticketID"), 10, 32)
|
||||
type Req struct{ Contenido string `json:"contenido"` }
|
||||
type Req struct {
|
||||
Contenido string `json:"contenido"`
|
||||
}
|
||||
var req Req
|
||||
if err := c.BodyParser(&req); err != nil {
|
||||
return c.Status(400).JSON(fiber.Map{"error": err.Error()})
|
||||
|
||||
Reference in New Issue
Block a user