From bcf5cadaa06b5a052984487a449f3e5fb5365581 Mon Sep 17 00:00:00 2001 From: Robert Date: Thu, 30 Apr 2026 21:54:47 -0400 Subject: [PATCH] olllama template fix to remove currenttime --- .../services/ollama_init_custom_models.nix | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/modules/nixos/services/ollama_init_custom_models.nix b/modules/nixos/services/ollama_init_custom_models.nix index 812849e..4dc965d 100644 --- a/modules/nixos/services/ollama_init_custom_models.nix +++ b/modules/nixos/services/ollama_init_custom_models.nix @@ -14,8 +14,25 @@ local base_model=$2 if ! ${pkgs.docker}/bin/docker exec ollama ollama list | grep -q "$model_name"; then echo "$model_name not found, creating from $base_model..." + + # We use a custom TEMPLATE block to strip the 'currentDate' function + # which is unsupported in Ollama 0.5.7 but present in Devstral's default manifest. ${pkgs.docker}/bin/docker exec ollama sh -c "cat < /root/.ollama/$model_name.modelfile FROM $base_model +TEMPLATE \"\"\"{{- if .System }} +[SYSTEM_PROMPT] +{{ .System }} +[/SYSTEM_PROMPT] +{{- end }} +{{- range .Messages }} +{{- if eq .Role \"user\" }} +[INST] +{{ .Content }} +[/INST] +{{- else if eq .Role \"assistant\" }} +{{ .Content }} +{{- end }} +{{- end }}\"\"\" PARAMETER num_ctx 131072 PARAMETER num_predict 4096 PARAMETER num_keep 1024 @@ -26,6 +43,7 @@ PARAMETER stop \"[/INST]\" PARAMETER stop \"\" EOF" ${pkgs.docker}/bin/docker exec ollama ollama create "$model_name" -f "/root/.ollama/$model_name.modelfile" + ${pkgs.docker}/bin/docker exec ollama rm "/root/.ollama/$model_name.modelfile" else echo "$model_name already exists, skipping." fi @@ -36,6 +54,10 @@ EOF" # Create Devstral create_model_if_missing "devstral-small-2:24b-128k" "devstral-small-2:24b" + + # create_model_if_missing "qwen2.5-coder:32b-128k" "qwen2.5-coder:32b" + + # create_model_if_missing "mistral-large-planner:123b" "mistral-large:123b-instruct-v2407-q4_K_S" ''; serviceConfig = { Type = "oneshot";