1{
2 lib,
3 aiohttp,
4 async-timeout,
5 bash,
6 buildPythonPackage,
7 fetchFromGitHub,
8 freezegun,
9 langchain-core,
10 langchain-text-splitters,
11 langsmith,
12 lark,
13 numpy,
14 pandas,
15 poetry-core,
16 pydantic,
17 pytest-asyncio,
18 pytest-mock,
19 pytest-socket,
20 pytestCheckHook,
21 pythonOlder,
22 pyyaml,
23 requests-mock,
24 requests,
25 responses,
26 sqlalchemy,
27 syrupy,
28 tenacity,
29 toml,
30}:
31
32buildPythonPackage rec {
33 pname = "langchain";
34 version = "0.2.9";
35 pyproject = true;
36
37 disabled = pythonOlder "3.8";
38
39 src = fetchFromGitHub {
40 owner = "langchain-ai";
41 repo = "langchain";
42 rev = "refs/tags/langchain==${version}";
43 hash = "sha256-HSr1watEDC28SZTsJWbXGrZsQd0O/wgxmj7pTsxMBOA=";
44 };
45
46 sourceRoot = "${src.name}/libs/langchain";
47
48 build-system = [ poetry-core ];
49
50 buildInputs = [ bash ];
51
52 dependencies = [
53 aiohttp
54 langchain-core
55 langchain-text-splitters
56 langsmith
57 numpy
58 pydantic
59 pyyaml
60 requests
61 sqlalchemy
62 tenacity
63 ] ++ lib.optionals (pythonOlder "3.11") [ async-timeout ];
64
65 nativeCheckInputs = [
66 freezegun
67 lark
68 pandas
69 pytest-asyncio
70 pytest-mock
71 pytest-socket
72 pytestCheckHook
73 requests-mock
74 responses
75 syrupy
76 toml
77 ];
78
79 pytestFlagsArray = [
80 # integration_tests require network access, database access and require `OPENAI_API_KEY`, etc.
81 "tests/unit_tests"
82 "--only-core"
83 ];
84
85 disabledTests = [
86 # These tests have database access
87 "test_table_info"
88 "test_sql_database_run"
89 # These tests have network access
90 "test_socket_disabled"
91 "test_openai_agent_with_streaming"
92 "test_openai_agent_tools_agent"
93 # This test may require a specific version of langchain-community
94 "test_compatible_vectorstore_documentation"
95 # AssertionErrors
96 "test_callback_handlers"
97 "test_generic_fake_chat_model"
98 # Test is outdated
99 "test_serializable_mapping"
100 "test_person"
101 "test_aliases_hidden"
102 ];
103
104 pythonImportsCheck = [ "langchain" ];
105
106 passthru = {
107 updateScript = langchain-core.updateScript;
108 };
109
110 meta = {
111 description = "Building applications with LLMs through composability";
112 homepage = "https://github.com/langchain-ai/langchain";
113 changelog = "https://github.com/langchain-ai/langchain/releases/tag/v${version}";
114 license = lib.licenses.mit;
115 maintainers = with lib.maintainers; [ natsukium ];
116 mainProgram = "langchain-server";
117 };
118}