1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
|
{
lib,
config,
buildPythonPackage,
fetchFromGitHub,
# build-system
setuptools,
setuptools-scm,
# dependencies
cloudpickle,
datasets,
diskcache,
genson,
interegular,
jinja2,
jsonschema,
lark,
nest-asyncio,
numpy,
outlines-core,
pycountry,
pydantic,
torch,
transformers,
# tests
airportsdata,
anthropic,
google-genai,
iso3166,
jax,
llama-cpp-python,
mistralai,
ollama,
openai,
pytest-asyncio,
pytest-mock,
pytestCheckHook,
tensorflow,
}:
buildPythonPackage rec {
pname = "outlines";
version = "1.2.9";
pyproject = true;
src = fetchFromGitHub {
owner = "outlines-dev";
repo = "outlines";
tag = version;
hash = "sha256-QuS8IokiOPJeh59+W4FLoE9dvBCChf2li70+Ex3aIwg=";
};
build-system = [
setuptools
setuptools-scm
];
pythonRelaxDeps = [
"outlines_core"
];
dependencies = [
cloudpickle
datasets
diskcache
genson
interegular
jinja2
jsonschema
lark
nest-asyncio
numpy
outlines-core
pycountry
pydantic
torch
transformers
];
# llama_cpp dependency cannot be imported when cudaSupport is enabled as it tries to load libcuda.so.1.
# This library is provided by the nvidia driver at runtime, but isn't available in the sandbox.
pythonImportsCheck = lib.optionals (!config.cudaSupport) [
"outlines"
];
# We also have to give up on tests for the same reason.
doCheck = !config.cudaSupport;
nativeCheckInputs = [
airportsdata
anthropic
google-genai
iso3166
jax
llama-cpp-python
mistralai
ollama
openai
pytest-asyncio
pytest-mock
pytestCheckHook
tensorflow
];
pytestFlagsArray = [
# 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
"-Wignore::FutureWarning"
];
disabledTests = [
# Try to dowload models from Hugging Face Hub
"test_application_callable_call"
"test_application_generator_reuse"
"test_application_template_call"
"test_application_template_error"
"test_generator_black_box_async_processor"
"test_generator_black_box_sync_processor"
"test_generator_init_multiple_output_type"
"test_generator_steerable_output_type"
"test_generator_steerable_processor"
"test_llamacpp_type_adapter_format_output_type"
"test_steerable_generator_call"
"test_steerable_generator_init_cfg_output_type"
"test_steerable_generator_init_invalid_output_type"
"test_steerable_generator_init_other_output_type"
"test_steerable_generator_init_valid_processor"
"test_steerable_generator_stream"
"test_transformer_tokenizer_convert_token_to_string"
"test_transformer_tokenizer_decode"
"test_transformer_tokenizer_encode"
"test_transformer_tokenizer_eq"
"test_transformer_tokenizer_getstate_setstate"
"test_transformer_tokenizer_hash"
"test_transformer_tokenizer_init"
# TypeError: "Could not resolve authentication method.
# Expected either api_key or auth_token to be set.
# Or for one of the `X-Api-Key` or `Authorization` headers to be explicitly omitted.
"test_anthopic_streaming"
"test_anthropic_chat"
"test_anthropic_simple_call"
"test_anthropic_simple_vision"
# ConnectionError: Failed to connect to Ollama.
"test_ollama_async_chat"
"test_ollama_async_direct"
"test_ollama_async_json"
"test_ollama_async_simple"
"test_ollama_async_simple_vision"
"test_ollama_async_stream"
"test_ollama_async_stream_json"
"test_ollama_chat"
"test_ollama_direct"
"test_ollama_json"
"test_ollama_simple"
"test_ollama_simple_vision"
"test_ollama_stream"
"test_ollama_stream_json"
# openai.APIConnectionError: Connection error.
"test_openai_async_chat"
"test_openai_async_direct_call"
"test_openai_async_simple_call"
"test_openai_async_simple_call_multiple_samples"
"test_openai_async_simple_json_schema"
"test_openai_async_simple_pydantic"
"test_openai_async_simple_pydantic_refusal"
"test_openai_async_simple_vision"
"test_openai_async_simple_vision_pydantic"
"test_openai_async_streaming"
"test_openai_chat"
"test_openai_direct_call"
"test_openai_simple_call"
"test_openai_simple_call_multiple_samples"
"test_openai_simple_json_schema"
"test_openai_simple_pydantic"
"test_openai_simple_pydantic_refusal"
"test_openai_simple_vision"
"test_openai_simple_vision_pydantic"
"test_openai_streaming"
# RuntimeError: Mistral API error: [Errno -3] Temporary failure in name resolution
"test_mistral_async_call"
"test_mistral_async_call_model_name"
"test_mistral_async_chat"
"test_mistral_async_json_schema"
"test_mistral_async_multiple_samples"
"test_mistral_async_pydantic"
"test_mistral_async_pydantic_refusal"
"test_mistral_async_streaming"
"test_mistral_async_vision"
"test_mistral_async_vision_pydantic"
"test_mistral_call"
"test_mistral_call_model_name"
"test_mistral_chat"
"test_mistral_json_schema"
"test_mistral_multiple_samples"
"test_mistral_pydantic"
"test_mistral_pydantic_refusal"
"test_mistral_streaming"
"test_mistral_vision"
"test_mistral_vision_pydantic"
];
disabledTestPaths = [
# Try to dowload models from Hugging Face Hub
"tests/backends/test_backends.py"
"tests/backends/test_llguidance.py"
"tests/backends/test_outlines_core.py"
"tests/backends/test_xgrammar.py"
"tests/models/test_llamacpp.py"
"tests/models/test_llamacpp_tokenizer.py"
"tests/models/test_transformers.py"
"tests/models/test_transformers_multimodal.py"
"tests/models/test_transformers_multimodal_type_adapter.py"
"tests/models/test_transformers_type_adapter.py"
# Requires unpackaged dottxt
"tests/models/test_dottxt.py"
# ValueError: Missing key inputs argument! To use the Google AI API, provide (`api_key`) arguments.
"tests/models/test_gemini.py"
];
meta = {
description = "Structured text generation";
homepage = "https://github.com/outlines-dev/outlines";
changelog = "https://github.com/dottxt-ai/outlines/releases/tag/${version}";
license = lib.licenses.asl20;
maintainers = with lib.maintainers; [ lach ];
};
}
|