1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 pytestCheckHook,
6 pythonOlder,
7 setuptools,
8 click-default-group,
9 numpy,
10 openai,
11 pip,
12 pluggy,
13 puremagic,
14 pydantic,
15 python-ulid,
16 pyyaml,
17 sqlite-migrate,
18 cogapp,
19 pytest-httpx,
20 sqlite-utils,
21}:
22let
23 llm = buildPythonPackage rec {
24 pname = "llm";
25 version = "0.19.1";
26 pyproject = true;
27
28 build-system = [ setuptools ];
29
30 disabled = pythonOlder "3.8";
31
32 src = fetchFromGitHub {
33 owner = "simonw";
34 repo = "llm";
35 tag = version;
36 hash = "sha256-MMqlcKSvBAdM6Xfz3MQTIbCfWEqzVeCPzuJJzFVpxb4=";
37 };
38
39 patches = [ ./001-disable-install-uninstall-commands.patch ];
40
41 dependencies = [
42 click-default-group
43 numpy
44 openai
45 pip
46 pluggy
47 puremagic
48 pydantic
49 python-ulid
50 pyyaml
51 setuptools # for pkg_resources
52 sqlite-migrate
53 sqlite-utils
54 ];
55
56 nativeCheckInputs = [
57 cogapp
58 numpy
59 pytest-httpx
60 pytestCheckHook
61 ];
62
63 doCheck = true;
64
65 pytestFlagsArray = [
66 "-svv"
67 "tests/"
68 ];
69
70 pythonImportsCheck = [ "llm" ];
71
72 passthru = {
73 inherit withPlugins;
74 };
75
76 meta = with lib; {
77 homepage = "https://github.com/simonw/llm";
78 description = "Access large language models from the command-line";
79 changelog = "https://github.com/simonw/llm/releases/tag/${version}";
80 license = licenses.asl20;
81 mainProgram = "llm";
82 maintainers = with maintainers; [
83 aldoborrero
84 mccartykim
85 ];
86 };
87 };
88
89 withPlugins = throw ''
90 llm.withPlugins was confusing to use and has been removed.
91 Please migrate to using python3.withPackages(ps: [ ps.llm ]) instead.
92
93 See https://nixos.org/manual/nixpkgs/stable/#python.withpackages-function for more usage examples.
94 '';
95in
96llm