Spaces:
Build error
Build error
Update graphrag_agent.py
Browse files- graphrag_agent.py +29 -14
graphrag_agent.py
CHANGED
|
@@ -698,22 +698,37 @@ def whether_to_interact(state):
|
|
| 698 |
else:
|
| 699 |
return "stop_flow"
|
| 700 |
|
| 701 |
-
#
|
| 702 |
-
|
| 703 |
-
|
| 704 |
-
|
| 705 |
-
|
| 706 |
-
|
| 707 |
-
|
| 708 |
-
|
| 709 |
-
|
| 710 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 711 |
|
| 712 |
-
|
| 713 |
-
|
| 714 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 715 |
|
| 716 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 717 |
|
| 718 |
def neo4j_retrieval(state: MyState):
|
| 719 |
logger.info("---NODE: neo4j_retrieval---")
|
|
|
|
| 698 |
else:
|
| 699 |
return "stop_flow"
|
| 700 |
|
| 701 |
+
# 数据存放路径
|
| 702 |
+
DATA_DIR = "data"
|
| 703 |
+
ZIP_FILE = "data.zip"
|
| 704 |
+
|
| 705 |
+
# ✅ 如果 data/ 已存在且非空,就跳过下载
|
| 706 |
+
if os.path.exists(DATA_DIR) and any(os.scandir(DATA_DIR)):
|
| 707 |
+
print("✅ 已检测到本地 data 文件夹,跳过下载。")
|
| 708 |
+
|
| 709 |
+
else:
|
| 710 |
+
# 如果没有解压好的 data,但有 data.zip,则直接解压
|
| 711 |
+
if os.path.exists(ZIP_FILE):
|
| 712 |
+
print("📦 检测到本地 data.zip,正在解压...")
|
| 713 |
+
with ZipFile(ZIP_FILE, "r") as zip_ref:
|
| 714 |
+
zip_ref.extractall(DATA_DIR)
|
| 715 |
+
print("✅ 已成功解压本地 data.zip")
|
| 716 |
|
| 717 |
+
else:
|
| 718 |
+
# 如果连 data.zip 都没有,才从 HF 下载
|
| 719 |
+
print("🌐 未检测到本地数据,开始从 Hugging Face 下载 data.zip...")
|
| 720 |
+
zip_path = hf_hub_download(
|
| 721 |
+
repo_id="achenyx1412/DGADIS",
|
| 722 |
+
filename="data.zip",
|
| 723 |
+
repo_type="dataset",
|
| 724 |
+
token=HF_TOKEN
|
| 725 |
+
)
|
| 726 |
|
| 727 |
+
# 解压
|
| 728 |
+
print("📦 正在解压 data.zip...")
|
| 729 |
+
with ZipFile(zip_path, "r") as zip_ref:
|
| 730 |
+
zip_ref.extractall(DATA_DIR)
|
| 731 |
+
print("✅ 已成功下载并解压 data.zip")
|
| 732 |
|
| 733 |
def neo4j_retrieval(state: MyState):
|
| 734 |
logger.info("---NODE: neo4j_retrieval---")
|