diff --git a/extensions/llamacpp-extension/settings.json b/extensions/llamacpp-extension/settings.json index 707b50c00..8d013fee1 100644 --- a/extensions/llamacpp-extension/settings.json +++ b/extensions/llamacpp-extension/settings.json @@ -23,6 +23,18 @@ "controllerType": "checkbox", "controllerProps": { "value": true } }, + { + "key": "chat_template", + "title": "Custom Jinja Chat template", + "description": "Custom Jinja chat_template to be used for the model", + "controllerType": "input", + "controllerProps": { + "value": "", + "placeholder": "e.g., {% for message in messages %}...{% endfor %} (default is read from GGUF)", + "type": "text", + "textAlign": "right" + } + }, { "key": "threads", "title": "Threads", diff --git a/extensions/llamacpp-extension/src/index.ts b/extensions/llamacpp-extension/src/index.ts index e68812510..878c6f4f6 100644 --- a/extensions/llamacpp-extension/src/index.ts +++ b/extensions/llamacpp-extension/src/index.ts @@ -33,6 +33,7 @@ type LlamacppConfig = { version_backend: string auto_update_engine: boolean auto_unload: boolean + chat_template: string n_gpu_layers: number ctx_size: number threads: number @@ -793,6 +794,7 @@ export default class llamacpp_extension extends AIEngine { } // Add remaining options from the interface + if (cfg.chat_template) args.push('--chat-template', cfg.chat_template) args.push('-ngl', String(cfg.n_gpu_layers > 0 ? cfg.n_gpu_layers : 100)) if (cfg.threads > 0) args.push('--threads', String(cfg.threads)) if (cfg.threads_batch > 0)