diff --git a/pkgs/development/python-modules/langchain-aws/default.nix b/pkgs/development/python-modules/langchain-aws/default.nix new file mode 100644 index 000000000000..29f0c2d5d644 --- /dev/null +++ b/pkgs/development/python-modules/langchain-aws/default.nix @@ -0,0 +1,63 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + boto3, + langchain-core, + numpy, + poetry-core, + pytestCheckHook, + pytest-asyncio, + nix-update-script, +}: + +buildPythonPackage rec { + pname = "langchain-aws"; + version = "0.1.16"; + pyproject = true; + + src = fetchFromGitHub { + owner = "langchain-ai"; + repo = "langchain-aws"; + rev = "refs/tags/v${version}"; + hash = "sha256-WICv4tD9abTLO6mp/gZ4dgYVWmLMdUHgkwpZPd+u+Ek="; + }; + + postPatch = '' + substituteInPlace pyproject.toml \ + --replace-fail "--snapshot-warn-unused" "" \ + --replace-fail "--cov=langchain_aws" "" + + ln -s ${langchain-core.src}/libs/standard-tests/langchain_standard_tests ./langchain_standard_tests + ''; + + sourceRoot = "${src.name}/libs/aws"; + + build-system = [ poetry-core ]; + + dependencies = [ + boto3 + langchain-core + numpy + ]; + + nativeCheckInputs = [ + pytest-asyncio + pytestCheckHook + ]; + + pytestFlagsArray = [ "tests/unit_tests" ]; + + pythonImportsCheck = [ "langchain_aws" ]; + + meta = { + changelog = "https://github.com/langchain-ai/langchain-aws/releases/tag/v${version}"; + description = "Build LangChain application on AWS"; + homepage = "https://github.com/langchain-ai/langchain-aws/"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ + drupol + natsukium + ]; + }; +} diff --git a/pkgs/development/python-modules/langchain-community/default.nix b/pkgs/development/python-modules/langchain-community/default.nix index 78150a083a16..9bb38f66f7b4 100644 --- a/pkgs/development/python-modules/langchain-community/default.nix +++ b/pkgs/development/python-modules/langchain-community/default.nix @@ -29,7 +29,7 @@ buildPythonPackage rec { pname = "langchain-community"; - version = "0.2.7"; + version = "0.2.12"; pyproject = true; disabled = pythonOlder "3.8"; @@ -38,7 +38,7 @@ buildPythonPackage rec { owner = "langchain-ai"; repo = "langchain"; rev = "refs/tags/langchain-community==${version}"; - hash = "sha256-r0YSJkYPcwjHyw1xST5Zrgg9USjN9GOsvhV97imSFCQ="; + hash = "sha256-HsKWGiWA6uKmRQOMw3efXkjwbBuvDHhf5waNvnvBdG4="; }; sourceRoot = "${src.name}/libs/community"; @@ -58,7 +58,6 @@ buildPythonPackage rec { langchain-core langchain langsmith - numpy pyyaml requests sqlalchemy @@ -67,6 +66,7 @@ buildPythonPackage rec { optional-dependencies = { cli = [ typer ]; + numpy = [ numpy ]; }; pythonImportsCheck = [ "langchain_community" ]; diff --git a/pkgs/development/python-modules/langchain-core/default.nix b/pkgs/development/python-modules/langchain-core/default.nix index 8e32b2f3f6d7..737fbb47d4b5 100644 --- a/pkgs/development/python-modules/langchain-core/default.nix +++ b/pkgs/development/python-modules/langchain-core/default.nix @@ -25,7 +25,7 @@ buildPythonPackage rec { pname = "langchain-core"; - version = "0.2.21"; + version = "0.2.33"; pyproject = true; disabled = pythonOlder "3.8"; @@ -34,7 +34,7 @@ buildPythonPackage rec { owner = "langchain-ai"; repo = "langchain"; rev = "refs/tags/langchain-core==${version}"; - hash = "sha256-8qEN03iimGLnhg6TdpPal+MXBZJ/QHJKwjxRF96abBw="; + hash = "sha256-vM3FY9E8PeC8LHP4QCTM1ggFynI+PscF7pv7CMaSZlU="; }; sourceRoot = "${src.name}/libs/core"; @@ -52,11 +52,14 @@ buildPythonPackage rec { jsonpatch langsmith packaging - pydantic pyyaml tenacity ]; + optional-dependencies = { + pydantic = [ pydantic ]; + }; + pythonImportsCheck = [ "langchain_core" ]; nativeCheckInputs = [ @@ -86,15 +89,22 @@ buildPythonPackage rec { ''; }; - disabledTests = [ - # flaky, sometimes fail to strip uuid from AIMessageChunk before comparing to test value - "test_map_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" - ]; + 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"; diff --git a/pkgs/development/python-modules/langchain-mongodb/default.nix b/pkgs/development/python-modules/langchain-mongodb/default.nix index 360fa099f937..9edd6e571784 100644 --- a/pkgs/development/python-modules/langchain-mongodb/default.nix +++ b/pkgs/development/python-modules/langchain-mongodb/default.nix @@ -22,7 +22,7 @@ buildPythonPackage rec { pname = "langchain-mongodb"; - version = "0.1.6"; + version = "0.1.8"; pyproject = true; disabled = pythonOlder "3.8"; @@ -31,7 +31,7 @@ buildPythonPackage rec { owner = "langchain-ai"; repo = "langchain"; rev = "refs/tags/langchain-mongodb==${version}"; - hash = "sha256-p/cdWFPc2Oi5aRmjj1oAixM6aDKw0TbyzMdP4h2acG4="; + hash = "sha256-fjSvn9O/CrKBexcwuILXFR7AGx/tZtGDWjA0L6XV4Hk="; }; sourceRoot = "${src.name}/libs/partners/mongodb"; diff --git a/pkgs/development/python-modules/langchain-openai/default.nix b/pkgs/development/python-modules/langchain-openai/default.nix index 58eecb2a9f2a..8f09f326ece8 100644 --- a/pkgs/development/python-modules/langchain-openai/default.nix +++ b/pkgs/development/python-modules/langchain-openai/default.nix @@ -23,7 +23,7 @@ buildPythonPackage rec { pname = "langchain-openai"; - version = "0.1.17"; + version = "0.1.22"; pyproject = true; disabled = pythonOlder "3.8"; @@ -32,7 +32,7 @@ buildPythonPackage rec { owner = "langchain-ai"; repo = "langchain"; rev = "refs/tags/langchain-openai==${version}"; - hash = "sha256-ELD1KXCVx3SmiJodagtOHgBGKdjRWiRVCCNYcL63eCY="; + hash = "sha256-5UAijSTfQ6nQxdZvKHl2o01wDW6+Jphf38V+dAs7Ffk="; }; sourceRoot = "${src.name}/libs/partners/openai"; @@ -48,7 +48,6 @@ buildPythonPackage rec { build-system = [ poetry-core ]; dependencies = [ - langchain langchain-core openai tiktoken diff --git a/pkgs/development/python-modules/langchain/default.nix b/pkgs/development/python-modules/langchain/default.nix index 8475a6bbbce5..249e1d74fdd7 100644 --- a/pkgs/development/python-modules/langchain/default.nix +++ b/pkgs/development/python-modules/langchain/default.nix @@ -31,7 +31,7 @@ buildPythonPackage rec { pname = "langchain"; - version = "0.2.9"; + version = "0.2.14"; pyproject = true; disabled = pythonOlder "3.8"; @@ -40,7 +40,7 @@ buildPythonPackage rec { owner = "langchain-ai"; repo = "langchain"; rev = "refs/tags/langchain==${version}"; - hash = "sha256-HSr1watEDC28SZTsJWbXGrZsQd0O/wgxmj7pTsxMBOA="; + hash = "sha256-dgXcZu7dtmwlXp8dzHSNfbBnK7RWvrSwqYELm1fczzc="; }; sourceRoot = "${src.name}/libs/langchain"; @@ -54,7 +54,6 @@ buildPythonPackage rec { langchain-core langchain-text-splitters langsmith - numpy pydantic pyyaml requests @@ -62,6 +61,10 @@ buildPythonPackage rec { tenacity ] ++ lib.optionals (pythonOlder "3.11") [ async-timeout ]; + optional-dependencies = { + numpy = [ numpy ]; + }; + nativeCheckInputs = [ freezegun lark diff --git a/pkgs/development/python-modules/langgraph-checkpoint-postgres/default.nix b/pkgs/development/python-modules/langgraph-checkpoint-postgres/default.nix new file mode 100644 index 000000000000..a3e9d63d6213 --- /dev/null +++ b/pkgs/development/python-modules/langgraph-checkpoint-postgres/default.nix @@ -0,0 +1,69 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + langgraph-checkpoint, + orjson, + psycopg, + langgraph-sdk, + poetry-core, + pythonOlder, + postgresql, + postgresqlTestHook, + pytestCheckHook, + pytest-asyncio, +}: + +buildPythonPackage rec { + pname = "langgraph-checkpoint-postgres"; + version = "1.0.3"; + pyproject = true; + + disabled = pythonOlder "3.10"; + + src = fetchFromGitHub { + owner = "langchain-ai"; + repo = "langgraph"; + rev = "refs/tags/checkpointpostgres==${version}"; + hash = "sha256-U7Bymo+Nj82kwjxN33W2MT10jv+lioZUxIKUt8Yxh/s="; + }; + + postgresqlTestSetupPost = '' + substituteInPlace tests/conftest.py \ + --replace-fail "DEFAULT_URI = \"postgres://postgres:postgres@localhost:5441/postgres?sslmode=disable\"" "DEFAULT_URI = \"postgres:///$PGDATABASE\"" + ''; + + sourceRoot = "${src.name}/libs/checkpoint-postgres"; + + build-system = [ poetry-core ]; + + dependencies = [ + langgraph-checkpoint + orjson + psycopg + ]; + + pythonImportsCheck = [ "langgraph.checkpoint.postgres" ]; + + nativeCheckInputs = [ + postgresql + postgresqlTestHook + pytest-asyncio + pytestCheckHook + ]; + + passthru = { + updateScript = langgraph-sdk.updateScript; + }; + + meta = { + description = "Library with a Postgres implementation of LangGraph checkpoint saver"; + homepage = "https://github.com/langchain-ai/langgraph/tree/main/libs/checkpoint-postgres"; + changelog = "https://github.com/langchain-ai/langgraph/releases/tag/checkpointpostgres==${version}"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ + drupol + sarahec + ]; + }; +} diff --git a/pkgs/development/python-modules/langgraph-checkpoint-sqlite/default.nix b/pkgs/development/python-modules/langgraph-checkpoint-sqlite/default.nix new file mode 100644 index 000000000000..323faf5ffb1b --- /dev/null +++ b/pkgs/development/python-modules/langgraph-checkpoint-sqlite/default.nix @@ -0,0 +1,58 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + langgraph-checkpoint, + aiosqlite, + pytest-asyncio, + pytestCheckHook, + langgraph-sdk, + poetry-core, + pythonOlder, +}: + +buildPythonPackage rec { + pname = "langgraph-checkpoint-sqlite"; + version = "1.0.0"; + pyproject = true; + + disabled = pythonOlder "3.9"; + + src = fetchFromGitHub { + owner = "langchain-ai"; + repo = "langgraph"; + rev = "refs/tags/checkpointsqlite==${version}"; + hash = "sha256-TUiZOf34jhs+nkeTsprtTdoVqDt7kZd8NxYLKX4l0kQ="; + }; + + sourceRoot = "${src.name}/libs/checkpoint-sqlite"; + + build-system = [ poetry-core ]; + + dependencies = [ + aiosqlite + langgraph-checkpoint + ]; + + pythonImportsCheck = [ "langgraph.checkpoint.sqlite" ]; + + nativeCheckInputs = [ + pytest-asyncio + pytestCheckHook + ]; + + passthru = { + updateScript = langgraph-sdk.updateScript; + }; + + meta = { + changelog = "https://github.com/langchain-ai/langgraph/releases/tag/checkpointsqlite==${version}"; + description = "Library with a SQLite implementation of LangGraph checkpoint saver"; + homepage = "https://github.com/langchain-ai/langgraph/tree/main/libs/checkpoint-sqlite"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ + drupol + sarahec + ]; + }; +} diff --git a/pkgs/development/python-modules/langgraph-checkpoint/default.nix b/pkgs/development/python-modules/langgraph-checkpoint/default.nix new file mode 100644 index 000000000000..77b3ba34826e --- /dev/null +++ b/pkgs/development/python-modules/langgraph-checkpoint/default.nix @@ -0,0 +1,51 @@ +{ + lib, + buildPythonPackage, + dataclasses-json, + fetchFromGitHub, + langchain-core, + poetry-core, + pytest-asyncio, + pytestCheckHook, + pythonOlder, +}: + +buildPythonPackage rec { + pname = "langgraph-checkpoint"; + version = "1.0.3"; + pyproject = true; + + disabled = pythonOlder "3.9"; + + src = fetchFromGitHub { + owner = "langchain-ai"; + repo = "langgraph"; + rev = "refs/tags/checkpoint==${version}"; + hash = "sha256-5JP9f2uHNo71btQ96sBPlS7JPqo35C3VEMeHN1cJSro="; + }; + + sourceRoot = "${src.name}/libs/checkpoint"; + + build-system = [ poetry-core ]; + + dependencies = [ langchain-core ]; + + pythonImportsCheck = [ "langgraph.checkpoint" ]; + + nativeCheckInputs = [ + dataclasses-json + pytest-asyncio + pytestCheckHook + ]; + + meta = { + changelog = "https://github.com/langchain-ai/langgraph/releases/tag/checkpoint==${version}"; + description = "Library with base interfaces for LangGraph checkpoint savers"; + homepage = "https://github.com/langchain-ai/langgraph/tree/main/libs/checkpoint"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ + drupol + sarahec + ]; + }; +} diff --git a/pkgs/development/python-modules/langgraph/default.nix b/pkgs/development/python-modules/langgraph/default.nix index 7a0c6756f419..712e90a602c1 100644 --- a/pkgs/development/python-modules/langgraph/default.nix +++ b/pkgs/development/python-modules/langgraph/default.nix @@ -8,36 +8,51 @@ httpx, langchain-core, langgraph-sdk, + langgraph-checkpoint, + langgraph-checkpoint-postgres, + langgraph-checkpoint-sqlite, + psycopg, langsmith, poetry-core, pydantic, pytest-asyncio, pytest-mock, + pytest-repeat, pytest-xdist, pytestCheckHook, pythonOlder, syrupy, + postgresql, + postgresqlTestHook, }: buildPythonPackage rec { pname = "langgraph"; - version = "0.1.9"; + version = "0.2.4"; pyproject = true; - disabled = pythonOlder "3.10"; + disabled = pythonOlder "3.9"; src = fetchFromGitHub { owner = "langchain-ai"; repo = "langgraph"; rev = "refs/tags/${version}"; - hash = "sha256-sBjSfKzcILkHgvo8g/NHC+/yUjQSyZB/8xaSCY3rPDs="; + hash = "sha256-jUBaWXrHCXAph8EGEJnH7lbKIyjQ8oPt4eDMyIkbURo="; }; + postgresqlTestSetupPost = '' + substituteInPlace tests/conftest.py \ + --replace-fail "DEFAULT_POSTGRES_URI = \"postgres://postgres:postgres@localhost:5442/\"" "DEFAULT_POSTGRES_URI = \"postgres:///$PGDATABASE\"" + ''; + sourceRoot = "${src.name}/libs/langgraph"; build-system = [ poetry-core ]; - dependencies = [ langchain-core ]; + dependencies = [ + langchain-core + langgraph-checkpoint + ]; pythonImportsCheck = [ "langgraph" ]; @@ -46,19 +61,36 @@ buildPythonPackage rec { dataclasses-json grandalf httpx + langgraph-checkpoint-postgres + langgraph-checkpoint-sqlite langsmith + psycopg pydantic pytest-asyncio pytest-mock + pytest-repeat pytest-xdist pytestCheckHook syrupy + postgresql + postgresqlTestHook ]; - pytestFlagsArray = [ "--snapshot-update" ]; - disabledTests = [ "test_doesnt_warn_valid_schema" # test is flaky due to pydantic error on the exception + # Disabling tests that requires to create new random databases + "test_cancel_graph_astream" + "test_cancel_graph_astream_events_v2" + "test_channel_values" + "test_fork_always_re_runs_nodes" + "test_interruption_without_state_updates" + "test_interruption_without_state_updates_async" + "test_invoke_two_processes_in_out_interrupt" + "test_nested_graph_interrupts" + "test_no_modifier_async" + "test_no_modifier" + "test_pending_writes_resume" + "test_remove_message_via_state_update" ]; passthru = { diff --git a/pkgs/development/python-modules/openai/default.nix b/pkgs/development/python-modules/openai/default.nix index 39344e65cd5d..c8dbfdf7816b 100644 --- a/pkgs/development/python-modules/openai/default.nix +++ b/pkgs/development/python-modules/openai/default.nix @@ -8,11 +8,13 @@ fetchFromGitHub, hatch-fancy-pypi-readme, hatchling, + jiter, httpx, numpy, pandas, pandas-stubs, pydantic, + inline-snapshot, pytest-asyncio, pytest-mock, pytestCheckHook, @@ -25,7 +27,7 @@ buildPythonPackage rec { pname = "openai"; - version = "1.39.0"; + version = "1.40.8"; pyproject = true; disabled = pythonOlder "3.7.1"; @@ -34,7 +36,7 @@ buildPythonPackage rec { owner = "openai"; repo = "openai-python"; rev = "refs/tags/v${version}"; - hash = "sha256-jOtJu5Luvwnel2GLBjZHDP3MuXTWXFZKYHQfdmyEyTs="; + hash = "sha256-T9TdZWPC8exIY7FoLQkz+QfzWFT5BxCBHxP9SXQeT0I="; }; build-system = [ @@ -43,6 +45,7 @@ buildPythonPackage rec { ]; dependencies = [ + jiter httpx pydantic typing-extensions @@ -63,6 +66,7 @@ buildPythonPackage rec { pythonImportsCheck = [ "openai" ]; nativeCheckInputs = [ + inline-snapshot pytestCheckHook pytest-asyncio pytest-mock diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 72faea20cfe6..ce3728ea525a 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -6752,6 +6752,8 @@ self: super: with self; { langchain = callPackage ../development/python-modules/langchain { }; + langchain-aws = callPackage ../development/python-modules/langchain-aws { }; + langchain-azure-dynamic-sessions = callPackage ../development/python-modules/langchain-azure-dynamic-sessions { }; langchain-chroma = callPackage ../development/python-modules/langchain-chroma { }; @@ -6776,6 +6778,12 @@ self: super: with self; { langgraph = callPackage ../development/python-modules/langgraph { }; + langgraph-checkpoint = callPackage ../development/python-modules/langgraph-checkpoint { }; + + langgraph-checkpoint-postgres = callPackage ../development/python-modules/langgraph-checkpoint-postgres { }; + + langgraph-checkpoint-sqlite = callPackage ../development/python-modules/langgraph-checkpoint-sqlite { }; + langgraph-cli = callPackage ../development/python-modules/langgraph-cli { }; langgraph-sdk = callPackage ../development/python-modules/langgraph-sdk { };