summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/graphrag/default.nix
blob: b6cfe85c613cdbf1fd63d9af086ce57ec3ae0a07 (plain)
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
{
  lib,
  stdenv,
  buildPythonPackage,
  fetchFromGitHub,

  # build-system
  setuptools,

  # dependencies
  aiofiles,
  azure-cosmos,
  azure-identity,
  azure-search-documents,
  azure-storage-blob,
  devtools,
  environs,
  fnllm,
  future,
  graspologic,
  json-repair,
  lancedb,
  litellm,
  networkx,
  nltk,
  numpy,
  openai,
  pandas,
  pyarrow,
  pydantic,
  python-dotenv,
  pyyaml,
  spacy,
  textblob,
  tiktoken,
  tqdm,
  typer,
  typing-extensions,
  umap-learn,

  # tests
  nbformat,
  pytest-asyncio,
  pytestCheckHook,
}:

buildPythonPackage rec {
  pname = "graphrag";
  version = "2.7.0";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "microsoft";
    repo = "graphrag";
    tag = "v${version}";
    hash = "sha256-F0MiC+14KOjCVwlcZpNo15SqDOfSYsVwH8qNQTHBKPQ=";
  };

  build-system = [
    setuptools
  ];

  pythonRelaxDeps = true;

  dependencies = [
    aiofiles
    azure-cosmos
    azure-identity
    azure-search-documents
    azure-storage-blob
    devtools
    environs
    fnllm
    future
    graspologic
    json-repair
    lancedb
    litellm
    networkx
    nltk
    numpy
    openai
    pandas
    pyarrow
    pydantic
    python-dotenv
    pyyaml
    spacy
    textblob
    tiktoken
    tqdm
    typer
    typing-extensions
    umap-learn
  ]
  ++ fnllm.optional-dependencies.azure
  ++ fnllm.optional-dependencies.openai;

  env.NUMBA_CACHE_DIR = "$TMPDIR";

  pythonImportsCheck = [ "graphrag" ];

  nativeCheckInputs = [
    nbformat
    pytest-asyncio
    pytestCheckHook
  ];

  enabledTestPaths = [ "tests/unit" ];

  disabledTestPaths = lib.optionals stdenv.hostPlatform.isDarwin [
    # Flaky
    "tests/unit/litellm_services/test_rate_limiter.py"
  ];

  disabledTests = [
    # touch the network
    "test_basic_functionality"
    "test_child"
    "test_dotprefix"
    "test_find"
    "test_load_strategy_sentence"
    "test_mixed_whitespace_handling"
    "test_multiple_documents"
    "test_run_extract_entities_multiple_documents"
    "test_run_extract_entities_single_document"
    "test_sort_context"
    "test_sort_context_max_tokens"
  ];

  meta = {
    description = "Modular graph-based Retrieval-Augmented Generation (RAG) system";
    homepage = "https://github.com/microsoft/graphrag";
    changelog = "https://github.com/microsoft/graphrag/blob/${src.tag}/CHANGELOG.md";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ natsukium ];
  };
}