mirror of
https://github.com/HKUDS/LightRAG.git
synced 2025-08-05 23:31:54 +00:00
Fix linting
This commit is contained in:
parent
2e2b9f3b48
commit
bdfd2d53c7
18
README-zh.md
18
README-zh.md
@ -820,7 +820,7 @@ rag = LightRAG(
|
|||||||
create INDEX CONCURRENTLY entity_idx_node_id ON dickens."Entity" (ag_catalog.agtype_access_operator(properties, '"node_id"'::agtype));
|
create INDEX CONCURRENTLY entity_idx_node_id ON dickens."Entity" (ag_catalog.agtype_access_operator(properties, '"node_id"'::agtype));
|
||||||
CREATE INDEX CONCURRENTLY entity_node_id_gin_idx ON dickens."Entity" using gin(properties);
|
CREATE INDEX CONCURRENTLY entity_node_id_gin_idx ON dickens."Entity" using gin(properties);
|
||||||
ALTER TABLE dickens."DIRECTED" CLUSTER ON directed_sid_idx;
|
ALTER TABLE dickens."DIRECTED" CLUSTER ON directed_sid_idx;
|
||||||
|
|
||||||
-- 如有必要可以删除
|
-- 如有必要可以删除
|
||||||
drop INDEX entity_p_idx;
|
drop INDEX entity_p_idx;
|
||||||
drop INDEX vertex_p_idx;
|
drop INDEX vertex_p_idx;
|
||||||
@ -1166,17 +1166,17 @@ LightRAG 现已与 [RAG-Anything](https://github.com/HKUDS/RAG-Anything) 实现
|
|||||||
from lightrag.llm.openai import openai_complete_if_cache, openai_embed
|
from lightrag.llm.openai import openai_complete_if_cache, openai_embed
|
||||||
from lightrag.utils import EmbeddingFunc
|
from lightrag.utils import EmbeddingFunc
|
||||||
import os
|
import os
|
||||||
|
|
||||||
async def load_existing_lightrag():
|
async def load_existing_lightrag():
|
||||||
# 首先,创建或加载现有的 LightRAG 实例
|
# 首先,创建或加载现有的 LightRAG 实例
|
||||||
lightrag_working_dir = "./existing_lightrag_storage"
|
lightrag_working_dir = "./existing_lightrag_storage"
|
||||||
|
|
||||||
# 检查是否存在之前的 LightRAG 实例
|
# 检查是否存在之前的 LightRAG 实例
|
||||||
if os.path.exists(lightrag_working_dir) and os.listdir(lightrag_working_dir):
|
if os.path.exists(lightrag_working_dir) and os.listdir(lightrag_working_dir):
|
||||||
print("✅ Found existing LightRAG instance, loading...")
|
print("✅ Found existing LightRAG instance, loading...")
|
||||||
else:
|
else:
|
||||||
print("❌ No existing LightRAG instance found, will create new one")
|
print("❌ No existing LightRAG instance found, will create new one")
|
||||||
|
|
||||||
# 使用您的配置创建/加载 LightRAG 实例
|
# 使用您的配置创建/加载 LightRAG 实例
|
||||||
lightrag_instance = LightRAG(
|
lightrag_instance = LightRAG(
|
||||||
working_dir=lightrag_working_dir,
|
working_dir=lightrag_working_dir,
|
||||||
@ -1199,10 +1199,10 @@ LightRAG 现已与 [RAG-Anything](https://github.com/HKUDS/RAG-Anything) 实现
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
# 初始化存储(如果有现有数据,这将加载现有数据)
|
# 初始化存储(如果有现有数据,这将加载现有数据)
|
||||||
await lightrag_instance.initialize_storages()
|
await lightrag_instance.initialize_storages()
|
||||||
|
|
||||||
# 现在使用现有的 LightRAG 实例初始化 RAGAnything
|
# 现在使用现有的 LightRAG 实例初始化 RAGAnything
|
||||||
rag = RAGAnything(
|
rag = RAGAnything(
|
||||||
lightrag=lightrag_instance, # 传递现有的 LightRAG 实例
|
lightrag=lightrag_instance, # 传递现有的 LightRAG 实例
|
||||||
@ -1231,20 +1231,20 @@ LightRAG 现已与 [RAG-Anything](https://github.com/HKUDS/RAG-Anything) 实现
|
|||||||
)
|
)
|
||||||
# 注意:working_dir、llm_model_func、embedding_func 等都从 lightrag_instance 继承
|
# 注意:working_dir、llm_model_func、embedding_func 等都从 lightrag_instance 继承
|
||||||
)
|
)
|
||||||
|
|
||||||
# 查询现有的知识库
|
# 查询现有的知识库
|
||||||
result = await rag.query_with_multimodal(
|
result = await rag.query_with_multimodal(
|
||||||
"What data has been processed in this LightRAG instance?",
|
"What data has been processed in this LightRAG instance?",
|
||||||
mode="hybrid"
|
mode="hybrid"
|
||||||
)
|
)
|
||||||
print("Query result:", result)
|
print("Query result:", result)
|
||||||
|
|
||||||
# 向现有的 LightRAG 实例添加新的多模态文档
|
# 向现有的 LightRAG 实例添加新的多模态文档
|
||||||
await rag.process_document_complete(
|
await rag.process_document_complete(
|
||||||
file_path="path/to/new/multimodal_document.pdf",
|
file_path="path/to/new/multimodal_document.pdf",
|
||||||
output_dir="./output"
|
output_dir="./output"
|
||||||
)
|
)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
asyncio.run(load_existing_lightrag())
|
asyncio.run(load_existing_lightrag())
|
||||||
```
|
```
|
||||||
|
18
README.md
18
README.md
@ -792,7 +792,7 @@ For production level scenarios you will most likely want to leverage an enterpri
|
|||||||
create INDEX CONCURRENTLY entity_idx_node_id ON dickens."Entity" (ag_catalog.agtype_access_operator(properties, '"node_id"'::agtype));
|
create INDEX CONCURRENTLY entity_idx_node_id ON dickens."Entity" (ag_catalog.agtype_access_operator(properties, '"node_id"'::agtype));
|
||||||
CREATE INDEX CONCURRENTLY entity_node_id_gin_idx ON dickens."Entity" using gin(properties);
|
CREATE INDEX CONCURRENTLY entity_node_id_gin_idx ON dickens."Entity" using gin(properties);
|
||||||
ALTER TABLE dickens."DIRECTED" CLUSTER ON directed_sid_idx;
|
ALTER TABLE dickens."DIRECTED" CLUSTER ON directed_sid_idx;
|
||||||
|
|
||||||
-- drop if necessary
|
-- drop if necessary
|
||||||
drop INDEX entity_p_idx;
|
drop INDEX entity_p_idx;
|
||||||
drop INDEX vertex_p_idx;
|
drop INDEX vertex_p_idx;
|
||||||
@ -1180,17 +1180,17 @@ LightRAG now seamlessly integrates with [RAG-Anything](https://github.com/HKUDS/
|
|||||||
from lightrag.llm.openai import openai_complete_if_cache, openai_embed
|
from lightrag.llm.openai import openai_complete_if_cache, openai_embed
|
||||||
from lightrag.utils import EmbeddingFunc
|
from lightrag.utils import EmbeddingFunc
|
||||||
import os
|
import os
|
||||||
|
|
||||||
async def load_existing_lightrag():
|
async def load_existing_lightrag():
|
||||||
# First, create or load an existing LightRAG instance
|
# First, create or load an existing LightRAG instance
|
||||||
lightrag_working_dir = "./existing_lightrag_storage"
|
lightrag_working_dir = "./existing_lightrag_storage"
|
||||||
|
|
||||||
# Check if previous LightRAG instance exists
|
# Check if previous LightRAG instance exists
|
||||||
if os.path.exists(lightrag_working_dir) and os.listdir(lightrag_working_dir):
|
if os.path.exists(lightrag_working_dir) and os.listdir(lightrag_working_dir):
|
||||||
print("✅ Found existing LightRAG instance, loading...")
|
print("✅ Found existing LightRAG instance, loading...")
|
||||||
else:
|
else:
|
||||||
print("❌ No existing LightRAG instance found, will create new one")
|
print("❌ No existing LightRAG instance found, will create new one")
|
||||||
|
|
||||||
# Create/Load LightRAG instance with your configurations
|
# Create/Load LightRAG instance with your configurations
|
||||||
lightrag_instance = LightRAG(
|
lightrag_instance = LightRAG(
|
||||||
working_dir=lightrag_working_dir,
|
working_dir=lightrag_working_dir,
|
||||||
@ -1213,10 +1213,10 @@ LightRAG now seamlessly integrates with [RAG-Anything](https://github.com/HKUDS/
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
# Initialize storage (this will load existing data if available)
|
# Initialize storage (this will load existing data if available)
|
||||||
await lightrag_instance.initialize_storages()
|
await lightrag_instance.initialize_storages()
|
||||||
|
|
||||||
# Now initialize RAGAnything with the existing LightRAG instance
|
# Now initialize RAGAnything with the existing LightRAG instance
|
||||||
rag = RAGAnything(
|
rag = RAGAnything(
|
||||||
lightrag=lightrag_instance, # Pass the existing LightRAG instance
|
lightrag=lightrag_instance, # Pass the existing LightRAG instance
|
||||||
@ -1245,20 +1245,20 @@ LightRAG now seamlessly integrates with [RAG-Anything](https://github.com/HKUDS/
|
|||||||
)
|
)
|
||||||
# Note: working_dir, llm_model_func, embedding_func, etc. are inherited from lightrag_instance
|
# Note: working_dir, llm_model_func, embedding_func, etc. are inherited from lightrag_instance
|
||||||
)
|
)
|
||||||
|
|
||||||
# Query the existing knowledge base
|
# Query the existing knowledge base
|
||||||
result = await rag.query_with_multimodal(
|
result = await rag.query_with_multimodal(
|
||||||
"What data has been processed in this LightRAG instance?",
|
"What data has been processed in this LightRAG instance?",
|
||||||
mode="hybrid"
|
mode="hybrid"
|
||||||
)
|
)
|
||||||
print("Query result:", result)
|
print("Query result:", result)
|
||||||
|
|
||||||
# Add new multimodal documents to the existing LightRAG instance
|
# Add new multimodal documents to the existing LightRAG instance
|
||||||
await rag.process_document_complete(
|
await rag.process_document_complete(
|
||||||
file_path="path/to/new/multimodal_document.pdf",
|
file_path="path/to/new/multimodal_document.pdf",
|
||||||
output_dir="./output"
|
output_dir="./output"
|
||||||
)
|
)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
asyncio.run(load_existing_lightrag())
|
asyncio.run(load_existing_lightrag())
|
||||||
```
|
```
|
||||||
|
@ -4,9 +4,7 @@ import asyncio
|
|||||||
from typing import Any, final
|
from typing import Any, final
|
||||||
import json
|
import json
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
import pipmaster as pm
|
|
||||||
|
|
||||||
from lightrag.utils import logger, compute_mdhash_id
|
from lightrag.utils import logger, compute_mdhash_id
|
||||||
from lightrag.base import BaseVectorStorage
|
from lightrag.base import BaseVectorStorage
|
||||||
|
Loading…
x
Reference in New Issue
Block a user