package meta import "github.com/mudler/LocalAI/core/services/routing/piipattern" // builtinPatternOptions turns the piipattern built-in catalogue into select // options for the editor's built-in-patterns checklist, keeping the catalogue // the single source of truth. func builtinPatternOptions() []FieldOption { cat := piipattern.BuiltinCatalogue() out := make([]FieldOption, 0, len(cat)) for _, b := range cat { out = append(out, FieldOption{Value: b.Name, Label: b.Name + " — " + b.Description}) } return out } // DefaultRegistry returns enrichment overrides for the ~30 most commonly used // config fields. Fields not listed here still appear with auto-generated // labels and type-inferred components. func DefaultRegistry() map[string]FieldMetaOverride { f64 := func(v float64) *float64 { return &v } return map[string]FieldMetaOverride{ // --- General --- "name": { Section: "general", Label: "Model Name", Description: "Unique identifier for this model configuration", Component: "input", Order: 0, }, "backend": { Section: "general", Label: "Backend", Description: "The inference backend to use (e.g. llama-cpp, vllm, diffusers)", Component: "select", AutocompleteProvider: ProviderBackends, Order: 1, }, "description": { Section: "general", Label: "Description", Description: "Human-readable description of what this model does", Component: "textarea", Order: 2, }, "usage": { Section: "general", Label: "Usage", Description: "Usage instructions or notes", Component: "textarea", Advanced: true, Order: 3, }, "cuda": { Section: "general", Label: "CUDA", Description: "Explicitly enable CUDA acceleration", Order: 5, }, "known_usecases": { Section: "general", Label: "Known Use Cases", Description: "Capabilities this model supports", Component: "string-list", Options: UsecaseOptions, Order: 6, }, // --- LLM --- "context_size": { Section: "llm", Label: "Context Size", Description: "Maximum context window in tokens", Component: "number", VRAMImpact: true, Order: 10, }, "gpu_layers": { Section: "llm", Label: "GPU Layers", Description: "Number of layers to offload to GPU (-1 = all)", Component: "number", Min: f64(-1), VRAMImpact: true, Order: 11, }, "threads": { Section: "llm", Label: "Threads", Description: "Number of CPU threads for inference", Component: "number", Min: f64(1), Order: 12, }, "f16": { Section: "llm", Label: "F16", Description: "Use 16-bit floating point for key/value cache", Order: 13, }, "mmap": { Section: "llm", Label: "Memory Map", Description: "Use memory-mapped files for model loading", Order: 14, }, "mmlock": { Section: "llm", Label: "Memory Lock", Description: "Lock model memory to prevent swapping", Advanced: true, Order: 15, }, "low_vram": { Section: "llm", Label: "Low VRAM", Description: "Optimize for systems with limited GPU memory", VRAMImpact: true, Order: 16, }, "embeddings": { Section: "llm", Label: "Embeddings", Description: "Enable embedding generation mode", Order: 17, }, "quantization": { Section: "llm", Label: "Quantization", Description: "Quantization method (e.g. q4_0, q5_1, q8_0)", Component: "select", Options: QuantizationOptions, Advanced: true, Order: 20, }, "flash_attention": { Section: "llm", Label: "Flash Attention", Description: "Enable flash attention for faster inference", Component: "input", Advanced: true, Order: 21, }, "reasoning_effort": { Section: "llm", Label: "Reasoning Effort", Description: "Default reasoning effort, forwarded to the backend as the reasoning_effort chat_template_kwarg (jinja models like gpt-oss / LFM2.5 honor it). A per-request reasoning_effort overrides it. 'none' also turns thinking off.", Component: "select", Options: []FieldOption{ {Value: "", Label: "Unset (model default)"}, {Value: "none", Label: "none (disable thinking)"}, {Value: "minimal", Label: "minimal"}, {Value: "low", Label: "low"}, {Value: "medium", Label: "medium"}, {Value: "high", Label: "high"}, }, Advanced: true, Order: 22, }, "cache_type_k": { Section: "llm", Label: "KV Cache Type (K)", Description: "Quantization type for key cache (e.g. f16, q8_0, q4_0)", Component: "select", Options: CacheTypeOptions, VRAMImpact: true, Advanced: true, Order: 22, }, "cache_type_v": { Section: "llm", Label: "KV Cache Type (V)", Description: "Quantization type for value cache", Component: "select", Options: CacheTypeOptions, VRAMImpact: true, Advanced: true, Order: 23, }, // --- Parameters --- "parameters.temperature": { Section: "parameters", Label: "Temperature", Description: "Sampling temperature (higher = more creative, lower = more deterministic)", Component: "slider", Min: f64(0), Max: f64(2), Step: f64(0.05), Order: 30, }, "parameters.top_p": { Section: "parameters", Label: "Top P", Description: "Nucleus sampling threshold", Component: "slider", Min: f64(0), Max: f64(1), Step: f64(0.01), Order: 31, }, "parameters.top_k": { Section: "parameters", Label: "Top K", Description: "Top-K sampling: consider only the K most likely tokens", Component: "number", Min: f64(0), Order: 32, }, "parameters.max_tokens": { Section: "parameters", Label: "Max Tokens", Description: "Maximum number of tokens to generate (0 = unlimited)", Component: "number", Min: f64(0), Order: 33, }, "parameters.repeat_penalty": { Section: "parameters", Label: "Repeat Penalty", Description: "Penalize repeated tokens (1.0 = no penalty)", Component: "number", Min: f64(0), Advanced: true, Order: 34, }, "parameters.seed": { Section: "parameters", Label: "Seed", Description: "Random seed (-1 = random)", Component: "number", Advanced: true, Order: 35, }, // --- Templates --- "template.chat": { Section: "templates", Label: "Chat Template", Description: "Go template for chat completion requests", Component: "code-editor", Language: "gotemplate", Order: 40, }, "template.chat_message": { Section: "templates", Label: "Chat Message Template", Description: "Go template for individual chat messages", Component: "code-editor", Language: "gotemplate", Order: 41, }, "template.completion": { Section: "templates", Label: "Completion Template", Description: "Go template for completion requests", Component: "code-editor", Language: "gotemplate", Order: 42, }, "template.function": { Section: "templates", Label: "Functions Template", Description: "Go template applied when tools/functions are present in the request", Component: "code-editor", Language: "gotemplate", Order: 43, }, "template.use_tokenizer_template": { Section: "templates", Label: "Use Tokenizer Template", Description: "Use the chat template from the model's tokenizer config", Order: 44, }, // Router section template — kept in the templates UI section // (rather than the router section under "other") so operators // editing prompt shapes find all template-typed fields in one // place, mirroring how chat / chat_message are grouped. "router.classifier_system_template": { Section: "templates", Label: "Router Classifier System Prompt", Description: "Go text/template (with sprig functions) for the routing system prompt the score classifier feeds to its classifier_model. Executed with `.Policies` ([]{Label, Description}). Empty falls back to the built-in Arch-Router-shaped prompt (route-listing block + JSON output schema). Override when the classifier model was trained on a different schema or you need the routing instructions in a different language. The candidate format scored against the model is fixed at `{\"route\": \"