1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5
6 # build-system
7 setuptools,
8 setuptools-scm,
9
10 # dependencies
11 airportsdata,
12 cloudpickle,
13 datasets,
14 diskcache,
15 genson,
16 interegular,
17 iso3166,
18 jinja2,
19 jsonschema,
20 lark,
21 nest-asyncio,
22 numpy,
23 outlines-core,
24 pycountry,
25 pydantic,
26 referencing,
27 requests,
28 torch,
29 transformers,
30
31 # tests
32 anthropic,
33 google-genai,
34 jax,
35 llama-cpp-python,
36 ollama,
37 openai,
38 pytest-asyncio,
39 pytest-mock,
40 pytestCheckHook,
41 tensorflow,
42}:
43
44buildPythonPackage rec {
45 pname = "outlines";
46 version = "1.2.3";
47 pyproject = true;
48
49 src = fetchFromGitHub {
50 owner = "outlines-dev";
51 repo = "outlines";
52 tag = version;
53 hash = "sha256-t1YSkFC56De9HkdDJN9WIpKDdHxZRfGRbFOtAiJxKUI=";
54 };
55
56 build-system = [
57 setuptools
58 setuptools-scm
59 ];
60
61 dependencies = [
62 airportsdata
63 cloudpickle
64 datasets
65 diskcache
66 genson
67 interegular
68 iso3166
69 jinja2
70 jsonschema
71 lark
72 nest-asyncio
73 numpy
74 outlines-core
75 pycountry
76 pydantic
77 referencing
78 requests
79 torch
80 transformers
81 ];
82
83 pythonImportsCheck = [ "outlines" ];
84
85 nativeCheckInputs = [
86 anthropic
87 google-genai
88 jax
89 llama-cpp-python
90 ollama
91 openai
92 pytest-asyncio
93 pytest-mock
94 pytestCheckHook
95 tensorflow
96 ];
97
98 pytestFlagsArray = [
99 # FutureWarning: functools.partial will be a method descriptor in future Python versions; wrap it in enum.member() if you want to preserve the old behavior
100 "-Wignore::FutureWarning"
101 ];
102
103 disabledTests = [
104 # Try to dowload models from Hugging Face Hub
105 "test_application_callable_call"
106 "test_application_generator_reuse"
107 "test_application_template_call"
108 "test_application_template_error"
109 "test_generator_black_box_async_processor"
110 "test_generator_black_box_sync_processor"
111 "test_generator_init_multiple_output_type"
112 "test_generator_steerable_output_type"
113 "test_generator_steerable_processor"
114 "test_llamacpp_type_adapter_format_output_type"
115 "test_steerable_generator_call"
116 "test_steerable_generator_init_cfg_output_type"
117 "test_steerable_generator_init_invalid_output_type"
118 "test_steerable_generator_init_other_output_type"
119 "test_steerable_generator_init_valid_processor"
120 "test_steerable_generator_stream"
121 "test_transformer_tokenizer_convert_token_to_string"
122 "test_transformer_tokenizer_decode"
123 "test_transformer_tokenizer_encode"
124 "test_transformer_tokenizer_eq"
125 "test_transformer_tokenizer_getstate_setstate"
126 "test_transformer_tokenizer_hash"
127 "test_transformer_tokenizer_init"
128
129 # TypeError: "Could not resolve authentication method.
130 # Expected either api_key or auth_token to be set.
131 # Or for one of the `X-Api-Key` or `Authorization` headers to be explicitly omitted.
132 "test_anthopic_streaming"
133 "test_anthropic_chat"
134 "test_anthropic_simple_call"
135 "test_anthropic_simple_vision"
136
137 # ConnectionError: Failed to connect to Ollama.
138 "test_ollama_async_chat"
139 "test_ollama_async_direct"
140 "test_ollama_async_json"
141 "test_ollama_async_simple"
142 "test_ollama_async_simple_vision"
143 "test_ollama_async_stream"
144 "test_ollama_async_stream_json"
145 "test_ollama_chat"
146 "test_ollama_direct"
147 "test_ollama_json"
148 "test_ollama_simple"
149 "test_ollama_simple_vision"
150 "test_ollama_stream"
151 "test_ollama_stream_json"
152
153 # openai.APIConnectionError: Connection error.
154 "test_openai_async_chat"
155 "test_openai_async_direct_call"
156 "test_openai_async_simple_call"
157 "test_openai_async_simple_call_multiple_samples"
158 "test_openai_async_simple_json_schema"
159 "test_openai_async_simple_pydantic"
160 "test_openai_async_simple_pydantic_refusal"
161 "test_openai_async_simple_vision"
162 "test_openai_async_simple_vision_pydantic"
163 "test_openai_async_streaming"
164 "test_openai_chat"
165 "test_openai_direct_call"
166 "test_openai_simple_call"
167 "test_openai_simple_call_multiple_samples"
168 "test_openai_simple_json_schema"
169 "test_openai_simple_pydantic"
170 "test_openai_simple_pydantic_refusal"
171 "test_openai_simple_vision"
172 "test_openai_simple_vision_pydantic"
173 "test_openai_streaming"
174 ];
175
176 disabledTestPaths = [
177 # Try to dowload models from Hugging Face Hub
178 "tests/backends/test_backends.py"
179 "tests/backends/test_llguidance.py"
180 "tests/backends/test_outlines_core.py"
181 "tests/backends/test_xgrammar.py"
182 "tests/models/test_llamacpp.py"
183 "tests/models/test_llamacpp_tokenizer.py"
184 "tests/models/test_transformers.py"
185 "tests/models/test_transformers_multimodal.py"
186 "tests/models/test_transformers_multimodal_type_adapter.py"
187 "tests/models/test_transformers_type_adapter.py"
188
189 # Requires unpackaged dottxt
190 "tests/models/test_dottxt.py"
191
192 # ValueError: Missing key inputs argument! To use the Google AI API, provide (`api_key`) arguments.
193 "tests/models/test_gemini.py"
194 ];
195
196 meta = {
197 description = "Structured text generation";
198 homepage = "https://github.com/outlines-dev/outlines";
199 changelog = "https://github.com/dottxt-ai/outlines/releases/tag/${version}";
200 license = lib.licenses.asl20;
201 maintainers = with lib.maintainers; [ lach ];
202 };
203}