|  | import os | 
					
						
						|  | from lightrag import LightRAG, QueryParam | 
					
						
						|  | from lightrag.llm import gpt_4o_mini_complete | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | WORKING_DIR = "./local_neo4jWorkDir" | 
					
						
						|  |  | 
					
						
						|  | if not os.path.exists(WORKING_DIR): | 
					
						
						|  | os.mkdir(WORKING_DIR) | 
					
						
						|  |  | 
					
						
						|  | rag = LightRAG( | 
					
						
						|  | working_dir=WORKING_DIR, | 
					
						
						|  | llm_model_func=gpt_4o_mini_complete, | 
					
						
						|  | graph_storage="Neo4JStorage", | 
					
						
						|  | log_level="INFO", | 
					
						
						|  |  | 
					
						
						|  | ) | 
					
						
						|  |  | 
					
						
						|  | with open("./book.txt") as f: | 
					
						
						|  | rag.insert(f.read()) | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | print( | 
					
						
						|  | rag.query("What are the top themes in this story?", param=QueryParam(mode="naive")) | 
					
						
						|  | ) | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | print( | 
					
						
						|  | rag.query("What are the top themes in this story?", param=QueryParam(mode="local")) | 
					
						
						|  | ) | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | print( | 
					
						
						|  | rag.query("What are the top themes in this story?", param=QueryParam(mode="global")) | 
					
						
						|  | ) | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | print( | 
					
						
						|  | rag.query("What are the top themes in this story?", param=QueryParam(mode="hybrid")) | 
					
						
						|  | ) | 
					
						
						|  |  |