diff options
author | abysssol <abysssol@pm.me> | 2024-03-11 20:53:45 -0400 |
---|---|---|
committer | abysssol <abysssol@pm.me> | 2024-03-11 21:37:48 -0400 |
commit | efed30f903199e90be4f280c65f2f410b55835df (patch) | |
tree | 56552b864ab6d8242d5319d234ba45c770388f3f /nixos/tests/ollama.nix | |
parent | 52544c4a0a84552db4013a8858ade52eaf7ff0ca (diff) |
nixos/ollama: add test for the ollama service
Diffstat (limited to 'nixos/tests/ollama.nix')
-rw-r--r-- | nixos/tests/ollama.nix | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/nixos/tests/ollama.nix b/nixos/tests/ollama.nix new file mode 100644 index 0000000000000..4b21f445cdbd3 --- /dev/null +++ b/nixos/tests/ollama.nix @@ -0,0 +1,56 @@ +import ./make-test-python.nix ({ pkgs, lib, ... }: +let + mainPort = "11434"; + altPort = "11435"; + + curlRequest = port: request: + "curl http://127.0.0.1:${port}/api/generate -d '${builtins.toJSON request}'"; + + prompt = { + model = "tinydolphin"; + prompt = "lorem ipsum"; + options = { + seed = 69; + temperature = 0; + }; + }; +in +{ + name = "ollama"; + meta = with lib.maintainers; { + maintainers = [ abysssol ]; + }; + + nodes = { + cpu = { ... }: { + services.ollama.enable = true; + }; + + rocm = { ... }: { + services.ollama.enable = true; + services.ollama.acceleration = "rocm"; + }; + + cuda = { ... }: { + services.ollama.enable = true; + services.ollama.acceleration = "cuda"; + }; + + altAddress = { ... }: { + services.ollama.enable = true; + services.ollama.listenAddress = "127.0.0.1:${altPort}"; + }; + }; + + testScript = '' + vms = [ cpu, rocm, cuda, altAddress ]; + + start_all() + for vm in vms: + vm.wait_for_unit("multi-user.target") + + stdout = cpu.succeed("""${curlRequest mainPort prompt}""", timeout=100) + + stdout = altAddress.succeed("""${curlRequest altPort prompt}""", timeout=100) + ''; +}) |