package models import ( "github.com/sujit-baniya/fiber-boilerplate/app" "gorm.io/gorm" ) // WhisperAsrConfig almacena la conexión al servicio propio de transcripción // de audio (whisper-asr-webservice self-hosted, autenticado con Basic Auth) // — distinto del Whisper de OpenAI que ya se configura vía AiConfig con // modulo "whisper" para el bot de Telegram. Solo un registro activo a la vez. type WhisperAsrConfig struct { gorm.Model BaseURL string `json:"base_url" gorm:"column:base_url;type:text;not null"` // ej: https://whisper.u-s.app/asr Username string `json:"username" gorm:"column:username;size:255;not null"` Password string `json:"password" gorm:"column:password;type:text;not null"` Notas string `json:"notas" gorm:"column:notas;type:text"` Activo bool `json:"activo" gorm:"column:activo;default:true"` } func (WhisperAsrConfig) TableName() string { return "whisper_asr_config" } func GetWhisperAsrConfig() (*WhisperAsrConfig, error) { var item WhisperAsrConfig if err := app.Http.Database.DB.Where("activo = ?", true).Order("id DESC").First(&item).Error; err != nil { return nil, err } return &item, nil } func SaveWhisperAsrConfig(s WhisperAsrConfig) error { app.Http.Database.DB.Model(&WhisperAsrConfig{}).Where("activo = ?", true).Update("activo", false) s.Activo = true if s.ID > 0 { return app.Http.Database.DB.Model(&s).Updates(map[string]interface{}{ "base_url": s.BaseURL, "username": s.Username, "password": s.Password, "notas": s.Notas, "activo": true, }).Error } return app.Http.Database.DB.Create(&s).Error }