1{ 2 lib, 3 buildPythonPackage, 4 fetchFromGitHub, 5 pythonOlder, 6 7 # build-system 8 hatchling, 9 10 # dependencies 11 aiohttp, 12 docstring-parser, 13 jinja2, 14 jiter, 15 openai, 16 pydantic, 17 requests, 18 rich, 19 tenacity, 20 typer, 21 22 # tests 23 anthropic, 24 diskcache, 25 fastapi, 26 google-generativeai, 27 pytest-asyncio, 28 pytestCheckHook, 29 python-dotenv, 30 redis, 31}: 32 33buildPythonPackage rec { 34 pname = "instructor"; 35 version = "1.7.9"; 36 pyproject = true; 37 38 disabled = pythonOlder "3.9"; 39 40 src = fetchFromGitHub { 41 owner = "jxnl"; 42 repo = "instructor"; 43 tag = version; 44 hash = "sha256-3IwvbepDrylOIlL+IteyFChqYc/ZIu6IieIkbAPL+mw="; 45 }; 46 47 build-system = [ hatchling ]; 48 49 pythonRelaxDeps = [ "rich" ]; 50 51 dependencies = [ 52 aiohttp 53 docstring-parser 54 jinja2 55 jiter 56 openai 57 pydantic 58 requests 59 rich 60 tenacity 61 typer 62 ]; 63 64 nativeCheckInputs = [ 65 anthropic 66 diskcache 67 fastapi 68 google-generativeai 69 pytest-asyncio 70 pytestCheckHook 71 python-dotenv 72 redis 73 ]; 74 75 pythonImportsCheck = [ "instructor" ]; 76 77 disabledTests = [ 78 # Tests require OpenAI API key 79 "successfully" 80 "test_mode_functions_deprecation_warning" 81 "test_partial" 82 83 # Requires unpackaged `vertexai` 84 "test_json_preserves_description_of_non_english_characters_in_json_mode" 85 86 # Checks magic values and this fails on Python 3.13 87 "test_raw_base64_autodetect_jpeg" 88 "test_raw_base64_autodetect_png" 89 90 # Performance benchmarks that sometimes fail when running many parallel builds 91 "test_combine_system_messages_benchmark" 92 "test_extract_system_messages_benchmark" 93 ]; 94 95 disabledTestPaths = [ 96 # Tests require OpenAI API key 97 "tests/test_distil.py" 98 "tests/llm/" 99 ]; 100 101 meta = { 102 description = "Structured outputs for llm"; 103 homepage = "https://github.com/jxnl/instructor"; 104 changelog = "https://github.com/jxnl/instructor/releases/tag/${src.tag}"; 105 license = lib.licenses.mit; 106 maintainers = with lib.maintainers; [ mic92 ]; 107 mainProgram = "instructor"; 108 }; 109}