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