1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 nix-update-script,
6
7 # build-system
8 pdm-backend,
9
10 # dependencies
11 aiohttp,
12 langchain-core,
13 langchain-openai,
14 requests,
15
16 # tests
17 langchain-tests,
18 pytest-asyncio,
19 pytest-mock,
20 pytestCheckHook,
21}:
22
23buildPythonPackage rec {
24 pname = "langchain-xai";
25 version = "0.2.3";
26 pyproject = true;
27
28 src = fetchFromGitHub {
29 owner = "langchain-ai";
30 repo = "langchain";
31 tag = "langchain-xai==${version}";
32 hash = "sha256-9pSwEHqh+WkHsjn7JNsyEy+U67ekTqAdHMAvAFanR8w=";
33 };
34
35 sourceRoot = "${src.name}/libs/partners/xai";
36
37 build-system = [ pdm-backend ];
38
39 dependencies = [
40 aiohttp
41 langchain-core
42 langchain-openai
43 requests
44 ];
45
46 pythonRelaxDeps = [
47 # Each component release requests the exact latest core.
48 # That prevents us from updating individual components.
49 "langchain-core"
50 ];
51
52 nativeCheckInputs = [
53 langchain-tests
54 pytest-asyncio
55 pytest-mock
56 pytestCheckHook
57 ];
58
59 pytestFlagsArray = [ "tests/unit_tests" ];
60
61 pythonImportsCheck = [ "langchain_xai" ];
62
63 passthru.updateScript = nix-update-script {
64 extraArgs = [
65 "--version-regex"
66 "langchain-xai==([0-9.]+)"
67 ];
68 };
69
70 meta = {
71 changelog = "https://github.com/langchain-ai/langchain-xai/releases/tag/langchain-xai==${version}";
72 description = "Build LangChain applications with X AI";
73 homepage = "https://github.com/langchain-ai/langchain/tree/master/libs/partners/xai";
74 license = lib.licenses.mit;
75 maintainers = [
76 lib.maintainers.sarahec
77 ];
78 };
79}