cleanup no required install

This commit is contained in:
Yannick Stephan
2025-02-18 20:27:59 +01:00
parent ea41d08b9f
commit 011227e426
6 changed files with 20 additions and 30 deletions

View File

@@ -247,7 +247,7 @@ rag = LightRAG(
* If you want to use Hugging Face models, you only need to set LightRAG as follows:
See lightrag_hf_demo.py
See `lightrag_hf_demo.py`
```python
from lightrag.llm import hf_model_complete, hf_embed

View File

@@ -1,9 +1,9 @@
aiofiles
ascii_colors
fastapi
numpy
pipmaster
python-dotenv
python-multipart
tenacity
tiktoken
uvicorn

View File

@@ -6,12 +6,16 @@ import numpy as np
from lightrag.utils import logger
from ..base import BaseVectorStorage
import pipmaster as pm
import configparser
if not pm.is_installed("configparser"):
pm.install("configparser")
if not pm.is_installed("pymilvus"):
pm.install("pymilvus")
try:
import configparser
from pymilvus import MilvusClient
except ImportError as e:
raise ImportError(

View File

@@ -1,7 +1,6 @@
import html
import os
from dataclasses import dataclass
from typing import Any, cast, final
from typing import Any, final
import numpy as np
@@ -14,8 +13,16 @@ from lightrag.utils import (
from lightrag.base import (
BaseGraphStorage,
)
import pipmaster as pm
if not pm.is_installed("graspologic"):
pm.install("graspologic")
if not pm.is_installed("networkx"):
pm.install("networkx")
try:
from graspologic import embed
import networkx as nx
except ImportError as e:
raise ImportError(
@@ -39,21 +46,6 @@ class NetworkXStorage(BaseGraphStorage):
)
nx.write_graphml(graph, file_name)
@staticmethod
def stable_largest_connected_component(graph: nx.Graph) -> nx.Graph:
"""Refer to https://github.com/microsoft/graphrag/index/graph/utils/stable_lcc.py
Return the largest connected component of the graph, with nodes and edges sorted in a stable way.
"""
from graspologic.utils import largest_connected_component
graph = graph.copy()
graph = cast(nx.Graph, largest_connected_component(graph))
node_mapping = {
node: html.unescape(node.upper().strip()) for node in graph.nodes()
} # type: ignore
graph = nx.relabel_nodes(graph, node_mapping)
return NetworkXStorage._stabilize_graph(graph)
@staticmethod
def _stabilize_graph(graph: nx.Graph) -> nx.Graph:
"""Refer to https://github.com/microsoft/graphrag/index/graph/utils/stable_lcc.py
@@ -153,8 +145,6 @@ class NetworkXStorage(BaseGraphStorage):
# @TODO: NOT USED
async def _node2vec_embed(self):
from graspologic import embed
embeddings, nodes = embed.node2vec_embed(
self._graph,
**self.global_config["node2vec_params"],

View File

@@ -20,10 +20,14 @@ from ..utils import logger
import pipmaster as pm
if not pm.is_installed("graspologic"):
pm.install("graspologic")
if not pm.is_installed("oracledb"):
pm.install("oracledb")
try:
from graspologic import embed
import oracledb
except ImportError as e:
@@ -452,8 +456,6 @@ class OracleGraphStorage(BaseGraphStorage):
async def _node2vec_embed(self):
"""为节点生成向量"""
from graspologic import embed
embeddings, nodes = embed.node2vec_embed(
self._graph,
**self.config["node2vec_params"],

View File

@@ -1,12 +1,6 @@
accelerate
aiofiles
aiohttp
configparser
# File manipulation libraries
docling
graspologic
# database packages
networkx