Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at gcc-offload 151 lines 4.2 kB view raw
1{ 2 lib, 3 stdenv, 4 buildPythonPackage, 5 fetchFromGitHub, 6 7 # build-system 8 poetry-core, 9 10 # dependencies 11 jsonpatch, 12 langsmith, 13 packaging, 14 pyyaml, 15 tenacity, 16 17 # optional-dependencies 18 pydantic, 19 20 # tests 21 freezegun, 22 grandalf, 23 httpx, 24 numpy, 25 pytest-asyncio, 26 pytest-mock, 27 pytest-xdist, 28 pytestCheckHook, 29 syrupy, 30 31 # passthru 32 writeScript, 33}: 34 35buildPythonPackage rec { 36 pname = "langchain-core"; 37 version = "0.3.15"; 38 pyproject = true; 39 40 src = fetchFromGitHub { 41 owner = "langchain-ai"; 42 repo = "langchain"; 43 rev = "refs/tags/langchain-core==${version}"; 44 hash = "sha256-lSXAqjjnihuucTZOSwQJk8gtrtFbUOTHN4J587iLKy0="; 45 }; 46 47 sourceRoot = "${src.name}/libs/core"; 48 49 build-system = [ poetry-core ]; 50 51 pythonRelaxDeps = [ "tenacity" ]; 52 53 dependencies = [ 54 jsonpatch 55 langsmith 56 packaging 57 pyyaml 58 tenacity 59 ]; 60 61 optional-dependencies = { 62 pydantic = [ pydantic ]; 63 }; 64 65 pythonImportsCheck = [ "langchain_core" ]; 66 67 nativeCheckInputs = [ 68 freezegun 69 grandalf 70 httpx 71 numpy 72 pytest-asyncio 73 pytest-mock 74 pytest-xdist 75 pytestCheckHook 76 syrupy 77 ]; 78 79 pytestFlagsArray = [ "tests/unit_tests" ]; 80 81 # don't add langchain-standard-tests to nativeCheckInputs 82 # to avoid circular import 83 preCheck = '' 84 export PYTHONPATH=${src}/libs/standard-tests:$PYTHONPATH 85 ''; 86 87 passthru = { 88 # Updates to core tend to drive updates in everything else 89 updateScript = writeScript "update.sh" '' 90 #!/usr/bin/env nix-shell 91 #!nix-shell -i bash -p nix-update 92 93 set -u -o pipefail +e 94 # Common core 95 nix-update --commit --version-regex 'langchain-core==(.*)' python3Packages.langchain-core 96 nix-update --commit --version-regex 'langchain-text-splitters==(.*)' python3Packages.langchain-text-splitters 97 nix-update --commit --version-regex 'langchain==(.*)' python3Packages.langchain 98 nix-update --commit --version-regex 'langchain-community==(.*)' python3Packages.langchain-community 99 100 # Extensions 101 nix-update --commit --version-regex 'langchain-aws==(.*)' python3Packages.langchain-aws 102 nix-update --commit --version-regex 'langchain-azure-dynamic-sessions==(.*)' python3Packages.langchain-azure-dynamic-sessions 103 nix-update --commit --version-regex 'langchain-chroma==(.*)' python3Packages.langchain-chroma 104 nix-update --commit --version-regex 'langchain-huggingface==(.*)' python3Packages.langchain-huggingface 105 nix-update --commit --version-regex 'langchain-mongodb==(.*)' python3Packages.langchain-mongodb 106 nix-update --commit --version-regex 'langchain-openai==(.*)' python3Packages.langchain-openai 107 ''; 108 }; 109 110 disabledTests = 111 [ 112 # flaky, sometimes fail to strip uuid from AIMessageChunk before comparing to test value 113 "test_map_stream" 114 # Compares with machine-specific timings 115 "test_rate_limit" 116 # flaky: assert (1726352133.7419367 - 1726352132.2697523) < 1 117 "test_benchmark_model" 118 119 # TypeError: exceptions must be derived from Warning, not <class 'NoneType'> 120 "test_chat_prompt_template_variable_names" 121 "test_create_model_v2" 122 123 # Comparison with magic strings 124 "test_prompt_with_chat_model" 125 "test_prompt_with_chat_model_async" 126 "test_prompt_with_llm" 127 "test_prompt_with_llm_parser" 128 "test_prompt_with_llm_and_async_lambda" 129 "test_prompt_with_chat_model_and_parser" 130 "test_combining_sequences" 131 ] 132 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 133 # Langchain-core the following tests due to the test comparing execution time with magic values. 134 "test_queue_for_streaming_via_sync_call" 135 "test_same_event_loop" 136 # Comparisons with magic numbers 137 "test_rate_limit_ainvoke" 138 "test_rate_limit_astream" 139 ]; 140 141 meta = { 142 description = "Building applications with LLMs through composability"; 143 homepage = "https://github.com/langchain-ai/langchain/tree/master/libs/core"; 144 changelog = "https://github.com/langchain-ai/langchain/releases/tag/v${version}"; 145 license = lib.licenses.mit; 146 maintainers = with lib.maintainers; [ 147 natsukium 148 sarahec 149 ]; 150 }; 151}