1{ buildPythonPackage
2, eliot
3, fetchPypi
4, google-search-results
5, jinja2
6, lib
7, manifest-ml
8, openai
9, pytestCheckHook
10, pythonAtLeast
11, pythonRelaxDepsHook
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 nativeBuildInputs = [ pythonRelaxDepsHook ];
35
36 pythonRemoveDeps = [
37 # Only used in the examples:
38 "datasets"
39 "faiss-cpu"
40 "jinja2-highlight"
41 "trio"
42
43 # Not used anywhere:
44 "eliot-tree"
45
46 # Not yet packaged in nixpkgs:
47 "gradio"
48 ];
49
50 # Some of these could be made optional. Certain packages are used by certain backends.
51 propagatedBuildInputs = [
52 eliot
53 google-search-results
54 jinja2
55 manifest-ml
56 openai
57 ];
58
59 # As of 0.3.3, the PyPI distribution does not include any tests.
60 doCheck = false;
61
62 pythonImportsCheck = [ "minichain" ];
63
64 nativeCheckInputs = [ pytestCheckHook ];
65
66 meta = with lib; {
67 description = "A tiny library for coding with large language models";
68 homepage = "https://srush-minichain.hf.space";
69 changelog = "https://github.com/srush/MiniChain/releases/tag/v${version}";
70 license = licenses.mit;
71 maintainers = with maintainers; [ samuela ];
72 };
73}