summary refs log tree commit diff
path: root/pkgs/development/python-modules/langchain/default.nix
blob: 865ce51b07db04e38014815496fed8d32fe0be7d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
{ lib
, bash
, buildPythonPackage
, fetchFromGitHub
, pythonOlder
, pythonRelaxDepsHook
, poetry-core
, aiohttp
, async-timeout
, dataclasses-json
, langsmith
, numexpr
, numpy
, openapi-schema-pydantic
, pydantic
, pyyaml
, requests
, sqlalchemy
, tenacity
  # optional dependencies
, anthropic
, atlassian-python-api
, azure-core
, azure-cosmos
, azure-identity
, beautifulsoup4
, chardet
, clarifai
, cohere
, duckduckgo-search
, elasticsearch
, esprima
, faiss
, google-api-python-client
, google-auth
, google-search-results
, gptcache
, html2text
, huggingface-hub
, jinja2
, jq
, lark
, librosa
, lxml
, manifest-ml
, markdownify
, neo4j
, networkx
, nlpcloud
, nltk
, openai
, opensearch-py
, pdfminer-six
, pgvector
, pinecone-client
, psycopg2
, pyowm
, pypdf
, pytesseract
, python-arango
, qdrant-client
, rdflib
, redis
, requests-toolbelt
, sentence-transformers
, spacy
, steamship
, tiktoken
, torch
, transformers
, weaviate-client
, wikipedia
  # test dependencies
, freezegun
, pandas
, pexpect
, pytest-asyncio
, pytest-mock
, pytest-socket
, pytest-vcr
, pytestCheckHook
, responses
, syrupy
, toml
}:

buildPythonPackage rec {
  pname = "langchain";
  version = "0.0.285";
  format = "pyproject";

  disabled = pythonOlder "3.8";

  src = fetchFromGitHub {
    owner = "hwchase17";
    repo = "langchain";
    rev = "refs/tags/v${version}";
    hash = "sha256-3vOfwn8qvPd9dPRnsX14bVSLQQKHLPS5r15S8yAQFpw=";
  };

  sourceRoot = "${src.name}/libs/langchain";

  postPatch = ''
    substituteInPlace langchain/utilities/bash.py \
      --replace '"env", ["-i", "bash", ' '"${lib.getExe bash}", ['
    substituteInPlace tests/unit_tests/test_bash.py \
      --replace "/bin/sh" "${bash}/bin/sh"
  '';

  nativeBuildInputs = [
    poetry-core
    pythonRelaxDepsHook
  ];

  buildInputs = [
    bash
  ];

  propagatedBuildInputs = [
    pydantic
    sqlalchemy
    requests
    pyyaml
    numpy
    openapi-schema-pydantic
    dataclasses-json
    tenacity
    aiohttp
    numexpr
    langsmith
  ] ++ lib.optionals (pythonOlder "3.11") [
    async-timeout
  ];

  passthru.optional-dependencies = {
    llms = [
      anthropic
      clarifai
      cohere
      openai
      # openllm
      # openlm
      nlpcloud
      huggingface-hub
      manifest-ml
      torch
      transformers
      # xinference
    ];
    qdrant = [
      qdrant-client
    ];
    openai = [
      openai
      tiktoken
    ];
    text_helpers = [
      chardet
    ];
    clarifai = [
      clarifai
    ];
    cohere = [
      cohere
    ];
    docarray = [
      # docarray
    ];
    embeddings = [
      sentence-transformers
    ];
    javascript = [
      esprima
    ];
    azure = [
      azure-identity
      azure-cosmos
      openai
      azure-core
      # azure-ai-formrecognizer
      # azure-ai-vision
      # azure-cognitiveservices-speech
      # azure-search-documents
    ];
    all = [
      anthropic
      clarifai
      cohere
      openai
      nlpcloud
      huggingface-hub
      # jina
      manifest-ml
      elasticsearch
      opensearch-py
      google-search-results
      faiss
      sentence-transformers
      transformers
      spacy
      nltk
      wikipedia
      beautifulsoup4
      tiktoken
      torch
      jinja2
      pinecone-client
      # pinecone-text
      weaviate-client
      redis
      google-api-python-client
      google-auth
      # wolframalpha
      qdrant-client
      # tensorflow-text
      pypdf
      networkx
      # nomic
      # aleph-alpha-client
      # deeplake
      # libdeeplake
      pgvector
      psycopg2
      pyowm
      pytesseract
      html2text
      atlassian-python-api
      gptcache
      duckduckgo-search
      # arxiv
      azure-identity
      # clickhouse-connect
      azure-cosmos
      # lancedb
      # langkit
      lark
      pexpect
      # pyvespa
      # O365
      jq
      # docarray
      steamship
      pdfminer-six
      lxml
      requests-toolbelt
      neo4j
      # openlm
      # azure-ai-formrecognizer
      # azure-ai-vision
      # azure-cognitiveservices-speech
      # momento
      # singlestoredb
      # tigrisdb
      # nebula3-python
      # awadb
      # esprima
      # octoai-sdk
      rdflib
      # amadeus
      # xinference
      librosa
      python-arango
    ];
  };

  nativeCheckInputs = [
    freezegun
    markdownify
    pandas
    pytest-asyncio
    pytest-mock
    pytest-socket
    pytest-vcr
    pytestCheckHook
    responses
    syrupy
    toml
  ] ++ passthru.optional-dependencies.all;

  pytestFlagsArray = [
    # integration_tests have many network, db access and require `OPENAI_API_KEY`, etc.
    "tests/unit_tests"
  ];

  disabledTests = [
    # these tests have db access
    "test_table_info"
    "test_sql_database_run"

    # these tests have network access
    "test_socket_disabled"
  ];

  meta = with lib; {
    description = "Building applications with LLMs through composability";
    homepage = "https://github.com/hwchase17/langchain";
    changelog = "https://github.com/hwchase17/langchain/releases/tag/v${version}";
    license = licenses.mit;
    maintainers = with maintainers; [ natsukium ];
  };
}