From 04683d1b477cb5edb0da18f1786cf5bef0ea85b6 Mon Sep 17 00:00:00 2001 From: Sarah Clark Date: Sat, 20 Jul 2024 10:55:01 -0700 Subject: [PATCH] init langgraph, langgraph-sdk, and langgraph-cli --- pkgs/by-name/la/langgraph-cli/package.nix | 3 + .../python-modules/langgraph-cli/default.nix | 68 +++++++++++++++++ .../python-modules/langgraph-sdk/default.nix | 58 ++++++++++++++ .../python-modules/langgraph/default.nix | 75 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 6 ++ 5 files changed, 210 insertions(+) create mode 100644 pkgs/by-name/la/langgraph-cli/package.nix create mode 100644 pkgs/development/python-modules/langgraph-cli/default.nix create mode 100644 pkgs/development/python-modules/langgraph-sdk/default.nix create mode 100644 pkgs/development/python-modules/langgraph/default.nix diff --git a/pkgs/by-name/la/langgraph-cli/package.nix b/pkgs/by-name/la/langgraph-cli/package.nix new file mode 100644 index 000000000000..c307b728b76d --- /dev/null +++ b/pkgs/by-name/la/langgraph-cli/package.nix @@ -0,0 +1,3 @@ +{ python3Packages }: + +python3Packages.toPythonApplication python3Packages.langgraph-cli diff --git a/pkgs/development/python-modules/langgraph-cli/default.nix b/pkgs/development/python-modules/langgraph-cli/default.nix new file mode 100644 index 000000000000..4d8dd5bccc29 --- /dev/null +++ b/pkgs/development/python-modules/langgraph-cli/default.nix @@ -0,0 +1,68 @@ +{ + lib, + buildPythonPackage, + click, + fetchFromGitHub, + nix-update-script, + poetry-core, + pytest-asyncio, + pytestCheckHook, + pythonOlder, +}: + +buildPythonPackage rec { + pname = "langgraph-cli"; + version = "0.1.49"; + pyproject = true; + + disabled = pythonOlder "3.10"; + + src = fetchFromGitHub { + owner = "langchain-ai"; + repo = "langgraph"; + rev = "refs/tags/cli==${version}"; + hash = "sha256-yphXboJA/TLGIPggb2Cvsxn1+WUSYMzC0wPHft3TGvo="; + }; + + sourceRoot = "${src.name}/libs/cli"; + + build-system = [ poetry-core ]; + + dependencies = [ click ]; + + nativeCheckInputs = [ + pytest-asyncio + pytestCheckHook + ]; + + pytestFlagsArray = [ "tests/unit_tests" ]; + + pythonImportsCheck = [ "langgraph_cli" ]; + + disabledTests = [ + # Flaky tests that generate a Docker configuration then compare to exact text + "test_config_to_docker_simple" + "test_config_to_docker_pipconfig" + "test_config_to_compose_env_vars" + "test_config_to_compose_env_file" + "test_config_to_compose_end_to_end" + "test_config_to_compose_simple_config" + "test_config_to_compose_watch" + ]; + + passthru.updateScript = nix-update-script { + extraArgs = [ + "--version-regex" + "cli==(.*)" + ]; + }; + + meta = { + description = "Official CLI for LangGraph API"; + homepage = "https://github.com/langchain-ai/langgraph/libs/cli"; + changelog = "https://github.com/langchain-ai/langgraph/releases/tag/${version}"; + mainProgram = "langgraph"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ sarahec ]; + }; +} diff --git a/pkgs/development/python-modules/langgraph-sdk/default.nix b/pkgs/development/python-modules/langgraph-sdk/default.nix new file mode 100644 index 000000000000..d002f958fb40 --- /dev/null +++ b/pkgs/development/python-modules/langgraph-sdk/default.nix @@ -0,0 +1,58 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + httpx, + httpx-sse, + orjson, + poetry-core, + pythonOlder, + writeScript, +}: + +buildPythonPackage rec { + pname = "langgraph-sdk"; + version = "0.1.26"; + pyproject = true; + + disabled = pythonOlder "3.9"; + + src = fetchFromGitHub { + owner = "langchain-ai"; + repo = "langgraph"; + rev = "refs/tags/sdk==${version}"; + hash = "sha256-o7JrB2WSWfPm927tDRMcjzx+6Io6Q+Yjp4XPVs2+F4o="; + }; + + sourceRoot = "${src.name}/libs/sdk-py"; + + build-system = [ poetry-core ]; + + dependencies = [ + httpx + httpx-sse + orjson + ]; + + pythonImportsCheck = [ "langgraph_sdk" ]; + + passthru = { + # python3Packages.langgraph-sdk depends on python3Packages.langgraph. langgraph-cli is independent of both. + updateScript = writeScript "update.sh" '' + #!/usr/bin/env nix-shell + #!nix-shell -i bash -p nix-update + + set -eu -o pipefail + nix-update --commit --version-regex '(.*)' python3Packages.langgraph + nix-update --commit --version-regex 'sdk==(.*)' python3Packages.langgraph-sdk + ''; + }; + + meta = { + description = "SDK for interacting with the LangGraph Cloud REST API"; + homepage = "https://github.com/langchain-ai/langgraphtree/main/libs/sdk-py"; + changelog = "https://github.com/langchain-ai/langgraph/releases/tag/sdk==${version}"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ sarahec ]; + }; +} diff --git a/pkgs/development/python-modules/langgraph/default.nix b/pkgs/development/python-modules/langgraph/default.nix new file mode 100644 index 000000000000..7a0c6756f419 --- /dev/null +++ b/pkgs/development/python-modules/langgraph/default.nix @@ -0,0 +1,75 @@ +{ + lib, + buildPythonPackage, + aiosqlite, + dataclasses-json, + fetchFromGitHub, + grandalf, + httpx, + langchain-core, + langgraph-sdk, + langsmith, + poetry-core, + pydantic, + pytest-asyncio, + pytest-mock, + pytest-xdist, + pytestCheckHook, + pythonOlder, + syrupy, +}: + +buildPythonPackage rec { + pname = "langgraph"; + version = "0.1.9"; + pyproject = true; + + disabled = pythonOlder "3.10"; + + src = fetchFromGitHub { + owner = "langchain-ai"; + repo = "langgraph"; + rev = "refs/tags/${version}"; + hash = "sha256-sBjSfKzcILkHgvo8g/NHC+/yUjQSyZB/8xaSCY3rPDs="; + }; + + sourceRoot = "${src.name}/libs/langgraph"; + + build-system = [ poetry-core ]; + + dependencies = [ langchain-core ]; + + pythonImportsCheck = [ "langgraph" ]; + + nativeCheckInputs = [ + aiosqlite + dataclasses-json + grandalf + httpx + langsmith + pydantic + pytest-asyncio + pytest-mock + pytest-xdist + pytestCheckHook + syrupy + ]; + + pytestFlagsArray = [ "--snapshot-update" ]; + + disabledTests = [ + "test_doesnt_warn_valid_schema" # test is flaky due to pydantic error on the exception + ]; + + passthru = { + updateScript = langgraph-sdk.updateScript; + }; + + meta = { + description = "Build resilient language agents as graphs"; + homepage = "https://github.com/langchain-ai/langgraph"; + changelog = "https://github.com/langchain-ai/langgraph/releases/tag/${version}"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ sarahec ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index b31e805460b6..4da91feabe3e 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -6660,6 +6660,12 @@ self: super: with self; { langfuse = callPackage ../development/python-modules/langfuse { }; + langgraph = callPackage ../development/python-modules/langgraph { }; + + langgraph-cli = callPackage ../development/python-modules/langgraph-cli { }; + + langgraph-sdk = callPackage ../development/python-modules/langgraph-sdk { }; + langid = callPackage ../development/python-modules/langid { }; langsmith = callPackage ../development/python-modules/langsmith { };