mirror of
https://github.com/mudler/LocalAI.git
synced 2026-07-30 09:57:57 -04:00
fix(distributed): backend discovery hid worker-installed backends Backend discovery endpoints filter on installed-state, which on a distributed controller derives from the controller's own filesystem. A backend lives on the worker node that runs it, so every backend an admin installed on a GPU worker read as "not installed" and vanished from the listing. #10947 fixed the sibling capability filter on the same endpoints, so a fine-tuning-capable GPU worker now made the backend listable while the installed-state filter still dropped it: the dropdown stayed empty. The controller cannot derive this locally, but it already aggregates the per-node view that GET /backends renders, so discovery reuses the active BackendManager rather than growing a second path. Three surfaces shared the root cause and route through the same helper now: - GET /backends/available (Installed is now cluster-wide) - GET /api/fine-tuning/backends - GET /api/quantization/backends The response stays a boolean rather than an installed-on-N-of-M count: per-node install state is already served by GET /backends nodes[], and per-node control by POST /api/nodes/:id/backends/install, so a summary is all these dropdowns need. A nil provider (single-node) leaves the local filesystem as the only source and reproduces today's listing exactly, and a registry error degrades to that same listing instead of blanking the catalog. Assisted-by: Claude:claude-opus-4-8 golangci-lint Signed-off-by: Ettore Di Giacinto <mudler@localai.io> Co-authored-by: Ettore Di Giacinto <mudler@localai.io>
42 lines
1.6 KiB
Go
42 lines
1.6 KiB
Go
package routes
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/labstack/echo/v4"
|
|
"github.com/mudler/LocalAI/core/application"
|
|
"github.com/mudler/LocalAI/core/config"
|
|
"github.com/mudler/LocalAI/core/http/endpoints/localai"
|
|
"github.com/mudler/LocalAI/core/services/quantization"
|
|
)
|
|
|
|
// RegisterQuantizationRoutes registers quantization API routes.
|
|
func RegisterQuantizationRoutes(e *echo.Echo, qService *quantization.QuantizationService, appConfig *config.ApplicationConfig, app *application.Application, quantizationMw echo.MiddlewareFunc) {
|
|
if qService == nil {
|
|
return
|
|
}
|
|
|
|
// Service readiness middleware
|
|
readyMw := func(next echo.HandlerFunc) echo.HandlerFunc {
|
|
return func(c echo.Context) error {
|
|
if qService == nil {
|
|
return c.JSON(http.StatusServiceUnavailable, map[string]string{
|
|
"error": "quantization service is not available",
|
|
})
|
|
}
|
|
return next(c)
|
|
}
|
|
}
|
|
|
|
q := e.Group("/api/quantization", readyMw, quantizationMw)
|
|
q.GET("/backends", localai.ListQuantizationBackendsEndpoint(appConfig, ClusterCapabilityProviderFor(app), ClusterInstalledProviderFor(app)))
|
|
q.POST("/jobs", localai.StartQuantizationJobEndpoint(qService))
|
|
q.GET("/jobs", localai.ListQuantizationJobsEndpoint(qService))
|
|
q.GET("/jobs/:id", localai.GetQuantizationJobEndpoint(qService))
|
|
q.POST("/jobs/:id/stop", localai.StopQuantizationJobEndpoint(qService))
|
|
q.DELETE("/jobs/:id", localai.DeleteQuantizationJobEndpoint(qService))
|
|
q.GET("/jobs/:id/progress", localai.QuantizationProgressEndpoint(qService))
|
|
q.POST("/jobs/:id/import", localai.ImportQuantizedModelEndpoint(qService))
|
|
q.GET("/jobs/:id/download", localai.DownloadQuantizedModelEndpoint(qService))
|
|
}
|