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