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.nix56
1 files changed, 44 insertions, 12 deletions
diff --git a/pkgs/development/python-modules/langchain-core/default.nix b/pkgs/development/python-modules/langchain-core/default.nix
index 3c0b421564492..cf919d3404da4 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.1";
   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-D0y6kW5bWcCKW2TwVPlZcAUxqADgsOm9fWySAjHYYIg=";
   };
 
+  sourceRoot = "${src.name}/libs/core";
+
   pythonRelaxDeps = [
     "langsmith"
     "packaging"
@@ -38,24 +48,46 @@ 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" ];
+
+  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; {
     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 = licenses.mit;
     maintainers = with maintainers; [ natsukium ];
   };