1{ lib
2, buildPythonPackage
3, fetchFromGitHub
4, pythonOlder
5, poetry-core
6, numpy
7, pyyaml
8, sqlalchemy
9, requests
10, async-timeout
11, aiohttp
12, numexpr
13, openapi-schema-pydantic
14, dataclasses-json
15, tqdm
16, tenacity
17, bash
18 # optional dependencies
19, anthropic
20, cohere
21, openai
22, nlpcloud
23, huggingface-hub
24, manifest-ml
25, torch
26, transformers
27, qdrant-client
28, sentence-transformers
29, azure-identity
30, azure-cosmos
31, azure-core
32, elasticsearch
33, opensearch-py
34, google-search-results
35, faiss
36, spacy
37, nltk
38, beautifulsoup4
39, tiktoken
40, jinja2
41, pinecone-client
42, weaviate-client
43, redis
44, google-api-python-client
45, pypdf
46, networkx
47, psycopg2
48, boto3
49, pyowm
50, pytesseract
51, html2text
52, atlassian-python-api
53, duckduckgo-search
54, lark
55, jq
56, steamship
57, pdfminer-six
58, lxml
59, chardet
60, requests-toolbelt
61, neo4j
62 # test dependencies
63, pytest-vcr
64, pytest-asyncio
65, pytest-mock
66, pytest-socket
67, pandas
68, toml
69, freezegun
70, responses
71, pexpect
72, pytestCheckHook
73}:
74
75buildPythonPackage rec {
76 pname = "langchain";
77 version = "0.0.188";
78 format = "pyproject";
79
80 disabled = pythonOlder "3.8";
81
82 src = fetchFromGitHub {
83 owner = "hwchase17";
84 repo = "langchain";
85 rev = "refs/tags/v${version}";
86 hash = "sha256-hf0pfWPXdutUKDzt56Uc0Q02TzScLAegQZ2gdR2IM/c=";
87 };
88
89 postPatch = ''
90 substituteInPlace langchain/utilities/bash.py \
91 --replace '"env", ["-i", "bash", ' '"${lib.getExe bash}", ['
92 substituteInPlace tests/unit_tests/test_bash.py \
93 --replace "/bin/sh" "${bash}/bin/sh"
94 '';
95
96 nativeBuildInputs = [
97 poetry-core
98 ];
99
100 buildInputs = [
101 bash
102 ];
103
104 propagatedBuildInputs = [
105 numpy
106 pyyaml
107 sqlalchemy
108 requests
109 aiohttp
110 numexpr
111 openapi-schema-pydantic
112 dataclasses-json
113 tqdm
114 tenacity
115 ] ++ lib.optionals (pythonOlder "3.11") [
116 async-timeout
117 ] ++ passthru.optional-dependencies.all;
118
119 passthru.optional-dependencies = {
120 llms = [
121 anthropic
122 cohere
123 openai
124 nlpcloud
125 huggingface-hub
126 manifest-ml
127 torch
128 transformers
129 ];
130 qdrant = [
131 qdrant-client
132 ];
133 openai = [
134 openai
135 ];
136 text_helpers = [
137 chardet
138 ];
139 cohere = [
140 cohere
141 ];
142 docarray = [
143 # docarray
144 ];
145 embeddings = [
146 sentence-transformers
147 ];
148 azure = [
149 azure-identity
150 azure-cosmos
151 openai
152 azure-core
153 ];
154 all = [
155 anthropic
156 cohere
157 openai
158 nlpcloud
159 huggingface-hub
160 # jina
161 manifest-ml
162 elasticsearch
163 opensearch-py
164 google-search-results
165 faiss
166 sentence-transformers
167 transformers
168 spacy
169 nltk
170 # wikipedia
171 beautifulsoup4
172 tiktoken
173 torch
174 jinja2
175 pinecone-client
176 # pinecone-text
177 weaviate-client
178 redis
179 google-api-python-client
180 # wolframalpha
181 qdrant-client
182 # tensorflow-text
183 pypdf
184 networkx
185 # nomic
186 # aleph-alpha-client
187 # deeplake
188 # pgvector
189 psycopg2
190 boto3
191 pyowm
192 pytesseract
193 html2text
194 atlassian-python-api
195 # gptcache
196 duckduckgo-search
197 # arxiv
198 azure-identity
199 # clickhouse-connect
200 azure-cosmos
201 # lancedb
202 # langkit
203 lark
204 pexpect
205 # pyvespa
206 # O365
207 jq
208 # docarray
209 steamship
210 pdfminer-six
211 lxml
212 requests-toolbelt
213 neo4j
214 # openlm
215 # azure-ai-formrecognizer
216 # azure-ai-vision
217 # azure-cognitiveservices-speech
218 ];
219 };
220
221 nativeCheckInputs = [
222 pytestCheckHook
223 pytest-vcr
224 pytest-mock
225 pytest-socket
226 pytest-asyncio
227 pandas
228 toml
229 freezegun
230 responses
231 ];
232
233 pytestFlagsArray = [
234 # integration_tests have many network, db access and require `OPENAI_API_KEY`, etc.
235 "tests/unit_tests"
236 ];
237
238 disabledTests = [
239 # these tests have db access
240 "test_table_info"
241 "test_sql_database_run"
242
243 # these tests have network access
244 "test_socket_disabled"
245 ];
246
247 meta = with lib; {
248 description = "Building applications with LLMs through composability";
249 homepage = "https://github.com/hwchase17/langchain";
250 changelog = "https://github.com/hwchase17/langchain/releases/tag/v${version}";
251 license = licenses.mit;
252 maintainers = with maintainers; [ natsukium ];
253 };
254}