blob: 185ab306b71d962e2e5e48e876f32440373d9fac (
plain)
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
|
{
lib,
buildPythonPackage,
fetchFromGitHub,
general-sam,
setuptools,
kbnf,
frozendict,
jsonschema,
pydantic,
transformers,
vllm,
}:
buildPythonPackage rec {
pname = "formatron";
version = "0.5.0";
pyproject = true;
src = fetchFromGitHub {
owner = "Dan-wanna-M";
repo = "formatron";
rev = "v${version}";
hash = "sha256-LQJza8F5wPcQO1y7Ino4slv7zoJMsZBn4LKLWYO9818=";
fetchSubmodules = true;
};
postPatch = ''
# Fix pydantic compatibility
# https://github.com/Dan-wanna-M/formatron/issues/35
substituteInPlace src/formatron/schemas/dict_inference.py \
--replace-fail 'typing.Type' 'Type' \
--replace-fail 'typing.Any' 'Any'
substituteInPlace src/formatron/schemas/json_schema.py \
--replace-fail 'from pydantic import typing' 'import typing'
'';
build-system = [
setuptools
];
dependencies = [
frozendict
general-sam
jsonschema
kbnf
pydantic
];
optional-dependencies = {
transformers = [
transformers
];
vllm = [
vllm
];
};
pythonImportsCheck = [
"formatron"
];
meta = {
description = "Control the output format of language models";
homepage = "https://github.com/Dan-wanna-M/formatron";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ BatteredBunny ];
};
}
|