mirror of
				https://github.com/HKUDS/LightRAG.git
				synced 2025-11-04 03:39:35 +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_node_id_gin_idx ON dickens."Entity" using gin(properties);
 | 
			
		||||
  ALTER TABLE dickens."DIRECTED" CLUSTER ON directed_sid_idx;
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  -- 如有必要可以删除
 | 
			
		||||
  drop INDEX entity_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.utils import EmbeddingFunc
 | 
			
		||||
        import os
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
        async def load_existing_lightrag():
 | 
			
		||||
            # 首先,创建或加载现有的 LightRAG 实例
 | 
			
		||||
            lightrag_working_dir = "./existing_lightrag_storage"
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
            # 检查是否存在之前的 LightRAG 实例
 | 
			
		||||
            if os.path.exists(lightrag_working_dir) and os.listdir(lightrag_working_dir):
 | 
			
		||||
                print("✅ Found existing LightRAG instance, loading...")
 | 
			
		||||
            else:
 | 
			
		||||
                print("❌ No existing LightRAG instance found, will create new one")
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
            # 使用您的配置创建/加载 LightRAG 实例
 | 
			
		||||
            lightrag_instance = LightRAG(
 | 
			
		||||
                working_dir=lightrag_working_dir,
 | 
			
		||||
@ -1199,10 +1199,10 @@ LightRAG 现已与 [RAG-Anything](https://github.com/HKUDS/RAG-Anything) 实现
 | 
			
		||||
                    ),
 | 
			
		||||
                )
 | 
			
		||||
            )
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
            # 初始化存储(如果有现有数据,这将加载现有数据)
 | 
			
		||||
            await lightrag_instance.initialize_storages()
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
            # 现在使用现有的 LightRAG 实例初始化 RAGAnything
 | 
			
		||||
            rag = RAGAnything(
 | 
			
		||||
                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 继承
 | 
			
		||||
            )
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
            # 查询现有的知识库
 | 
			
		||||
            result = await rag.query_with_multimodal(
 | 
			
		||||
                "What data has been processed in this LightRAG instance?",
 | 
			
		||||
                mode="hybrid"
 | 
			
		||||
            )
 | 
			
		||||
            print("Query result:", result)
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
            # 向现有的 LightRAG 实例添加新的多模态文档
 | 
			
		||||
            await rag.process_document_complete(
 | 
			
		||||
                file_path="path/to/new/multimodal_document.pdf",
 | 
			
		||||
                output_dir="./output"
 | 
			
		||||
            )
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
        if __name__ == "__main__":
 | 
			
		||||
            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_node_id_gin_idx ON dickens."Entity" using gin(properties);
 | 
			
		||||
  ALTER TABLE dickens."DIRECTED" CLUSTER ON directed_sid_idx;
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  -- drop if necessary
 | 
			
		||||
  drop INDEX entity_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.utils import EmbeddingFunc
 | 
			
		||||
        import os
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
        async def load_existing_lightrag():
 | 
			
		||||
            # First, create or load an existing LightRAG instance
 | 
			
		||||
            lightrag_working_dir = "./existing_lightrag_storage"
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
            # Check if previous LightRAG instance exists
 | 
			
		||||
            if os.path.exists(lightrag_working_dir) and os.listdir(lightrag_working_dir):
 | 
			
		||||
                print("✅ Found existing LightRAG instance, loading...")
 | 
			
		||||
            else:
 | 
			
		||||
                print("❌ No existing LightRAG instance found, will create new one")
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
            # Create/Load LightRAG instance with your configurations
 | 
			
		||||
            lightrag_instance = LightRAG(
 | 
			
		||||
                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)
 | 
			
		||||
            await lightrag_instance.initialize_storages()
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
            # Now initialize RAGAnything with the existing LightRAG instance
 | 
			
		||||
            rag = RAGAnything(
 | 
			
		||||
                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
 | 
			
		||||
            )
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
            # Query the existing knowledge base
 | 
			
		||||
            result = await rag.query_with_multimodal(
 | 
			
		||||
                "What data has been processed in this LightRAG instance?",
 | 
			
		||||
                mode="hybrid"
 | 
			
		||||
            )
 | 
			
		||||
            print("Query result:", result)
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
            # Add new multimodal documents to the existing LightRAG instance
 | 
			
		||||
            await rag.process_document_complete(
 | 
			
		||||
                file_path="path/to/new/multimodal_document.pdf",
 | 
			
		||||
                output_dir="./output"
 | 
			
		||||
            )
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
        if __name__ == "__main__":
 | 
			
		||||
            asyncio.run(load_existing_lightrag())
 | 
			
		||||
    ```
 | 
			
		||||
 | 
			
		||||
@ -4,9 +4,7 @@ import asyncio
 | 
			
		||||
from typing import Any, final
 | 
			
		||||
import json
 | 
			
		||||
import numpy as np
 | 
			
		||||
 | 
			
		||||
from dataclasses import dataclass
 | 
			
		||||
import pipmaster as pm
 | 
			
		||||
 | 
			
		||||
from lightrag.utils import logger, compute_mdhash_id
 | 
			
		||||
from lightrag.base import BaseVectorStorage
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user