1{
2 lib,
3 aiohttp,
4 anthropic,
5 buildPythonPackage,
6 docstring-parser,
7 fetchFromGitHub,
8 openai,
9 poetry-core,
10 pydantic,
11 pytest-examples,
12 pytest-asyncio,
13 pytestCheckHook,
14 fastapi,
15 diskcache,
16 redis,
17 pythonOlder,
18 pythonRelaxDepsHook,
19 rich,
20 tenacity,
21 typer,
22}:
23
24buildPythonPackage rec {
25 pname = "instructor";
26 version = "1.2.3";
27 pyproject = true;
28
29 disabled = pythonOlder "3.9";
30
31 src = fetchFromGitHub {
32 owner = "jxnl";
33 repo = "instructor";
34 rev = "refs/tags/${version}";
35 hash = "sha256-LmorlFKIG7iPAK4pDbQqjxjiwB1md3u52B4u5WlqqTk=";
36 };
37
38 pythonRelaxDeps = [
39 "docstring-parser"
40 "pydantic"
41 ];
42
43 build-system = [ poetry-core ];
44
45 nativeBuildInputs = [ pythonRelaxDepsHook ];
46
47 dependencies = [
48 aiohttp
49 docstring-parser
50 openai
51 pydantic
52 rich
53 tenacity
54 typer
55 ];
56
57 nativeCheckInputs = [
58 anthropic
59 fastapi
60 redis
61 diskcache
62 pytest-asyncio
63 pytest-examples
64 pytestCheckHook
65 ];
66
67 pythonImportsCheck = [ "instructor" ];
68
69 disabledTests = [
70 # Tests require OpenAI API key
71 "test_partial"
72 "successfully"
73 ];
74
75 disabledTestPaths = [
76 # Tests require OpenAI API key
77 "tests/test_distil.py"
78 "tests/test_new_client.py"
79 "tests/llm/"
80 ];
81
82 meta = with lib; {
83 description = "Structured outputs for llm";
84 homepage = "https://github.com/jxnl/instructor";
85 changelog = "https://github.com/jxnl/instructor/releases/tag/v${version}";
86 license = licenses.mit;
87 maintainers = with maintainers; [ mic92 ];
88 mainProgram = "instructor";
89 };
90}