mirror of
https://github.com/mudler/LocalAI.git
synced 2026-06-06 15:56:06 -04:00
Add a routing middleware stack and a cloud-proxy backend. * cloud-proxy: a Go gRPC backend that forwards OpenAI- and Anthropic-shaped chat requests to upstream providers, with an optional translate mode (OpenAI request -> Anthropic /v1/messages -> OpenAI response) and full tool-calling support. * routing: admission control, content-aware model routing (embedding cache + classifier + rerank + Arch-Router score), PII detection/redaction (regex + NER) with streaming filter and OpenAI/Anthropic adapters, and a per-user/per-key billing recorder backed by GORM or in-memory storage. * middleware: UsageMiddleware records usage via the billing recorder, plus admission, route-model, usage-stamp and trace middlewares. * observability: BackendTrace ring buffer stores full request bodies (capped), MITM proxy emits structured trace events, and router classifier decisions surface at /api/router/decide. * gallery: Arch-Router-1.5B (Q4_K_M and Q8_0). * UI: cloud-proxy model-editor fields, classifier system-prompt and score-normalization config, and a Traces page rendering request bodies. Assisted-by: claude-code:claude-opus-4-7 [Read] [Edit] [Bash] Signed-off-by: Richard Palethorpe <io@richiejp.com>
49 lines
2.1 KiB
Go
49 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"
|
|
ToolListPIIPatterns = "list_pii_patterns"
|
|
ToolGetPIIEvents = "get_pii_events"
|
|
ToolTestPIIRedaction = "test_pii_redaction"
|
|
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"
|
|
ToolSetPIIPatternAction = "set_pii_pattern_action"
|
|
ToolPersistPIIPatterns = "persist_pii_patterns"
|
|
)
|
|
|
|
// 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"
|