mirror of
https://github.com/EZ-Api/ez-api.git
synced 2026-01-13 17:47:51 +00:00
feat(models): add kind and models_meta snapshot
This commit is contained in:
@@ -294,8 +294,25 @@ func (h *Handler) CreateModel(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
name := strings.TrimSpace(req.Name)
|
||||
if name == "" {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "name required"})
|
||||
return
|
||||
}
|
||||
kind := strings.ToLower(strings.TrimSpace(req.Kind))
|
||||
if kind == "" {
|
||||
kind = "chat"
|
||||
}
|
||||
switch kind {
|
||||
case "chat", "embedding", "rerank", "other":
|
||||
default:
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "invalid kind"})
|
||||
return
|
||||
}
|
||||
|
||||
modelReq := model.Model{
|
||||
Name: req.Name,
|
||||
Name: name,
|
||||
Kind: kind,
|
||||
ContextWindow: req.ContextWindow,
|
||||
CostPerToken: req.CostPerToken,
|
||||
SupportsVision: req.SupportsVision,
|
||||
@@ -370,7 +387,27 @@ func (h *Handler) UpdateModel(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
existing.Name = req.Name
|
||||
name := strings.TrimSpace(req.Name)
|
||||
if name == "" {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "name required"})
|
||||
return
|
||||
}
|
||||
kind := strings.ToLower(strings.TrimSpace(req.Kind))
|
||||
if kind == "" {
|
||||
kind = strings.ToLower(strings.TrimSpace(existing.Kind))
|
||||
}
|
||||
if kind == "" {
|
||||
kind = "chat"
|
||||
}
|
||||
switch kind {
|
||||
case "chat", "embedding", "rerank", "other":
|
||||
default:
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "invalid kind"})
|
||||
return
|
||||
}
|
||||
|
||||
existing.Name = name
|
||||
existing.Kind = kind
|
||||
existing.ContextWindow = req.ContextWindow
|
||||
existing.CostPerToken = req.CostPerToken
|
||||
existing.SupportsVision = req.SupportsVision
|
||||
|
||||
Reference in New Issue
Block a user