diff --git a/pkgs/development/python-modules/llm-openai-plugin/default.nix b/pkgs/development/python-modules/llm-openai-plugin/default.nix new file mode 100644 index 000000000000..0eec14a4d981 --- /dev/null +++ b/pkgs/development/python-modules/llm-openai-plugin/default.nix @@ -0,0 +1,59 @@ +{ + lib, + callPackage, + buildPythonPackage, + fetchFromGitHub, + setuptools, + llm, + openai, + pytestCheckHook, + pytest-asyncio, + pytest-recording, + syrupy, + cogapp, + writableTmpDirAsHomeHook, +}: +buildPythonPackage rec { + pname = "llm-openai-plugin"; + version = "0.3"; + pyproject = true; + + src = fetchFromGitHub { + owner = "simonw"; + repo = "llm-openai-plugin"; + tag = version; + hash = "sha256-WpaxXJQXz9vkqtlQbi4NxLnX5j4UDLdQXwCEhDwkvm4="; + }; + + build-system = [ + setuptools + ]; + + dependencies = [ + llm + openai + ]; + + nativeCheckInputs = [ + pytestCheckHook + pytest-asyncio + pytest-recording + syrupy + cogapp + writableTmpDirAsHomeHook + ]; + + pythonImportsCheck = [ "llm_openai" ]; + + passthru.tests = { + llm-plugin = callPackage ./tests/llm-plugin.nix { }; + }; + + meta = { + description = "OpenAI plugin for LLM"; + homepage = "https://github.com/simonw/llm-openai-plugin"; + changelog = "https://github.com/simonw/llm-openai-plugin/releases/tag/${src.tag}"; + license = lib.licenses.asl20; + maintainers = with lib.maintainers; [ josh ]; + }; +} diff --git a/pkgs/development/python-modules/llm-openai-plugin/tests/llm-plugin.nix b/pkgs/development/python-modules/llm-openai-plugin/tests/llm-plugin.nix new file mode 100644 index 000000000000..8092b15a5c90 --- /dev/null +++ b/pkgs/development/python-modules/llm-openai-plugin/tests/llm-plugin.nix @@ -0,0 +1,22 @@ +{ + runCommand, + python, + yq, +}: +let + venv = python.withPackages (ps: [ + ps.llm + ps.llm-openai-plugin + ]); +in +runCommand "llm-openai-plugin-test-llm-plugin" + { + nativeBuildInputs = [ + venv + yq + ]; + } + '' + llm plugins | yq --exit-status 'any(.name == "llm-openai-plugin")' + touch "$out" + '' diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 6a6a77d1ea23..6ab1d23a3b94 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -8124,6 +8124,8 @@ self: super: with self; { llm-ollama = callPackage ../development/python-modules/llm-ollama { }; + llm-openai-plugin = callPackage ../development/python-modules/llm-openai-plugin { }; + llmx = callPackage ../development/python-modules/llmx { }; llvmlite = callPackage ../development/python-modules/llvmlite {