1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5
6 # build-system
7 pdm-backend,
8
9 # dependencies
10 huggingface-hub,
11 langchain-core,
12 sentence-transformers,
13 tokenizers,
14 transformers,
15
16 # tests
17 freezegun,
18 httpx,
19 lark,
20 pandas,
21 pytest-asyncio,
22 pytest-mock,
23 pytest-socket,
24 pytestCheckHook,
25 requests-mock,
26 responses,
27 syrupy,
28 toml,
29
30 # passthru
31 gitUpdater,
32}:
33
34buildPythonPackage rec {
35 pname = "langchain-huggingface";
36 version = "0.3.0";
37 pyproject = true;
38
39 src = fetchFromGitHub {
40 owner = "langchain-ai";
41 repo = "langchain";
42 tag = "langchain-huggingface==${version}";
43 hash = "sha256-+7fxCw4YYyfXwXw30lf1Xb01aj01C6X0B5yUrNPQzNY=";
44 };
45
46 sourceRoot = "${src.name}/libs/partners/huggingface";
47
48 build-system = [ pdm-backend ];
49
50 pythonRelaxDeps = [
51 # Each component release requests the exact latest core.
52 # That prevents us from updating individual components.
53 "langchain-core"
54 ];
55
56 dependencies = [
57 huggingface-hub
58 langchain-core
59 sentence-transformers
60 tokenizers
61 transformers
62 ];
63
64 nativeCheckInputs = [
65 freezegun
66 httpx
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 enabledTestPaths = [ "tests/unit_tests" ];
80
81 pythonImportsCheck = [ "langchain_huggingface" ];
82
83 passthru.updateScript = gitUpdater {
84 rev-prefix = "langchain-huggingface==";
85 };
86
87 meta = {
88 changelog = "https://github.com/langchain-ai/langchain/releases/tag/${src.tag}";
89 description = "Integration package connecting Huggingface related classes and LangChain";
90 homepage = "https://github.com/langchain-ai/langchain/tree/master/libs/partners/huggingface";
91 license = lib.licenses.mit;
92 maintainers = with lib.maintainers; [
93 natsukium
94 sarahec
95 ];
96 };
97}