back to not making breaks
Browse files- lightrag/kg/age_impl.py +8 -1
- lightrag/kg/chroma_impl.py +4 -0
- lightrag/kg/faiss_impl.py +6 -1
- lightrag/kg/milvus_impl.py +7 -5
- lightrag/kg/mongo_impl.py +7 -3
- lightrag/kg/nano_vector_db_impl.py +4 -1
- lightrag/kg/oracle_impl.py +5 -0
- lightrag/kg/postgres_impl.py +5 -0
- lightrag/kg/qdrant_impl.py +5 -0
- lightrag/kg/tidb_impl.py +7 -0
lightrag/kg/age_impl.py
CHANGED
@@ -7,7 +7,7 @@ from contextlib import asynccontextmanager
|
|
7 |
from dataclasses import dataclass
|
8 |
from typing import Any, Dict, List, NamedTuple, Optional, Union, final
|
9 |
import numpy as np
|
10 |
-
|
11 |
from lightrag.types import KnowledgeGraph
|
12 |
|
13 |
from tenacity import (
|
@@ -27,6 +27,13 @@ if sys.platform.startswith("win"):
|
|
27 |
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
|
28 |
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
try:
|
31 |
import psycopg
|
32 |
from psycopg.rows import namedtuple_row
|
|
|
7 |
from dataclasses import dataclass
|
8 |
from typing import Any, Dict, List, NamedTuple, Optional, Union, final
|
9 |
import numpy as np
|
10 |
+
import pipmaster as pm
|
11 |
from lightrag.types import KnowledgeGraph
|
12 |
|
13 |
from tenacity import (
|
|
|
27 |
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
|
28 |
|
29 |
|
30 |
+
if not pm.is_installed("psycopg-pool"):
|
31 |
+
pm.install("psycopg-pool")
|
32 |
+
pm.install("psycopg[binary,pool]")
|
33 |
+
|
34 |
+
if not pm.is_installed("asyncpg"):
|
35 |
+
pm.install("asyncpg")
|
36 |
+
|
37 |
try:
|
38 |
import psycopg
|
39 |
from psycopg.rows import namedtuple_row
|
lightrag/kg/chroma_impl.py
CHANGED
@@ -5,6 +5,10 @@ import numpy as np
|
|
5 |
|
6 |
from lightrag.base import BaseVectorStorage
|
7 |
from lightrag.utils import logger
|
|
|
|
|
|
|
|
|
8 |
|
9 |
try:
|
10 |
from chromadb import HttpClient, PersistentClient
|
|
|
5 |
|
6 |
from lightrag.base import BaseVectorStorage
|
7 |
from lightrag.utils import logger
|
8 |
+
import pipmaster as pm
|
9 |
+
|
10 |
+
if not pm.is_installed("chromadb"):
|
11 |
+
pm.install("chromadb")
|
12 |
|
13 |
try:
|
14 |
from chromadb import HttpClient, PersistentClient
|
lightrag/kg/faiss_impl.py
CHANGED
@@ -5,8 +5,9 @@ from typing import Any, final
|
|
5 |
|
6 |
import json
|
7 |
import numpy as np
|
8 |
-
|
9 |
from dataclasses import dataclass
|
|
|
10 |
|
11 |
from lightrag.utils import (
|
12 |
logger,
|
@@ -16,8 +17,12 @@ from lightrag.base import (
|
|
16 |
BaseVectorStorage,
|
17 |
)
|
18 |
|
|
|
|
|
|
|
19 |
try:
|
20 |
import faiss
|
|
|
21 |
except ImportError as e:
|
22 |
raise ImportError(
|
23 |
"`faiss` library is not installed. Please install it via pip: `pip install faiss`."
|
|
|
5 |
|
6 |
import json
|
7 |
import numpy as np
|
8 |
+
|
9 |
from dataclasses import dataclass
|
10 |
+
import pipmaster as pm
|
11 |
|
12 |
from lightrag.utils import (
|
13 |
logger,
|
|
|
17 |
BaseVectorStorage,
|
18 |
)
|
19 |
|
20 |
+
if not pm.is_installed("faiss"):
|
21 |
+
pm.install("faiss")
|
22 |
+
|
23 |
try:
|
24 |
import faiss
|
25 |
+
from tqdm.asyncio import tqdm as tqdm_async
|
26 |
except ImportError as e:
|
27 |
raise ImportError(
|
28 |
"`faiss` library is not installed. Please install it via pip: `pip install faiss`."
|
lightrag/kg/milvus_impl.py
CHANGED
@@ -6,16 +6,18 @@ from dataclasses import dataclass
|
|
6 |
import numpy as np
|
7 |
from lightrag.utils import logger
|
8 |
from ..base import BaseVectorStorage
|
9 |
-
|
10 |
import configparser
|
11 |
|
|
|
|
|
|
|
12 |
try:
|
13 |
from pymilvus import MilvusClient
|
14 |
-
except ImportError:
|
15 |
raise ImportError(
|
16 |
-
"pymilvus library is not installed. Please install it
|
17 |
-
)
|
18 |
-
|
19 |
|
20 |
config = configparser.ConfigParser()
|
21 |
config.read("config.ini", "utf-8")
|
|
|
6 |
import numpy as np
|
7 |
from lightrag.utils import logger
|
8 |
from ..base import BaseVectorStorage
|
9 |
+
import pipmaster as pm
|
10 |
import configparser
|
11 |
|
12 |
+
if not pm.is_installed("pymilvus"):
|
13 |
+
pm.install("pymilvus")
|
14 |
+
|
15 |
try:
|
16 |
from pymilvus import MilvusClient
|
17 |
+
except ImportError as e:
|
18 |
raise ImportError(
|
19 |
+
"`pymilvus` library is not installed. Please install it via pip: `pip install pymilvus`."
|
20 |
+
) from e
|
|
|
21 |
|
22 |
config = configparser.ConfigParser()
|
23 |
config.read("config.ini", "utf-8")
|
lightrag/kg/mongo_impl.py
CHANGED
@@ -18,6 +18,13 @@ from ..base import (
|
|
18 |
from ..namespace import NameSpace, is_namespace
|
19 |
from ..utils import logger
|
20 |
from ..types import KnowledgeGraph, KnowledgeGraphNode, KnowledgeGraphEdge
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
try:
|
23 |
from motor.motor_asyncio import AsyncIOMotorClient
|
@@ -214,9 +221,6 @@ class MongoDocStatusStorage(DocStatusStorage):
|
|
214 |
# Implement the method here
|
215 |
pass
|
216 |
|
217 |
-
async def update_doc_status(self, data: dict[str, Any]) -> None:
|
218 |
-
raise NotImplementedError
|
219 |
-
|
220 |
|
221 |
@final
|
222 |
@dataclass
|
|
|
18 |
from ..namespace import NameSpace, is_namespace
|
19 |
from ..utils import logger
|
20 |
from ..types import KnowledgeGraph, KnowledgeGraphNode, KnowledgeGraphEdge
|
21 |
+
import pipmaster as pm
|
22 |
+
|
23 |
+
if not pm.is_installed("pymongo"):
|
24 |
+
pm.install("pymongo")
|
25 |
+
|
26 |
+
if not pm.is_installed("motor"):
|
27 |
+
pm.install("motor")
|
28 |
|
29 |
try:
|
30 |
from motor.motor_asyncio import AsyncIOMotorClient
|
|
|
221 |
# Implement the method here
|
222 |
pass
|
223 |
|
|
|
|
|
|
|
224 |
|
225 |
@final
|
226 |
@dataclass
|
lightrag/kg/nano_vector_db_impl.py
CHANGED
@@ -11,11 +11,14 @@ from lightrag.utils import (
|
|
11 |
logger,
|
12 |
compute_mdhash_id,
|
13 |
)
|
14 |
-
|
15 |
from lightrag.base import (
|
16 |
BaseVectorStorage,
|
17 |
)
|
18 |
|
|
|
|
|
|
|
19 |
try:
|
20 |
from nano_vectordb import NanoVectorDB
|
21 |
except ImportError as e:
|
|
|
11 |
logger,
|
12 |
compute_mdhash_id,
|
13 |
)
|
14 |
+
import pipmaster as pm
|
15 |
from lightrag.base import (
|
16 |
BaseVectorStorage,
|
17 |
)
|
18 |
|
19 |
+
if not pm.is_installed("nano-vectordb"):
|
20 |
+
pm.install("nano-vectordb")
|
21 |
+
|
22 |
try:
|
23 |
from nano_vectordb import NanoVectorDB
|
24 |
except ImportError as e:
|
lightrag/kg/oracle_impl.py
CHANGED
@@ -18,6 +18,11 @@ from ..base import (
|
|
18 |
from ..namespace import NameSpace, is_namespace
|
19 |
from ..utils import logger
|
20 |
|
|
|
|
|
|
|
|
|
|
|
21 |
try:
|
22 |
import oracledb
|
23 |
|
|
|
18 |
from ..namespace import NameSpace, is_namespace
|
19 |
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 |
|
lightrag/kg/postgres_impl.py
CHANGED
@@ -34,6 +34,11 @@ if sys.platform.startswith("win"):
|
|
34 |
|
35 |
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
|
36 |
|
|
|
|
|
|
|
|
|
|
|
37 |
try:
|
38 |
import asyncpg
|
39 |
from tqdm.asyncio import tqdm as tqdm_async
|
|
|
34 |
|
35 |
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
|
36 |
|
37 |
+
import pipmaster as pm
|
38 |
+
|
39 |
+
if not pm.is_installed("asyncpg"):
|
40 |
+
pm.install("asyncpg")
|
41 |
+
|
42 |
try:
|
43 |
import asyncpg
|
44 |
from tqdm.asyncio import tqdm as tqdm_async
|
lightrag/kg/qdrant_impl.py
CHANGED
@@ -14,6 +14,11 @@ import configparser
|
|
14 |
config = configparser.ConfigParser()
|
15 |
config.read("config.ini", "utf-8")
|
16 |
|
|
|
|
|
|
|
|
|
|
|
17 |
try:
|
18 |
from qdrant_client import QdrantClient, models
|
19 |
|
|
|
14 |
config = configparser.ConfigParser()
|
15 |
config.read("config.ini", "utf-8")
|
16 |
|
17 |
+
import pipmaster as pm
|
18 |
+
|
19 |
+
if not pm.is_installed("qdrant_client"):
|
20 |
+
pm.install("qdrant_client")
|
21 |
+
|
22 |
try:
|
23 |
from qdrant_client import QdrantClient, models
|
24 |
|
lightrag/kg/tidb_impl.py
CHANGED
@@ -13,6 +13,13 @@ from ..base import BaseGraphStorage, BaseKVStorage, BaseVectorStorage
|
|
13 |
from ..namespace import NameSpace, is_namespace
|
14 |
from ..utils import logger
|
15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
try:
|
17 |
from sqlalchemy import create_engine, text
|
18 |
|
|
|
13 |
from ..namespace import NameSpace, is_namespace
|
14 |
from ..utils import logger
|
15 |
|
16 |
+
import pipmaster as pm
|
17 |
+
|
18 |
+
if not pm.is_installed("pymysql"):
|
19 |
+
pm.install("pymysql")
|
20 |
+
if not pm.is_installed("sqlalchemy"):
|
21 |
+
pm.install("sqlalchemy")
|
22 |
+
|
23 |
try:
|
24 |
from sqlalchemy import create_engine, text
|
25 |
|