gzdaniel commited on
Commit
75d4e58
·
1 Parent(s): 31493cc

Fix linting

Browse files
Files changed (3) hide show
  1. README-zh.md +9 -9
  2. README.md +9 -9
  3. lightrag/kg/faiss_impl.py +0 -2
README-zh.md CHANGED
@@ -820,7 +820,7 @@ rag = LightRAG(
820
  create INDEX CONCURRENTLY entity_idx_node_id ON dickens."Entity" (ag_catalog.agtype_access_operator(properties, '"node_id"'::agtype));
821
  CREATE INDEX CONCURRENTLY entity_node_id_gin_idx ON dickens."Entity" using gin(properties);
822
  ALTER TABLE dickens."DIRECTED" CLUSTER ON directed_sid_idx;
823
-
824
  -- 如有必要可以删除
825
  drop INDEX entity_p_idx;
826
  drop INDEX vertex_p_idx;
@@ -1166,17 +1166,17 @@ LightRAG 现已与 [RAG-Anything](https://github.com/HKUDS/RAG-Anything) 实现
1166
  from lightrag.llm.openai import openai_complete_if_cache, openai_embed
1167
  from lightrag.utils import EmbeddingFunc
1168
  import os
1169
-
1170
  async def load_existing_lightrag():
1171
  # 首先,创建或加载现有的 LightRAG 实例
1172
  lightrag_working_dir = "./existing_lightrag_storage"
1173
-
1174
  # 检查是否存在之前的 LightRAG 实例
1175
  if os.path.exists(lightrag_working_dir) and os.listdir(lightrag_working_dir):
1176
  print("✅ Found existing LightRAG instance, loading...")
1177
  else:
1178
  print("❌ No existing LightRAG instance found, will create new one")
1179
-
1180
  # 使用您的配置创建/加载 LightRAG 实例
1181
  lightrag_instance = LightRAG(
1182
  working_dir=lightrag_working_dir,
@@ -1199,10 +1199,10 @@ LightRAG 现已与 [RAG-Anything](https://github.com/HKUDS/RAG-Anything) 实现
1199
  ),
1200
  )
1201
  )
1202
-
1203
  # 初始化存储(如果有现有数据,这将加载现有数据)
1204
  await lightrag_instance.initialize_storages()
1205
-
1206
  # 现在使用现有的 LightRAG 实例初始化 RAGAnything
1207
  rag = RAGAnything(
1208
  lightrag=lightrag_instance, # 传递现有的 LightRAG 实例
@@ -1231,20 +1231,20 @@ LightRAG 现已与 [RAG-Anything](https://github.com/HKUDS/RAG-Anything) 实现
1231
  )
1232
  # 注意:working_dir、llm_model_func、embedding_func 等都从 lightrag_instance 继承
1233
  )
1234
-
1235
  # 查询现有的知识库
1236
  result = await rag.query_with_multimodal(
1237
  "What data has been processed in this LightRAG instance?",
1238
  mode="hybrid"
1239
  )
1240
  print("Query result:", result)
1241
-
1242
  # 向现有的 LightRAG 实例添加新的多模态文档
1243
  await rag.process_document_complete(
1244
  file_path="path/to/new/multimodal_document.pdf",
1245
  output_dir="./output"
1246
  )
1247
-
1248
  if __name__ == "__main__":
1249
  asyncio.run(load_existing_lightrag())
1250
  ```
 
820
  create INDEX CONCURRENTLY entity_idx_node_id ON dickens."Entity" (ag_catalog.agtype_access_operator(properties, '"node_id"'::agtype));
821
  CREATE INDEX CONCURRENTLY entity_node_id_gin_idx ON dickens."Entity" using gin(properties);
822
  ALTER TABLE dickens."DIRECTED" CLUSTER ON directed_sid_idx;
823
+
824
  -- 如有必要可以删除
825
  drop INDEX entity_p_idx;
826
  drop INDEX vertex_p_idx;
 
1166
  from lightrag.llm.openai import openai_complete_if_cache, openai_embed
1167
  from lightrag.utils import EmbeddingFunc
1168
  import os
1169
+
1170
  async def load_existing_lightrag():
1171
  # 首先,创建或加载现有的 LightRAG 实例
1172
  lightrag_working_dir = "./existing_lightrag_storage"
1173
+
1174
  # 检查是否存在之前的 LightRAG 实例
1175
  if os.path.exists(lightrag_working_dir) and os.listdir(lightrag_working_dir):
1176
  print("✅ Found existing LightRAG instance, loading...")
1177
  else:
1178
  print("❌ No existing LightRAG instance found, will create new one")
1179
+
1180
  # 使用您的配置创建/加载 LightRAG 实例
1181
  lightrag_instance = LightRAG(
1182
  working_dir=lightrag_working_dir,
 
1199
  ),
1200
  )
1201
  )
1202
+
1203
  # 初始化存储(如果有现有数据,这将加载现有数据)
1204
  await lightrag_instance.initialize_storages()
1205
+
1206
  # 现在使用现有的 LightRAG 实例初始化 RAGAnything
1207
  rag = RAGAnything(
1208
  lightrag=lightrag_instance, # 传递现有的 LightRAG 实例
 
1231
  )
1232
  # 注意:working_dir、llm_model_func、embedding_func 等都从 lightrag_instance 继承
1233
  )
1234
+
1235
  # 查询现有的知识库
1236
  result = await rag.query_with_multimodal(
1237
  "What data has been processed in this LightRAG instance?",
1238
  mode="hybrid"
1239
  )
1240
  print("Query result:", result)
1241
+
1242
  # 向现有的 LightRAG 实例添加新的多模态文档
1243
  await rag.process_document_complete(
1244
  file_path="path/to/new/multimodal_document.pdf",
1245
  output_dir="./output"
1246
  )
1247
+
1248
  if __name__ == "__main__":
1249
  asyncio.run(load_existing_lightrag())
1250
  ```
README.md CHANGED
@@ -792,7 +792,7 @@ For production level scenarios you will most likely want to leverage an enterpri
792
  create INDEX CONCURRENTLY entity_idx_node_id ON dickens."Entity" (ag_catalog.agtype_access_operator(properties, '"node_id"'::agtype));
793
  CREATE INDEX CONCURRENTLY entity_node_id_gin_idx ON dickens."Entity" using gin(properties);
794
  ALTER TABLE dickens."DIRECTED" CLUSTER ON directed_sid_idx;
795
-
796
  -- drop if necessary
797
  drop INDEX entity_p_idx;
798
  drop INDEX vertex_p_idx;
@@ -1180,17 +1180,17 @@ LightRAG now seamlessly integrates with [RAG-Anything](https://github.com/HKUDS/
1180
  from lightrag.llm.openai import openai_complete_if_cache, openai_embed
1181
  from lightrag.utils import EmbeddingFunc
1182
  import os
1183
-
1184
  async def load_existing_lightrag():
1185
  # First, create or load an existing LightRAG instance
1186
  lightrag_working_dir = "./existing_lightrag_storage"
1187
-
1188
  # Check if previous LightRAG instance exists
1189
  if os.path.exists(lightrag_working_dir) and os.listdir(lightrag_working_dir):
1190
  print("✅ Found existing LightRAG instance, loading...")
1191
  else:
1192
  print("❌ No existing LightRAG instance found, will create new one")
1193
-
1194
  # Create/Load LightRAG instance with your configurations
1195
  lightrag_instance = LightRAG(
1196
  working_dir=lightrag_working_dir,
@@ -1213,10 +1213,10 @@ LightRAG now seamlessly integrates with [RAG-Anything](https://github.com/HKUDS/
1213
  ),
1214
  )
1215
  )
1216
-
1217
  # Initialize storage (this will load existing data if available)
1218
  await lightrag_instance.initialize_storages()
1219
-
1220
  # Now initialize RAGAnything with the existing LightRAG instance
1221
  rag = RAGAnything(
1222
  lightrag=lightrag_instance, # Pass the existing LightRAG instance
@@ -1245,20 +1245,20 @@ LightRAG now seamlessly integrates with [RAG-Anything](https://github.com/HKUDS/
1245
  )
1246
  # Note: working_dir, llm_model_func, embedding_func, etc. are inherited from lightrag_instance
1247
  )
1248
-
1249
  # Query the existing knowledge base
1250
  result = await rag.query_with_multimodal(
1251
  "What data has been processed in this LightRAG instance?",
1252
  mode="hybrid"
1253
  )
1254
  print("Query result:", result)
1255
-
1256
  # Add new multimodal documents to the existing LightRAG instance
1257
  await rag.process_document_complete(
1258
  file_path="path/to/new/multimodal_document.pdf",
1259
  output_dir="./output"
1260
  )
1261
-
1262
  if __name__ == "__main__":
1263
  asyncio.run(load_existing_lightrag())
1264
  ```
 
792
  create INDEX CONCURRENTLY entity_idx_node_id ON dickens."Entity" (ag_catalog.agtype_access_operator(properties, '"node_id"'::agtype));
793
  CREATE INDEX CONCURRENTLY entity_node_id_gin_idx ON dickens."Entity" using gin(properties);
794
  ALTER TABLE dickens."DIRECTED" CLUSTER ON directed_sid_idx;
795
+
796
  -- drop if necessary
797
  drop INDEX entity_p_idx;
798
  drop INDEX vertex_p_idx;
 
1180
  from lightrag.llm.openai import openai_complete_if_cache, openai_embed
1181
  from lightrag.utils import EmbeddingFunc
1182
  import os
1183
+
1184
  async def load_existing_lightrag():
1185
  # First, create or load an existing LightRAG instance
1186
  lightrag_working_dir = "./existing_lightrag_storage"
1187
+
1188
  # Check if previous LightRAG instance exists
1189
  if os.path.exists(lightrag_working_dir) and os.listdir(lightrag_working_dir):
1190
  print("✅ Found existing LightRAG instance, loading...")
1191
  else:
1192
  print("❌ No existing LightRAG instance found, will create new one")
1193
+
1194
  # Create/Load LightRAG instance with your configurations
1195
  lightrag_instance = LightRAG(
1196
  working_dir=lightrag_working_dir,
 
1213
  ),
1214
  )
1215
  )
1216
+
1217
  # Initialize storage (this will load existing data if available)
1218
  await lightrag_instance.initialize_storages()
1219
+
1220
  # Now initialize RAGAnything with the existing LightRAG instance
1221
  rag = RAGAnything(
1222
  lightrag=lightrag_instance, # Pass the existing LightRAG instance
 
1245
  )
1246
  # Note: working_dir, llm_model_func, embedding_func, etc. are inherited from lightrag_instance
1247
  )
1248
+
1249
  # Query the existing knowledge base
1250
  result = await rag.query_with_multimodal(
1251
  "What data has been processed in this LightRAG instance?",
1252
  mode="hybrid"
1253
  )
1254
  print("Query result:", result)
1255
+
1256
  # Add new multimodal documents to the existing LightRAG instance
1257
  await rag.process_document_complete(
1258
  file_path="path/to/new/multimodal_document.pdf",
1259
  output_dir="./output"
1260
  )
1261
+
1262
  if __name__ == "__main__":
1263
  asyncio.run(load_existing_lightrag())
1264
  ```
lightrag/kg/faiss_impl.py CHANGED
@@ -4,9 +4,7 @@ import asyncio
4
  from typing import Any, final
5
  import json
6
  import numpy as np
7
-
8
  from dataclasses import dataclass
9
- import pipmaster as pm
10
 
11
  from lightrag.utils import logger, compute_mdhash_id
12
  from lightrag.base import BaseVectorStorage
 
4
  from typing import Any, final
5
  import json
6
  import numpy as np
 
7
  from dataclasses import dataclass
 
8
 
9
  from lightrag.utils import logger, compute_mdhash_id
10
  from lightrag.base import BaseVectorStorage