From ddfc6cef59f47d6e3713acae619dda1ca4740ed0 Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Thu, 24 Apr 2025 19:56:27 -0700 Subject: build python packages for llm To get a more recent version of the llm python tool and the anthropic module, we need to build the packages ourselves. Refactor how we're building overlays to make it easier to add new packages using the `pkgsUnstable` set. --- pkgs/llmPython/default.nix | 85 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 pkgs/llmPython/default.nix (limited to 'pkgs/llmPython/default.nix') diff --git a/pkgs/llmPython/default.nix b/pkgs/llmPython/default.nix new file mode 100644 index 0000000..0f53218 --- /dev/null +++ b/pkgs/llmPython/default.nix @@ -0,0 +1,85 @@ +{ + pkgs, + pkgsUnstable, + lib, + ... +}: +let + # Define all packages in a recursive attribute set + pythonPackages = rec { + llm = pkgsUnstable.python3.pkgs.buildPythonPackage rec { + pname = "llm"; + version = "0.24.2"; + format = "setuptools"; + + src = pkgsUnstable.fetchurl { + url = "https://files.pythonhosted.org/packages/source/l/llm/llm-0.24.2.tar.gz"; + sha256 = "sha256-4U8nIhg4hM4JaSIBtUzdlhlCSS8Nk8p0mmLQKzuL9Do="; + }; + + # Dependencies + propagatedBuildInputs = with pkgsUnstable.python3.pkgs; [ + pyyaml + click + click-default-group + condense-json + openai + pip + pluggy + puremagic + pydantic + python-ulid + setuptools + sqlite-migrate + sqlite-utils + ]; + + # Disable tests - enable if you have specific test dependencies + doCheck = false; + + # Basic import check + pythonImportsCheck = [ "llm" ]; + + meta = with lib; { + description = "CLI utility and Python library for interacting with Large Language Models from organizations like OpenAI, Anthropic and Gemini plus local models installed on your own machine."; + homepage = "https://github.com/simonw/llm"; + license = licenses.asl20; + }; + }; + + # Note, these are available in nixpkgs unstable, but are still behind the latest versions + llm-anthropic = pkgsUnstable.python3.pkgs.buildPythonPackage rec { + pname = "llm-anthropic"; + version = "0.15.1"; + format = "pyproject"; + + src = pkgs.fetchurl { + url = "https://files.pythonhosted.org/packages/source/l/llm_anthropic/llm_anthropic-0.15.1.tar.gz"; + sha256 = "sha256-C8xNs4oS51YxAn1iJkk8j4sJ5dO0pVOwIiP4mv/MnQk="; + }; + + nativeBuildInputs = with pkgsUnstable.python3.pkgs; [ + setuptools + wheel + ]; + # Dependencies + propagatedBuildInputs = with pkgsUnstable.python3.pkgs; [ + anthropic + llm # Use the llm we defined above + ]; + + # Disable tests - enable if you have specific test dependencies + doCheck = false; + + # Basic import check + pythonImportsCheck = [ "llm_anthropic" ]; + + meta = with lib; { + description = "LLM access to models by Anthropic, including the Claude series"; + homepage = "https://github.com/simonw/llm-anthropic"; + license = licenses.asl20; + }; + }; + }; +in +pythonPackages -- cgit v1.2.3