2024-04-21 15:54:59 +00:00
|
|
|
import ./make-test-python.nix ({ pkgs, lib, ... }:
|
|
|
|
let
|
2024-06-05 15:53:02 +00:00
|
|
|
mainPort = 11434;
|
|
|
|
altPort = 11435;
|
2024-04-21 15:54:59 +00:00
|
|
|
|
|
|
|
curlRequest = port: request:
|
2024-06-05 15:53:02 +00:00
|
|
|
"curl http://127.0.0.1:${toString port}/api/generate -d '${builtins.toJSON request}'";
|
2024-04-21 15:54:59 +00:00
|
|
|
|
|
|
|
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;
|
2024-06-05 15:53:02 +00:00
|
|
|
services.ollama.port = altPort;
|
2024-04-21 15:54:59 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
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)
|
|
|
|
'';
|
|
|
|
})
|