You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.6 KiB

2 weeks ago
import asyncio
from Util.DocxUtil import get_docx_content_by_pandoc
1 week ago
from Util.LightRagUtil import configure_logging, initialize_rag
import os
2 weeks ago
7 days ago
KEMU = 'ChangChun' # JiHe,Math,SuShi,Chemistry,ShiJi,ChangChun
2 weeks ago
1 week ago
# 组装文件路径
WORKING_DIR = "./Topic/" + KEMU
7 days ago
docx_file = 'static/Txt/'
2 weeks ago
async def main():
1 week ago
# 注释掉或删除以下清理代码
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",
]
7 days ago
# 在docx_file 目录下遍历所有以KEMU开头的文件
for filename in os.listdir(docx_file):
if filename.startswith(KEMU):
file_path = os.path.join(docx_file, filename)
# 获取docx文件的内容
content = get_docx_content_by_pandoc(file_path)
1 week ago
# 删除文件
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}")
try:
# 注意默认设置使用NetworkX
rag = await initialize_rag(WORKING_DIR)
await rag.ainsert(content)
print("\nIndexing completed successfully!")
except Exception as e:
print(f"An error occurred: {e}")
finally:
await rag.finalize_storages()
2 weeks ago
if __name__ == "__main__":
1 week ago
configure_logging()
2 weeks ago
asyncio.run(main())