92 lines
2.3 KiB
Nix
92 lines
2.3 KiB
Nix
{
|
|
pkgs,
|
|
lib,
|
|
optimizeWithFlags,
|
|
...
|
|
}:
|
|
let
|
|
models = [
|
|
rec {
|
|
name = "DeepSeek-R1-Distill-Qwen-14B-Q4_0";
|
|
filename = builtins.elemAt (lib.splitString "?" src.name) 0;
|
|
context_length = 32768;
|
|
gen_length = 8192;
|
|
src = pkgs.fetchurl {
|
|
url = "https://huggingface.co/bartowski/DeepSeek-R1-Distill-Qwen-14B-GGUF/resolve/main/DeepSeek-R1-Distill-Qwen-14B-Q4_0.gguf?download=true";
|
|
sha256 = "906b3382f2680f4ce845459b4a122e904002b075238080307586bcffcde49eef";
|
|
};
|
|
}
|
|
];
|
|
|
|
gpt4all_package = (
|
|
optimizeWithFlags
|
|
(pkgs.gpt4all.overrideAttrs (old: {
|
|
patches = old.patches ++ [
|
|
./disable-settings-err.patch
|
|
./disable-version-check.patch
|
|
];
|
|
}))
|
|
# compile flags
|
|
[
|
|
"-O3"
|
|
"-march=native"
|
|
"-mtune=native"
|
|
]
|
|
);
|
|
|
|
system_prompt = "";
|
|
in
|
|
{
|
|
home.packages = [
|
|
gpt4all_package
|
|
];
|
|
|
|
home.file =
|
|
lib.recursiveUpdate
|
|
{
|
|
".config/nomic.ai/GPT4All.ini".text =
|
|
''
|
|
[General]
|
|
chatTheme=Dark
|
|
height=940
|
|
suggestionMode=Off
|
|
threadCount=8
|
|
userDefaultModel=${
|
|
# select the first element of `models` to be the default model
|
|
(builtins.elemAt models 0).name
|
|
}
|
|
width=1472
|
|
x=0
|
|
y=0
|
|
|
|
[download]
|
|
lastVersionStarted=${gpt4all_package.version}
|
|
''
|
|
+ (lib.concatMapStringsSep "\n" (model: ''
|
|
[model-${model.name}]
|
|
contextLength=${builtins.toString model.context_length}
|
|
filename=${model.filename}
|
|
maxLength=${builtins.toString model.gen_length}
|
|
promptBatchSize=256
|
|
systemMessage="${
|
|
# replace newlines with the string "\n" for gpt4all to properly parse
|
|
builtins.replaceStrings [ "\n" ] [ "\\n" ] system_prompt
|
|
}"
|
|
'') models)
|
|
+ ''
|
|
|
|
[network]
|
|
isActive=false
|
|
usageStatsActive=false
|
|
'';
|
|
}
|
|
(
|
|
builtins.listToAttrs (
|
|
map (f: {
|
|
name = ".local/share/nomic.ai/GPT4All/${f.filename}";
|
|
value.source = f.src;
|
|
}) models
|
|
)
|
|
);
|
|
}
|