LLM Backend Auto-Loader (model/autoload.go)

LocalAI · pkg/model/autoload.go · go · MIT
ai, tag:knn-classified, tag:backend, tag:autoload, tag:model, tag:detection

Registers a predicate for LLM-capable backends and auto-selects the appropriate backend for GGUF models, preferring llama‑cpp. Use to dynamically choose inference backends in modular AI services.

// Source: https://github.com/mudler/LocalAI | License: MIT | Copyright 2023-2025 Ettore Di Giacinto (mudler@localai.io)
// Provided via justclaw.it.com; keep this notice with the code.
package model

import (
	"sort"
	"strings"
)

// preferredGGUFBackend is tried first when auto-detecting the backend for a
// GGUF model, since GGUF is overwhelmingly llama.cpp's native format.
const preferredGGUFBackend = "llama-cpp"

// llmCapableBackend reports whether the named backend can serve a text/LLM GGUF
// model. The backend capability table lives in core/config, which is a
// higher-level package that already imports pkg/model; importing it back here
// would form a core/config -> pkg/model -> core/config cycle. So core/config
// registers the predicate via RegisterLLMCapableBackendFunc instead

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key