This commit is contained in:
Lizandro Guarnizo
2026-06-02 13:13:29 -05:00
parent ba76754331
commit 28d0eae715
7 changed files with 434 additions and 77 deletions
+13 -7
View File
@@ -35,14 +35,15 @@ func GetAiConfigs(c *fiber.Ctx) error {
// Ocultar la API key en el listado (mostrar solo últimos 4 chars)
type safe struct {
ID uint `json:"ID"`
Nombre string `json:"nombre"`
Provider string `json:"provider"`
ID uint `json:"ID"`
Nombre string `json:"nombre"`
Provider string `json:"provider"`
ApiKeyHint string `json:"api_key_hint"`
BaseURL string `json:"base_url"`
ModelName string `json:"model_name"`
IsActive bool `json:"is_active"`
Notes string `json:"notes"`
BaseURL string `json:"base_url"`
ModelName string `json:"model_name"`
IsActive bool `json:"is_active"`
Notes string `json:"notes"`
Modulo string `json:"modulo"`
}
safeItems := make([]safe, len(items))
for i, it := range items {
@@ -59,6 +60,7 @@ func GetAiConfigs(c *fiber.Ctx) error {
ModelName: it.ModelName,
IsActive: it.IsActive,
Notes: it.Notes,
Modulo: it.Modulo,
}
}
@@ -80,6 +82,7 @@ func CreateAiConfigHandler(c *fiber.Ctx) error {
ModelName string `json:"model_name"`
IsActive bool `json:"is_active"`
Notes string `json:"notes"`
Modulo string `json:"modulo"`
}
var req Req
if err := c.BodyParser(&req); err != nil {
@@ -103,6 +106,7 @@ func CreateAiConfigHandler(c *fiber.Ctx) error {
ModelName: strings.TrimSpace(req.ModelName),
IsActive: req.IsActive,
Notes: req.Notes,
Modulo: strings.TrimSpace(req.Modulo),
}
if err := models.CreateAiConfig(&item); err != nil {
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{"error": err.Error()})
@@ -125,6 +129,7 @@ func UpdateAiConfigHandler(c *fiber.Ctx) error {
ModelName string `json:"model_name"`
IsActive bool `json:"is_active"`
Notes string `json:"notes"`
Modulo string `json:"modulo"`
}
var req Req
if err := c.BodyParser(&req); err != nil {
@@ -138,6 +143,7 @@ func UpdateAiConfigHandler(c *fiber.Ctx) error {
"model_name": strings.TrimSpace(req.ModelName),
"is_active": req.IsActive,
"notes": req.Notes,
"modulo": strings.TrimSpace(req.Modulo),
}
if strings.TrimSpace(req.ApiKey) != "" {
updates["api_key"] = strings.TrimSpace(req.ApiKey)