nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5
6 # build-system
7 setuptools,
8
9 # dependencies
10 jsonschema,
11 numpy,
12 opencv-python-headless,
13 pillow,
14 pydantic,
15 pydantic-extra-types,
16 requests,
17 sentencepiece,
18 tiktoken,
19 typing-extensions,
20
21 # tests
22 click,
23 fastapi,
24 huggingface-hub,
25 openai,
26 pycountry,
27 pydantic-settings,
28 pytestCheckHook,
29 soundfile,
30 soxr,
31 uvicorn,
32}:
33
34buildPythonPackage rec {
35 pname = "mistral-common";
36 version = "1.8.8";
37 pyproject = true;
38
39 src = fetchFromGitHub {
40 owner = "mistralai";
41 repo = "mistral-common";
42 tag = "v${version}";
43 hash = "sha256-rvW2idAqdCZi7+DsHJXczJKbfceZQ4lQyHScLOqxFIc=";
44 };
45
46 build-system = [ setuptools ];
47
48 dependencies = [
49 jsonschema
50 numpy
51 opencv-python-headless
52 pillow
53 pydantic
54 pydantic-extra-types
55 requests
56 sentencepiece
57 tiktoken
58 typing-extensions
59 ];
60
61 optional-dependencies = lib.fix (self: {
62 opencv = [
63 opencv-python-headless
64 ];
65 sentencepiece = [
66 sentencepiece
67 ];
68 soundfile = [
69 soundfile
70 ];
71 soxr = [
72 soxr
73 ];
74 audio = self.soundfile ++ self.soxr;
75 image = self.opencv;
76 hf-hub = [
77 huggingface-hub
78 ];
79 server = [
80 click
81 fastapi
82 pydantic-settings
83 ]
84 ++ fastapi.optional-dependencies.standard;
85 });
86
87 pythonImportsCheck = [ "mistral_common" ];
88
89 nativeCheckInputs = [
90 click
91 fastapi
92 huggingface-hub
93 openai
94 pycountry
95 pydantic-settings
96 pytestCheckHook
97 soundfile
98 soxr
99 uvicorn
100 ];
101
102 disabledTests = [
103 # Require internet
104 "test_download_gated_image"
105 "test_image_encoder_formats"
106 "test_image_processing"
107
108 # AssertionError: Regex pattern did not match.
109 "test_from_url"
110
111 # AssertionError, Extra items in the right set
112 "test_openai_chat_fields"
113 ];
114
115 meta = {
116 description = "Tools to help you work with Mistral models";
117 homepage = "https://github.com/mistralai/mistral-common";
118 changelog = "https://github.com/mistralai/mistral-common/releases/tag/v${version}";
119 license = lib.licenses.asl20;
120 maintainers = with lib.maintainers; [ bgamari ];
121 };
122}