|
|
@@ -419,7 +419,7 @@ if __name__ == "__main__":
|
|
|
ensure_collection(client, CHILD_COLLECTION_NAME, dense_dim=dense_dim)
|
|
|
|
|
|
if not os.path.exists(ROOT_DIR):
|
|
|
- print(f"❌ 目录不存在:{ROOT_DIR}")
|
|
|
+ logger.error("目录不存在:%s", ROOT_DIR)
|
|
|
else:
|
|
|
for folder_name in os.listdir(ROOT_DIR):
|
|
|
folder_path = os.path.join(ROOT_DIR, folder_name)
|
|
|
@@ -432,7 +432,7 @@ if __name__ == "__main__":
|
|
|
|
|
|
md_path = os.path.join(folder_path, file_name)
|
|
|
try:
|
|
|
- print(f"\n📄 正在处理:{md_path}")
|
|
|
+ logger.info("正在处理:%s", md_path)
|
|
|
|
|
|
with open(md_path, "r", encoding="utf-8") as f:
|
|
|
text = f.read()
|
|
|
@@ -449,9 +449,8 @@ if __name__ == "__main__":
|
|
|
insert_docs(client, emb, parent_docs, PARENT_COLLECTION_NAME)
|
|
|
insert_docs(client, emb, child_docs, CHILD_COLLECTION_NAME)
|
|
|
|
|
|
- print(f"✅ 父表写入:parents={len(parent_docs)} -> {PARENT_COLLECTION_NAME}")
|
|
|
- print(f"✅ 子表写入:children={len(child_docs)} -> {CHILD_COLLECTION_NAME}")
|
|
|
+ logger.info("父表写入:parents=%s -> %s", len(parent_docs), PARENT_COLLECTION_NAME)
|
|
|
+ logger.info("子表写入:children=%s -> %s", len(child_docs), CHILD_COLLECTION_NAME)
|
|
|
|
|
|
except Exception as e:
|
|
|
- print(f"❌ 处理失败:{md_path}")
|
|
|
- print(e)
|
|
|
+ logger.exception("处理失败:%s", md_path)
|