mirror of
https://github.com/mudler/LocalAI.git
synced 2026-06-22 07:39:02 -04:00
* feat(config): add model alias field and self-validation Add ModelConfig.Alias (yaml: alias), IsAlias(), and an alias short-circuit at the top of Validate() that rejects self-reference and forbids setting backend/parameters.model on a pure-redirect alias. Assisted-by: Claude:claude-opus-4-8 [Claude Code] Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * feat(config): resolve and validate model alias targets in the loader Assisted-by: Claude:opus-4-8 [Claude Code] Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * feat(middleware): resolve model aliases and stamp requested/served identity Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * feat(modeladmin): reject alias configs with invalid targets on create/edit Validate alias targets at create/swap entry points (ImportModelEndpoint, EditYAML, PatchConfig) so a dangling, chained, or disabled alias target is rejected at save time rather than surfacing as a runtime error. Assisted-by: Claude:opus-4-8 [Claude Code] Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * feat(api): add GET /api/aliases to list model aliases Adds an admin-gated read-only endpoint that lists every model alias config as {name, target} pairs, backed by the loader's existing GetAllModelsConfigs(). Assisted-by: Claude:opus-4.8 [Claude Code] Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * feat(mcp): add set_alias and list_aliases tools Expose model-alias management over the LocalAI Assistant MCP surface: list_aliases (read-only, GET /api/aliases) and set_alias (mutating). SetAlias is swap-first: PATCH /api/models/config-json/:name swaps an existing alias's target (validated, non-destructive) and a 404 falls back to POST /models/import to create a fresh {name, alias} config. The inproc client mirrors this via ConfigService.PatchConfig + a create path modeled on ImportModelEndpoint. Deletion reuses delete_model. Assisted-by: Claude:claude-opus-4 [Claude Code] Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * style(mcp): replace em dashes in alias tool comments Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * feat(config-meta): expose alias as a model-select field Add an 'alias' section to DefaultSections() and an 'alias' field override in DefaultRegistry() so the schema-driven React editor renders the new top-level ModelConfig.Alias field as a model picker in its own section. Assisted-by: Claude:opus-4.8 [Claude Code] Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * feat(ui): add alias template card and Manage alias badge Add an 'Alias / Routing' template to the create-flow gallery that seeds a minimal name + alias config, and a read-only 'alias -> target' badge on the Manage Models tab. The capabilities row payload does not carry the alias field, so the badge resolves targets from GET /api/aliases looked up by name. Assisted-by: Claude:claude-opus-4 [Claude Code] Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * docs: document model aliases Assisted-by: Claude:claude-opus-4-8 [Claude Code] Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * docs(swagger): regenerate for GET /api/aliases Adds the /api/aliases path and AliasInfo schema generated from the ListAliasesEndpoint annotation. Assisted-by: Claude:claude-opus-4-8 [Claude Code] Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * test(localai): check os.RemoveAll error in aliases_test Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * fix: correct alias conversion docs and advertise /api/aliases in instructions Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * fix(mcp): write alias config 0600 to satisfy gosec G306 The inproc createAlias path wrote the alias YAML with 0644, which gosec flags as a new G306 finding on the PR. The LocalAI process is the sole reader/writer of model configs, so 0600 is correct and keeps the scan clean. Assisted-by: Claude:claude-opus-4-8 [Claude Code] Signed-off-by: Ettore Di Giacinto <mudler@localai.io> --------- Signed-off-by: Ettore Di Giacinto <mudler@localai.io> Co-authored-by: Ettore Di Giacinto <mudler@localai.io>
50 lines
2.1 KiB
Go
50 lines
2.1 KiB
Go
package localaitools
|
|
|
|
// Tool names exposed by the LocalAI Assistant MCP server. Use these
|
|
// constants — never bare strings — when registering tools, asserting the
|
|
// catalog in tests, or referencing tool names from other packages. The
|
|
// embedded skill prompts under prompts/ keep the bare strings because
|
|
// go:embed-ed markdown can't reference Go constants; TestPromptsContain
|
|
// SafetyAnchors guards that those strings stay aligned.
|
|
const (
|
|
// Read-only tools.
|
|
ToolGallerySearch = "gallery_search"
|
|
ToolListInstalledModels = "list_installed_models"
|
|
ToolListGalleries = "list_galleries"
|
|
ToolGetJobStatus = "get_job_status"
|
|
ToolGetModelConfig = "get_model_config"
|
|
ToolListBackends = "list_backends"
|
|
ToolListKnownBackends = "list_known_backends"
|
|
ToolSystemInfo = "system_info"
|
|
ToolListNodes = "list_nodes"
|
|
ToolVRAMEstimate = "vram_estimate"
|
|
ToolGetBranding = "get_branding"
|
|
ToolGetUsageStats = "get_usage_stats"
|
|
ToolGetPIIEvents = "get_pii_events"
|
|
ToolGetMiddlewareStatus = "get_middleware_status"
|
|
ToolGetRouterDecisions = "get_router_decisions"
|
|
|
|
// Mutating tools — guarded by Options.DisableMutating and the
|
|
// LLM-side safety prompt (see prompts/10_safety.md).
|
|
ToolInstallModel = "install_model"
|
|
ToolImportModelURI = "import_model_uri"
|
|
ToolDeleteModel = "delete_model"
|
|
ToolEditModelConfig = "edit_model_config"
|
|
ToolReloadModels = "reload_models"
|
|
ToolInstallBackend = "install_backend"
|
|
ToolUpgradeBackend = "upgrade_backend"
|
|
ToolToggleModelState = "toggle_model_state"
|
|
ToolToggleModelPinned = "toggle_model_pinned"
|
|
ToolSetBranding = "set_branding"
|
|
ToolSetAlias = "set_alias"
|
|
|
|
// ToolListAliases is read-only but lives here so the alias tools stay
|
|
// grouped; the catalog tests assert its read-only placement.
|
|
ToolListAliases = "list_aliases"
|
|
)
|
|
|
|
// DefaultServerName is the MCP Implementation.Name surfaced when
|
|
// Options.ServerName is empty. Use the constant when you want a stable
|
|
// reference across packages (e.g. test fixtures, CLI defaults).
|
|
const DefaultServerName = "localai-admin"
|