1{
2 buildPythonPackage,
3 eliot,
4 fetchPypi,
5 google-search-results,
6 jinja2,
7 lib,
8 manifest-ml,
9 openai,
10 pytestCheckHook,
11 pythonAtLeast,
12}:
13
14buildPythonPackage rec {
15 pname = "minichain";
16 version = "0.3.3";
17 format = "setuptools";
18
19 # See https://github.com/NixOS/nixpkgs/pull/248195#issuecomment-1687398702.
20 disabled = pythonAtLeast "3.11";
21
22 # See https://github.com/srush/MiniChain/issues/23 and https://github.com/NixOS/nixpkgs/issues/248185 as to why we
23 # don't fetchFromGitHub.
24 src = fetchPypi {
25 inherit pname version;
26 hash = "sha256-+mju1Mz/aojROpiOVzv6WoRNTrhgCub4yyYLEWcHWh0=";
27 };
28
29 # See https://github.com/srush/MiniChain/issues/24.
30 postPatch = ''
31 substituteInPlace ./minichain/__init__.py --replace "from .gradio import GradioConf, show" ""
32 '';
33
34 pythonRemoveDeps = [
35 # Only used in the examples:
36 "datasets"
37 "faiss-cpu"
38 "jinja2-highlight"
39 "trio"
40
41 # Not used anywhere:
42 "eliot-tree"
43
44 # Not yet packaged in nixpkgs:
45 "gradio"
46 ];
47
48 # Some of these could be made optional. Certain packages are used by certain backends.
49 propagatedBuildInputs = [
50 eliot
51 google-search-results
52 jinja2
53 manifest-ml
54 openai
55 ];
56
57 # As of 0.3.3, the PyPI distribution does not include any tests.
58 doCheck = false;
59
60 pythonImportsCheck = [ "minichain" ];
61
62 nativeCheckInputs = [ pytestCheckHook ];
63
64 meta = with lib; {
65 description = "Tiny library for coding with large language models";
66 homepage = "https://srush-minichain.hf.space";
67 changelog = "https://github.com/srush/MiniChain/releases/tag/v${version}";
68 license = licenses.mit;
69 maintainers = with maintainers; [ samuela ];
70 };
71}