cleanup no required install
Browse files- README.md +1 -1
- lightrag/api/requirements.txt +1 -1
- lightrag/kg/milvus_impl.py +5 -1
- lightrag/kg/networkx_impl.py +9 -19
- lightrag/kg/oracle_impl.py +4 -2
- requirements.txt +0 -6
README.md
CHANGED
@@ -247,7 +247,7 @@ rag = LightRAG(
|
|
247 |
|
248 |
* If you want to use Hugging Face models, you only need to set LightRAG as follows:
|
249 |
|
250 |
-
See lightrag_hf_demo.py
|
251 |
|
252 |
```python
|
253 |
from lightrag.llm import hf_model_complete, hf_embed
|
|
|
247 |
|
248 |
* If you want to use Hugging Face models, you only need to set LightRAG as follows:
|
249 |
|
250 |
+
See `lightrag_hf_demo.py`
|
251 |
|
252 |
```python
|
253 |
from lightrag.llm import hf_model_complete, hf_embed
|
lightrag/api/requirements.txt
CHANGED
@@ -1,9 +1,9 @@
|
|
|
|
1 |
ascii_colors
|
2 |
fastapi
|
3 |
numpy
|
4 |
pipmaster
|
5 |
python-dotenv
|
6 |
-
python-multipart
|
7 |
tenacity
|
8 |
tiktoken
|
9 |
uvicorn
|
|
|
1 |
+
aiofiles
|
2 |
ascii_colors
|
3 |
fastapi
|
4 |
numpy
|
5 |
pipmaster
|
6 |
python-dotenv
|
|
|
7 |
tenacity
|
8 |
tiktoken
|
9 |
uvicorn
|
lightrag/kg/milvus_impl.py
CHANGED
@@ -6,12 +6,16 @@ import numpy as np
|
|
6 |
from lightrag.utils import logger
|
7 |
from ..base import BaseVectorStorage
|
8 |
import pipmaster as pm
|
9 |
-
|
|
|
|
|
|
|
10 |
|
11 |
if not pm.is_installed("pymilvus"):
|
12 |
pm.install("pymilvus")
|
13 |
|
14 |
try:
|
|
|
15 |
from pymilvus import MilvusClient
|
16 |
except ImportError as e:
|
17 |
raise ImportError(
|
|
|
6 |
from lightrag.utils import logger
|
7 |
from ..base import BaseVectorStorage
|
8 |
import pipmaster as pm
|
9 |
+
|
10 |
+
|
11 |
+
if not pm.is_installed("configparser"):
|
12 |
+
pm.install("configparser")
|
13 |
|
14 |
if not pm.is_installed("pymilvus"):
|
15 |
pm.install("pymilvus")
|
16 |
|
17 |
try:
|
18 |
+
import configparser
|
19 |
from pymilvus import MilvusClient
|
20 |
except ImportError as e:
|
21 |
raise ImportError(
|
lightrag/kg/networkx_impl.py
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
-
import html
|
2 |
import os
|
3 |
from dataclasses import dataclass
|
4 |
-
from typing import Any,
|
5 |
|
6 |
import numpy as np
|
7 |
|
@@ -14,8 +13,16 @@ from lightrag.utils import (
|
|
14 |
from lightrag.base import (
|
15 |
BaseGraphStorage,
|
16 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
try:
|
|
|
19 |
import networkx as nx
|
20 |
except ImportError as e:
|
21 |
raise ImportError(
|
@@ -39,21 +46,6 @@ class NetworkXStorage(BaseGraphStorage):
|
|
39 |
)
|
40 |
nx.write_graphml(graph, file_name)
|
41 |
|
42 |
-
@staticmethod
|
43 |
-
def stable_largest_connected_component(graph: nx.Graph) -> nx.Graph:
|
44 |
-
"""Refer to https://github.com/microsoft/graphrag/index/graph/utils/stable_lcc.py
|
45 |
-
Return the largest connected component of the graph, with nodes and edges sorted in a stable way.
|
46 |
-
"""
|
47 |
-
from graspologic.utils import largest_connected_component
|
48 |
-
|
49 |
-
graph = graph.copy()
|
50 |
-
graph = cast(nx.Graph, largest_connected_component(graph))
|
51 |
-
node_mapping = {
|
52 |
-
node: html.unescape(node.upper().strip()) for node in graph.nodes()
|
53 |
-
} # type: ignore
|
54 |
-
graph = nx.relabel_nodes(graph, node_mapping)
|
55 |
-
return NetworkXStorage._stabilize_graph(graph)
|
56 |
-
|
57 |
@staticmethod
|
58 |
def _stabilize_graph(graph: nx.Graph) -> nx.Graph:
|
59 |
"""Refer to https://github.com/microsoft/graphrag/index/graph/utils/stable_lcc.py
|
@@ -153,8 +145,6 @@ class NetworkXStorage(BaseGraphStorage):
|
|
153 |
|
154 |
# @TODO: NOT USED
|
155 |
async def _node2vec_embed(self):
|
156 |
-
from graspologic import embed
|
157 |
-
|
158 |
embeddings, nodes = embed.node2vec_embed(
|
159 |
self._graph,
|
160 |
**self.global_config["node2vec_params"],
|
|
|
|
|
1 |
import os
|
2 |
from dataclasses import dataclass
|
3 |
+
from typing import Any, final
|
4 |
|
5 |
import numpy as np
|
6 |
|
|
|
13 |
from lightrag.base import (
|
14 |
BaseGraphStorage,
|
15 |
)
|
16 |
+
import pipmaster as pm
|
17 |
+
|
18 |
+
if not pm.is_installed("graspologic"):
|
19 |
+
pm.install("graspologic")
|
20 |
+
|
21 |
+
if not pm.is_installed("networkx"):
|
22 |
+
pm.install("networkx")
|
23 |
|
24 |
try:
|
25 |
+
from graspologic import embed
|
26 |
import networkx as nx
|
27 |
except ImportError as e:
|
28 |
raise ImportError(
|
|
|
46 |
)
|
47 |
nx.write_graphml(graph, file_name)
|
48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
@staticmethod
|
50 |
def _stabilize_graph(graph: nx.Graph) -> nx.Graph:
|
51 |
"""Refer to https://github.com/microsoft/graphrag/index/graph/utils/stable_lcc.py
|
|
|
145 |
|
146 |
# @TODO: NOT USED
|
147 |
async def _node2vec_embed(self):
|
|
|
|
|
148 |
embeddings, nodes = embed.node2vec_embed(
|
149 |
self._graph,
|
150 |
**self.global_config["node2vec_params"],
|
lightrag/kg/oracle_impl.py
CHANGED
@@ -20,10 +20,14 @@ from ..utils import logger
|
|
20 |
|
21 |
import pipmaster as pm
|
22 |
|
|
|
|
|
|
|
23 |
if not pm.is_installed("oracledb"):
|
24 |
pm.install("oracledb")
|
25 |
|
26 |
try:
|
|
|
27 |
import oracledb
|
28 |
|
29 |
except ImportError as e:
|
@@ -452,8 +456,6 @@ class OracleGraphStorage(BaseGraphStorage):
|
|
452 |
|
453 |
async def _node2vec_embed(self):
|
454 |
"""ไธบ่็น็ๆๅ้"""
|
455 |
-
from graspologic import embed
|
456 |
-
|
457 |
embeddings, nodes = embed.node2vec_embed(
|
458 |
self._graph,
|
459 |
**self.config["node2vec_params"],
|
|
|
20 |
|
21 |
import pipmaster as pm
|
22 |
|
23 |
+
if not pm.is_installed("graspologic"):
|
24 |
+
pm.install("graspologic")
|
25 |
+
|
26 |
if not pm.is_installed("oracledb"):
|
27 |
pm.install("oracledb")
|
28 |
|
29 |
try:
|
30 |
+
from graspologic import embed
|
31 |
import oracledb
|
32 |
|
33 |
except ImportError as e:
|
|
|
456 |
|
457 |
async def _node2vec_embed(self):
|
458 |
"""ไธบ่็น็ๆๅ้"""
|
|
|
|
|
459 |
embeddings, nodes = embed.node2vec_embed(
|
460 |
self._graph,
|
461 |
**self.config["node2vec_params"],
|
requirements.txt
CHANGED
@@ -1,12 +1,6 @@
|
|
1 |
-
accelerate
|
2 |
-
aiofiles
|
3 |
aiohttp
|
4 |
configparser
|
5 |
|
6 |
-
# File manipulation libraries
|
7 |
-
docling
|
8 |
-
graspologic
|
9 |
-
|
10 |
# database packages
|
11 |
networkx
|
12 |
|
|
|
|
|
|
|
1 |
aiohttp
|
2 |
configparser
|
3 |
|
|
|
|
|
|
|
|
|
4 |
# database packages
|
5 |
networkx
|
6 |
|