diff --git a/pkgs/by-name/ll/llm/package.nix b/pkgs/by-name/ll/llm/package.nix index ec00b824c335..42c2b14ede81 100644 --- a/pkgs/by-name/ll/llm/package.nix +++ b/pkgs/by-name/ll/llm/package.nix @@ -3,6 +3,7 @@ python3Packages, enable-llm-anthropic ? false, enable-llm-cmd ? false, + enable-llm-command-r ? false, enable-llm-gemini ? false, enable-llm-gguf ? false, enable-llm-jq ? false, @@ -17,6 +18,7 @@ let llm llm-anthropic llm-cmd + llm-command-r llm-gemini llm-gguf llm-jq @@ -32,6 +34,7 @@ toPythonApplication ( (finalAttrs.propagatedBuildInputs or [ ]) ++ lib.optionals enable-llm-anthropic [ llm-anthropic ] ++ lib.optionals enable-llm-cmd [ llm-cmd ] + ++ lib.optionals enable-llm-cmd [ llm-command-r ] ++ lib.optionals enable-llm-gemini [ llm-gemini ] ++ lib.optionals enable-llm-gguf [ llm-gguf ] ++ lib.optionals enable-llm-jq [ llm-jq ] diff --git a/pkgs/development/python-modules/llm-command-r/default.nix b/pkgs/development/python-modules/llm-command-r/default.nix new file mode 100644 index 000000000000..c6d894cfc39b --- /dev/null +++ b/pkgs/development/python-modules/llm-command-r/default.nix @@ -0,0 +1,52 @@ +{ + lib, + callPackage, + buildPythonPackage, + fetchFromGitHub, + setuptools, + llm, + cohere, + pytestCheckHook, + pytest-recording, + writableTmpDirAsHomeHook, +}: + +buildPythonPackage rec { + pname = "llm-command-r"; + version = "0.3.1"; + pyproject = true; + + src = fetchFromGitHub { + owner = "simonw"; + repo = "llm-command-r"; + tag = version; + hash = "sha256-PxICRds9NJQP64HwoL7Oxd39yaIrMdAyQEbhaumJCgo="; + }; + + build-system = [ + setuptools + llm + ]; + + dependencies = [ cohere ]; + + nativeCheckInputs = [ + pytestCheckHook + pytest-recording + writableTmpDirAsHomeHook + ]; + + pythonImportsCheck = [ "llm_command_r" ]; + + passthru.tests = { + llm-plugin = callPackage ./tests/llm-plugin.nix { }; + }; + + meta = { + description = "Access the Cohere Command R family of models"; + homepage = "https://github.com/simonw/llm-command-r"; + changelog = "https://github.com/simonw/llm-command-r/releases/tag/${version}/CHANGELOG.md"; + license = lib.licenses.asl20; + maintainers = with lib.maintainers; [ philiptaron ]; + }; +} diff --git a/pkgs/development/python-modules/llm-command-r/tests/llm-plugin.nix b/pkgs/development/python-modules/llm-command-r/tests/llm-plugin.nix new file mode 100644 index 000000000000..a57802a8ad08 --- /dev/null +++ b/pkgs/development/python-modules/llm-command-r/tests/llm-plugin.nix @@ -0,0 +1,22 @@ +{ + runCommand, + python, + yq, +}: +let + venv = python.withPackages (ps: [ + ps.llm + ps.llm-anthropic + ]); +in +runCommand "llm-anthropic-test-llm-plugin" + { + nativeBuildInputs = [ + venv + yq + ]; + } + '' + llm plugins | yq --exit-status 'any(.name == "llm-anthropic")' + touch "$out" + '' diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 16103e129f42..6249fa645fd5 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -8298,6 +8298,8 @@ self: super: with self; { llm-cmd = callPackage ../development/python-modules/llm-cmd { }; + llm-command-r = callPackage ../development/python-modules/llm-command-r { }; + llm-gemini = callPackage ../development/python-modules/llm-gemini { }; llm-gguf = callPackage ../development/python-modules/llm-gguf { };