about summary refs log tree commit diff
path: root/pkgs/development/python-modules/langchain-core/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/python-modules/langchain-core/default.nix')
-rw-r--r--pkgs/development/python-modules/langchain-core/default.nix69
1 files changed, 54 insertions, 15 deletions
diff --git a/pkgs/development/python-modules/langchain-core/default.nix b/pkgs/development/python-modules/langchain-core/default.nix
index 3c0b421564492..c8566dd441f39 100644
--- a/pkgs/development/python-modules/langchain-core/default.nix
+++ b/pkgs/development/python-modules/langchain-core/default.nix
@@ -1,33 +1,43 @@
 {
   lib,
-  anyio,
   buildPythonPackage,
-  fetchPypi,
+  fetchFromGitHub,
+  freezegun,
+  grandalf,
   jsonpatch,
   langsmith,
+  numpy,
   packaging,
   poetry-core,
   pydantic,
+  pytest-asyncio,
+  pytest-mock,
+  pytest-xdist,
+  pytestCheckHook,
   pythonOlder,
   pythonRelaxDepsHook,
   pyyaml,
-  requests,
+  syrupy,
   tenacity,
+  writeScript,
 }:
 
 buildPythonPackage rec {
   pname = "langchain-core";
-  version = "0.1.48";
+  version = "0.2.5";
   pyproject = true;
 
   disabled = pythonOlder "3.8";
 
-  src = fetchPypi {
-    pname = "langchain_core";
-    inherit version;
-    hash = "sha256-8KmwqPIvIZ72/YTisdkqgBToRRTAobVTNw/UApaBPBY=";
+  src = fetchFromGitHub {
+    owner = "langchain-ai";
+    repo = "langchain";
+    rev = "langchain-core==${version}";
+    hash = "sha256-EBs6BHxBPBR1TfSyesM2gJJtxgClM6lLXko1qisrz7A=";
   };
 
+  sourceRoot = "${src.name}/libs/core";
+
   pythonRelaxDeps = [
     "langsmith"
     "packaging"
@@ -38,25 +48,54 @@ buildPythonPackage rec {
   nativeBuildInputs = [ pythonRelaxDepsHook ];
 
   dependencies = [
-    anyio
     jsonpatch
     langsmith
     packaging
     pydantic
     pyyaml
-    requests
     tenacity
   ];
 
   pythonImportsCheck = [ "langchain_core" ];
 
-  # PyPI source does not have tests
-  doCheck = false;
+  nativeCheckInputs = [
+    freezegun
+    grandalf
+    numpy
+    pytest-asyncio
+    pytest-mock
+    pytest-xdist
+    pytestCheckHook
+    syrupy
+  ];
+
+  pytestFlagsArray = [ "tests/unit_tests" ];
+
+  disabledTests = [
+    # Fail for an unclear reason with:
+    # AssertionError: assert '6a92363c-4ac...-d344769ab6ac' == '09af124a-2ed...-671c64c72b70'
+    "test_config_traceable_handoff"
+    "test_config_traceable_async_handoff"
+  ];
+
+  passthru = {
+    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 '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
+    '';
+  };
 
-  meta = with lib; {
+  meta = {
     description = "Building applications with LLMs through composability";
     homepage = "https://github.com/langchain-ai/langchain/tree/master/libs/core";
-    license = licenses.mit;
-    maintainers = with maintainers; [ natsukium ];
+    changelog = "https://github.com/langchain-ai/langchain/releases/tag/v${version}";
+    license = lib.licenses.mit;
+    maintainers = with lib.maintainers; [ natsukium ];
   };
 }