import asyncio from Util.LightRagUtil import configure_logging, initialize_rag async def main(): # 注释掉或删除以下清理代码 # files_to_delete = [ # "graph_chunk_entity_relation.graphml", # "kv_store_doc_status.json", # "kv_store_full_docs.json", # "kv_store_text_chunks.json", # "vdb_chunks.json", # "vdb_entities.json", # "vdb_relationships.json", # ] # for file in files_to_delete: # file_path = os.path.join(WORKING_DIR, file) # if os.path.exists(file_path): # os.remove(file_path) # print(f"Deleting old file:: {file_path}") # 数学 WORKING_DIR = "./Topic/Math" TXT_FILE = "小学数学教学中的若干问题.txt" # 苏轼 # WORKING_DIR = "./Topic/Chinese" # TXT_FILE = "sushi.txt" try: rag = await initialize_rag(WORKING_DIR) with open("../Txt/" + TXT_FILE, "r", encoding="utf-8") as f: await rag.ainsert(f.read()) print("\nIndexing completed successfully!") except Exception as e: print(f"An error occurred: {e}") finally: if rag: await rag.finalize_storages() if __name__ == "__main__": configure_logging() asyncio.run(main())