mirror of
https://github.com/mudler/LocalAI.git
synced 2026-11-06 20:43:27 -05:00
The notice came from navigation state, which survives a refresh, so it came back after add-ons were on again. A frontend also reports add-ons as off when the owner does not answer for a moment, which looked the same as the instance switch being off. Home now reads /api/features on mount, drops the notice and clears the history state when add-ons are on, and clears the state on dismiss. /api/features gains addons_enabled (the instance switch alone), so the notice can say "not answering right now" with a retry button when the switch is on and the owner is silent. Assisted-by: Claude:claude-sonnet-5-5 eslint node go-test
48 lines
2.2 KiB
Go
48 lines
2.2 KiB
Go
// SPDX-License-Identifier: MIT
|
|
package routes
|
|
|
|
import (
|
|
"github.com/labstack/echo/v4"
|
|
"github.com/mudler/LocalAI/core/application"
|
|
"github.com/mudler/LocalAI/core/config"
|
|
)
|
|
|
|
// RegisterFeatureRoutes serves GET /api/features, the switches the UI reads.
|
|
// Fine-tuning and quantization are add-ons, so they follow the add-on gate and
|
|
// have no switch of their own. addon_navigation is the layout (new or legacy)
|
|
// and is not a substitute for addons.
|
|
func RegisterFeatureRoutes(router *echo.Echo, appConfig *config.ApplicationConfig, app *application.Application) {
|
|
router.GET("/api/features", func(c echo.Context) error {
|
|
addons := app.AddonsFeature(c.Request().Context())
|
|
// addons_enabled is the instance switch alone. With addons false, true
|
|
// there means the owner does not answer right now, not that it is off.
|
|
// model_exports is false only when this instance does not see the
|
|
// owner's models path; an unknown check leaves it true.
|
|
// The chats keys say what runs on this server, not what a user may use:
|
|
// the permissions of a user come from /api/auth/me. A part that was
|
|
// switched off, or that failed to start, reads false.
|
|
chats := app.StudioService() != nil
|
|
return c.JSON(200, map[string]bool{
|
|
"chats": chats,
|
|
"agents": chats,
|
|
"triggers": chats && app.StudioTriggers() != nil,
|
|
"connectors": chats && app.StudioConnectors() != nil,
|
|
"agent_jobs": chats && app.StudioJobs() != nil,
|
|
"collections": appConfig.Collections.Enabled,
|
|
"mcp": !appConfig.DisableMCP,
|
|
"addons": addons,
|
|
"addons_enabled": app.AddonsEnabled(),
|
|
"fine_tuning": addons,
|
|
"quantization": addons,
|
|
"model_exports": addons && app.ModelExportsAllowed(c.Request().Context()),
|
|
"distributed": appConfig.Distributed.Enabled,
|
|
"backend_install": !appConfig.DisableBackendInstall,
|
|
"localai_assistant": !appConfig.DisableLocalAIAssistant && app.LocalAIAssistant() != nil,
|
|
"addon_navigation": !appConfig.LegacyNavigation,
|
|
// The server's default for offers from the assistant; a user's own
|
|
// choice in user.json wins.
|
|
"chats_suggestions": chats && !appConfig.DisableChatSuggestions,
|
|
})
|
|
})
|
|
}
|