1{ 2 lib, 3 buildPythonPackage, 4 fetchFromGitHub, 5 6 # build-system 7 pybind11, 8 setuptools, 9 10 # dependencies 11 diskcache, 12 guidance-stitch, 13 llguidance, 14 numpy, 15 ordered-set, 16 platformdirs, 17 psutil, 18 pydantic, 19 referencing, 20 requests, 21 tiktoken, 22 23 # optional-dependencies 24 openai, 25 jsonschema, 26 fastapi, 27 uvicorn, 28 29 # tests 30 huggingface-hub, 31 pytestCheckHook, 32 tokenizers, 33 torch, 34 writableTmpDirAsHomeHook, 35}: 36 37buildPythonPackage rec { 38 pname = "guidance"; 39 version = "0.2.1"; 40 pyproject = true; 41 42 src = fetchFromGitHub { 43 owner = "guidance-ai"; 44 repo = "guidance"; 45 tag = version; 46 hash = "sha256-FBnND9kCIVmE/IEz3TNOww8x0EAH6TTBYfKTprqSbDg="; 47 }; 48 49 build-system = [ 50 pybind11 51 setuptools 52 ]; 53 54 pythonRelaxDeps = [ 55 "llguidance" 56 ]; 57 58 dependencies = [ 59 diskcache 60 guidance-stitch 61 llguidance 62 numpy 63 ordered-set 64 platformdirs 65 psutil 66 pydantic 67 referencing 68 requests 69 tiktoken 70 ]; 71 72 optional-dependencies = { 73 azureai = [ openai ]; 74 openai = [ openai ]; 75 schemas = [ jsonschema ]; 76 server = [ 77 fastapi 78 uvicorn 79 ]; 80 }; 81 82 nativeCheckInputs = [ 83 huggingface-hub 84 pytestCheckHook 85 tokenizers 86 torch 87 writableTmpDirAsHomeHook 88 ] ++ optional-dependencies.schemas; 89 90 pytestFlagsArray = [ "tests/unit" ]; 91 92 disabledTests = [ 93 # require network access 94 "test_ll_backtrack_stop" 95 "test_ll_dolphin" 96 "test_ll_fighter" 97 "test_ll_max_tokens" 98 "test_ll_nice_man" 99 "test_ll_nullable_bug" 100 "test_ll_nullable_lexeme" 101 "test_ll_pop_tokens" 102 "test_ll_stop_quote_comma" 103 "test_llparser" 104 "test_str_method_smoke" 105 106 # flaky tests 107 "test_remote_mock_gen" # frequently fails when building packages in parallel 108 ]; 109 110 preCheck = '' 111 rm tests/conftest.py 112 ''; 113 114 pythonImportsCheck = [ "guidance" ]; 115 116 __darwinAllowLocalNetworking = true; 117 118 meta = { 119 description = "Guidance language for controlling large language models"; 120 homepage = "https://github.com/guidance-ai/guidance"; 121 changelog = "https://github.com/guidance-ai/guidance/releases/tag/v${version}"; 122 license = lib.licenses.mit; 123 maintainers = with lib.maintainers; [ natsukium ]; 124 }; 125}