Files
nixpkgs/pkgs/development/python-modules/langchain-core/default.nix
T

116 lines
2.7 KiB
Nix

{
lib,
stdenv,
buildPythonPackage,
fetchFromGitHub,
freezegun,
grandalf,
httpx,
jsonpatch,
langsmith,
numpy,
packaging,
poetry-core,
pydantic,
pytest-asyncio,
pytest-mock,
pytest-xdist,
pytestCheckHook,
pythonOlder,
pyyaml,
syrupy,
tenacity,
writeScript,
}:
buildPythonPackage rec {
pname = "langchain-core";
version = "0.2.37";
pyproject = true;
disabled = pythonOlder "3.8";
src = fetchFromGitHub {
owner = "langchain-ai";
repo = "langchain";
rev = "refs/tags/langchain-core==${version}";
hash = "sha256-An2ApN0pgCrQjqu9XPFfPyPvWx0+6JnUkGPrcD0/3kg=";
};
sourceRoot = "${src.name}/libs/core";
build-system = [ poetry-core ];
dependencies = [
jsonpatch
langsmith
packaging
pyyaml
tenacity
];
optional-dependencies = {
pydantic = [ pydantic ];
};
pythonImportsCheck = [ "langchain_core" ];
nativeCheckInputs = [
freezegun
grandalf
httpx
numpy
pytest-asyncio
pytest-mock
pytest-xdist
pytestCheckHook
syrupy
];
pytestFlagsArray = [ "tests/unit_tests" ];
# don't add langchain-standard-tests to nativeCheckInputs
# to avoid circular import
preCheck = ''
export PYTHONPATH=${src}/libs/standard-tests:$PYTHONPATH
'';
passthru = {
updateScript = writeScript "update.sh" ''
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p nix-update
set -u -o pipefail +e
nix-update --commit --version-regex 'langchain-core==(.*)' python3Packages.langchain-core
nix-update --commit --version-regex 'langchain-text-splitters==(.*)' python3Packages.langchain-text-splitters
nix-update --commit --version-regex 'langchain==(.*)' python3Packages.langchain
nix-update --commit --version-regex 'langchain-community==(.*)' python3Packages.langchain-community
'';
};
disabledTests =
[
# flaky, sometimes fail to strip uuid from AIMessageChunk before comparing to test value
"test_map_stream"
# Compares with machine-specific timings
"test_rate_limit_invoke"
"test_rate_limit_stream"
]
++ lib.optionals stdenv.isDarwin [
# Langchain-core the following tests due to the test comparing execution time with magic values.
"test_queue_for_streaming_via_sync_call"
"test_same_event_loop"
# Comparisons with magic numbers
"test_rate_limit_ainvoke"
"test_rate_limit_astream"
];
meta = {
description = "Building applications with LLMs through composability";
homepage = "https://github.com/langchain-ai/langchain/tree/master/libs/core";
changelog = "https://github.com/langchain-ai/langchain/releases/tag/v${version}";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ natsukium ];
};
}