Fix linting
Browse files- README-zh.md +9 -9
- README.md +9 -9
README-zh.md
CHANGED
@@ -824,7 +824,7 @@ rag = LightRAG(
|
|
824 |
create INDEX CONCURRENTLY entity_idx_node_id ON dickens."Entity" (ag_catalog.agtype_access_operator(properties, '"node_id"'::agtype));
|
825 |
CREATE INDEX CONCURRENTLY entity_node_id_gin_idx ON dickens."Entity" using gin(properties);
|
826 |
ALTER TABLE dickens."DIRECTED" CLUSTER ON directed_sid_idx;
|
827 |
-
|
828 |
-- 如有必要可以删除
|
829 |
drop INDEX entity_p_idx;
|
830 |
drop INDEX vertex_p_idx;
|
@@ -1182,17 +1182,17 @@ LightRAG 现已与 [RAG-Anything](https://github.com/HKUDS/RAG-Anything) 实现
|
|
1182 |
from lightrag.llm.openai import openai_complete_if_cache, openai_embed
|
1183 |
from lightrag.utils import EmbeddingFunc
|
1184 |
import os
|
1185 |
-
|
1186 |
async def load_existing_lightrag():
|
1187 |
# 首先,创建或加载现有的 LightRAG 实例
|
1188 |
lightrag_working_dir = "./existing_lightrag_storage"
|
1189 |
-
|
1190 |
# 检查是否存在之前的 LightRAG 实例
|
1191 |
if os.path.exists(lightrag_working_dir) and os.listdir(lightrag_working_dir):
|
1192 |
print("✅ Found existing LightRAG instance, loading...")
|
1193 |
else:
|
1194 |
print("❌ No existing LightRAG instance found, will create new one")
|
1195 |
-
|
1196 |
# 使用您的配置创建/加载 LightRAG 实例
|
1197 |
lightrag_instance = LightRAG(
|
1198 |
working_dir=lightrag_working_dir,
|
@@ -1215,10 +1215,10 @@ LightRAG 现已与 [RAG-Anything](https://github.com/HKUDS/RAG-Anything) 实现
|
|
1215 |
),
|
1216 |
)
|
1217 |
)
|
1218 |
-
|
1219 |
# 初始化存储(如果有现有数据,这将加载现有数据)
|
1220 |
await lightrag_instance.initialize_storages()
|
1221 |
-
|
1222 |
# 现在使用现有的 LightRAG 实例初始化 RAGAnything
|
1223 |
rag = RAGAnything(
|
1224 |
lightrag=lightrag_instance, # 传递现有的 LightRAG 实例
|
@@ -1247,20 +1247,20 @@ LightRAG 现已与 [RAG-Anything](https://github.com/HKUDS/RAG-Anything) 实现
|
|
1247 |
)
|
1248 |
# 注意:working_dir、llm_model_func、embedding_func 等都从 lightrag_instance 继承
|
1249 |
)
|
1250 |
-
|
1251 |
# 查询现有的知识库
|
1252 |
result = await rag.query_with_multimodal(
|
1253 |
"What data has been processed in this LightRAG instance?",
|
1254 |
mode="hybrid"
|
1255 |
)
|
1256 |
print("Query result:", result)
|
1257 |
-
|
1258 |
# 向现有的 LightRAG 实例添加新的多模态文档
|
1259 |
await rag.process_document_complete(
|
1260 |
file_path="path/to/new/multimodal_document.pdf",
|
1261 |
output_dir="./output"
|
1262 |
)
|
1263 |
-
|
1264 |
if __name__ == "__main__":
|
1265 |
asyncio.run(load_existing_lightrag())
|
1266 |
```
|
|
|
824 |
create INDEX CONCURRENTLY entity_idx_node_id ON dickens."Entity" (ag_catalog.agtype_access_operator(properties, '"node_id"'::agtype));
|
825 |
CREATE INDEX CONCURRENTLY entity_node_id_gin_idx ON dickens."Entity" using gin(properties);
|
826 |
ALTER TABLE dickens."DIRECTED" CLUSTER ON directed_sid_idx;
|
827 |
+
|
828 |
-- 如有必要可以删除
|
829 |
drop INDEX entity_p_idx;
|
830 |
drop INDEX vertex_p_idx;
|
|
|
1182 |
from lightrag.llm.openai import openai_complete_if_cache, openai_embed
|
1183 |
from lightrag.utils import EmbeddingFunc
|
1184 |
import os
|
1185 |
+
|
1186 |
async def load_existing_lightrag():
|
1187 |
# 首先,创建或加载现有的 LightRAG 实例
|
1188 |
lightrag_working_dir = "./existing_lightrag_storage"
|
1189 |
+
|
1190 |
# 检查是否存在之前的 LightRAG 实例
|
1191 |
if os.path.exists(lightrag_working_dir) and os.listdir(lightrag_working_dir):
|
1192 |
print("✅ Found existing LightRAG instance, loading...")
|
1193 |
else:
|
1194 |
print("❌ No existing LightRAG instance found, will create new one")
|
1195 |
+
|
1196 |
# 使用您的配置创建/加载 LightRAG 实例
|
1197 |
lightrag_instance = LightRAG(
|
1198 |
working_dir=lightrag_working_dir,
|
|
|
1215 |
),
|
1216 |
)
|
1217 |
)
|
1218 |
+
|
1219 |
# 初始化存储(如果有现有数据,这将加载现有数据)
|
1220 |
await lightrag_instance.initialize_storages()
|
1221 |
+
|
1222 |
# 现在使用现有的 LightRAG 实例初始化 RAGAnything
|
1223 |
rag = RAGAnything(
|
1224 |
lightrag=lightrag_instance, # 传递现有的 LightRAG 实例
|
|
|
1247 |
)
|
1248 |
# 注意:working_dir、llm_model_func、embedding_func 等都从 lightrag_instance 继承
|
1249 |
)
|
1250 |
+
|
1251 |
# 查询现有的知识库
|
1252 |
result = await rag.query_with_multimodal(
|
1253 |
"What data has been processed in this LightRAG instance?",
|
1254 |
mode="hybrid"
|
1255 |
)
|
1256 |
print("Query result:", result)
|
1257 |
+
|
1258 |
# 向现有的 LightRAG 实例添加新的多模态文档
|
1259 |
await rag.process_document_complete(
|
1260 |
file_path="path/to/new/multimodal_document.pdf",
|
1261 |
output_dir="./output"
|
1262 |
)
|
1263 |
+
|
1264 |
if __name__ == "__main__":
|
1265 |
asyncio.run(load_existing_lightrag())
|
1266 |
```
|
README.md
CHANGED
@@ -797,7 +797,7 @@ For production level scenarios you will most likely want to leverage an enterpri
|
|
797 |
create INDEX CONCURRENTLY entity_idx_node_id ON dickens."Entity" (ag_catalog.agtype_access_operator(properties, '"node_id"'::agtype));
|
798 |
CREATE INDEX CONCURRENTLY entity_node_id_gin_idx ON dickens."Entity" using gin(properties);
|
799 |
ALTER TABLE dickens."DIRECTED" CLUSTER ON directed_sid_idx;
|
800 |
-
|
801 |
-- drop if necessary
|
802 |
drop INDEX entity_p_idx;
|
803 |
drop INDEX vertex_p_idx;
|
@@ -1231,17 +1231,17 @@ LightRAG now seamlessly integrates with [RAG-Anything](https://github.com/HKUDS/
|
|
1231 |
from lightrag.llm.openai import openai_complete_if_cache, openai_embed
|
1232 |
from lightrag.utils import EmbeddingFunc
|
1233 |
import os
|
1234 |
-
|
1235 |
async def load_existing_lightrag():
|
1236 |
# First, create or load an existing LightRAG instance
|
1237 |
lightrag_working_dir = "./existing_lightrag_storage"
|
1238 |
-
|
1239 |
# Check if previous LightRAG instance exists
|
1240 |
if os.path.exists(lightrag_working_dir) and os.listdir(lightrag_working_dir):
|
1241 |
print("✅ Found existing LightRAG instance, loading...")
|
1242 |
else:
|
1243 |
print("❌ No existing LightRAG instance found, will create new one")
|
1244 |
-
|
1245 |
# Create/Load LightRAG instance with your configurations
|
1246 |
lightrag_instance = LightRAG(
|
1247 |
working_dir=lightrag_working_dir,
|
@@ -1264,10 +1264,10 @@ LightRAG now seamlessly integrates with [RAG-Anything](https://github.com/HKUDS/
|
|
1264 |
),
|
1265 |
)
|
1266 |
)
|
1267 |
-
|
1268 |
# Initialize storage (this will load existing data if available)
|
1269 |
await lightrag_instance.initialize_storages()
|
1270 |
-
|
1271 |
# Now initialize RAGAnything with the existing LightRAG instance
|
1272 |
rag = RAGAnything(
|
1273 |
lightrag=lightrag_instance, # Pass the existing LightRAG instance
|
@@ -1296,20 +1296,20 @@ LightRAG now seamlessly integrates with [RAG-Anything](https://github.com/HKUDS/
|
|
1296 |
)
|
1297 |
# Note: working_dir, llm_model_func, embedding_func, etc. are inherited from lightrag_instance
|
1298 |
)
|
1299 |
-
|
1300 |
# Query the existing knowledge base
|
1301 |
result = await rag.query_with_multimodal(
|
1302 |
"What data has been processed in this LightRAG instance?",
|
1303 |
mode="hybrid"
|
1304 |
)
|
1305 |
print("Query result:", result)
|
1306 |
-
|
1307 |
# Add new multimodal documents to the existing LightRAG instance
|
1308 |
await rag.process_document_complete(
|
1309 |
file_path="path/to/new/multimodal_document.pdf",
|
1310 |
output_dir="./output"
|
1311 |
)
|
1312 |
-
|
1313 |
if __name__ == "__main__":
|
1314 |
asyncio.run(load_existing_lightrag())
|
1315 |
```
|
|
|
797 |
create INDEX CONCURRENTLY entity_idx_node_id ON dickens."Entity" (ag_catalog.agtype_access_operator(properties, '"node_id"'::agtype));
|
798 |
CREATE INDEX CONCURRENTLY entity_node_id_gin_idx ON dickens."Entity" using gin(properties);
|
799 |
ALTER TABLE dickens."DIRECTED" CLUSTER ON directed_sid_idx;
|
800 |
+
|
801 |
-- drop if necessary
|
802 |
drop INDEX entity_p_idx;
|
803 |
drop INDEX vertex_p_idx;
|
|
|
1231 |
from lightrag.llm.openai import openai_complete_if_cache, openai_embed
|
1232 |
from lightrag.utils import EmbeddingFunc
|
1233 |
import os
|
1234 |
+
|
1235 |
async def load_existing_lightrag():
|
1236 |
# First, create or load an existing LightRAG instance
|
1237 |
lightrag_working_dir = "./existing_lightrag_storage"
|
1238 |
+
|
1239 |
# Check if previous LightRAG instance exists
|
1240 |
if os.path.exists(lightrag_working_dir) and os.listdir(lightrag_working_dir):
|
1241 |
print("✅ Found existing LightRAG instance, loading...")
|
1242 |
else:
|
1243 |
print("❌ No existing LightRAG instance found, will create new one")
|
1244 |
+
|
1245 |
# Create/Load LightRAG instance with your configurations
|
1246 |
lightrag_instance = LightRAG(
|
1247 |
working_dir=lightrag_working_dir,
|
|
|
1264 |
),
|
1265 |
)
|
1266 |
)
|
1267 |
+
|
1268 |
# Initialize storage (this will load existing data if available)
|
1269 |
await lightrag_instance.initialize_storages()
|
1270 |
+
|
1271 |
# Now initialize RAGAnything with the existing LightRAG instance
|
1272 |
rag = RAGAnything(
|
1273 |
lightrag=lightrag_instance, # Pass the existing LightRAG instance
|
|
|
1296 |
)
|
1297 |
# Note: working_dir, llm_model_func, embedding_func, etc. are inherited from lightrag_instance
|
1298 |
)
|
1299 |
+
|
1300 |
# Query the existing knowledge base
|
1301 |
result = await rag.query_with_multimodal(
|
1302 |
"What data has been processed in this LightRAG instance?",
|
1303 |
mode="hybrid"
|
1304 |
)
|
1305 |
print("Query result:", result)
|
1306 |
+
|
1307 |
# Add new multimodal documents to the existing LightRAG instance
|
1308 |
await rag.process_document_complete(
|
1309 |
file_path="path/to/new/multimodal_document.pdf",
|
1310 |
output_dir="./output"
|
1311 |
)
|
1312 |
+
|
1313 |
if __name__ == "__main__":
|
1314 |
asyncio.run(load_existing_lightrag())
|
1315 |
```
|