model-registry: add upstream check endpoint

This commit is contained in:
zenfun
2025-12-18 16:43:12 +08:00
parent a61eff27e7
commit 7dd3fac24e
5 changed files with 221 additions and 20 deletions

View File

@@ -42,6 +42,34 @@ type refreshModelRegistryRequest struct {
Ref string `json:"ref"`
}
// CheckModelRegistry godoc
// @Summary Check model registry upstream version
// @Description Checks models.dev commit SHA for a ref and indicates whether refresh is needed (does not apply changes)
// @Tags admin
// @Accept json
// @Produce json
// @Security AdminAuth
// @Param body body refreshModelRegistryRequest false "optional override ref"
// @Success 200 {object} service.ModelRegistryCheckResult
// @Failure 400 {object} gin.H
// @Failure 500 {object} gin.H
// @Router /admin/model-registry/check [post]
func (h *ModelRegistryHandler) Check(c *gin.Context) {
if h == nil || h.reg == nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": "model registry not configured"})
return
}
var req refreshModelRegistryRequest
_ = c.ShouldBindJSON(&req)
ref := strings.TrimSpace(req.Ref)
out, err := h.reg.Check(c.Request.Context(), ref)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to check model registry", "details": err.Error()})
return
}
c.JSON(http.StatusOK, out)
}
// RefreshModelRegistry godoc
// @Summary Refresh model registry from models.dev
// @Description Fetches models.dev, computes per-binding capabilities, and updates Redis meta:models