From ed505a4c11e066a9ae003d09a86ad1061763c18f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=A5=E6=B2=B3=E6=99=B4?= Date: Mon, 10 Mar 2025 15:51:39 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BD=BF=E7=94=A8=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E6=9B=BF=E6=8D=A2=E7=A1=AC=E7=BC=96=E7=A0=81?= =?UTF-8?q?=E7=9A=84=E9=A1=B9=E7=9B=AE=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将内存系统相关文件中硬编码的项目路径(C:/GitHub/MaiMBot)替换为动态计算的相对路径, 提高代码的可移植性和兼容性。 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- src/plugins/memory_system/draw_memory.py | 5 ++++- src/plugins/memory_system/memory_manual_build.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/plugins/memory_system/draw_memory.py b/src/plugins/memory_system/draw_memory.py index ffe2ba42..9f15164f 100644 --- a/src/plugins/memory_system/draw_memory.py +++ b/src/plugins/memory_system/draw_memory.py @@ -9,7 +9,10 @@ import networkx as nx from dotenv import load_dotenv from loguru import logger -sys.path.append("C:/GitHub/MaiMBot") # 添加项目根目录到 Python 路径 +# 添加项目根目录到 Python 路径 +root_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../..")) +sys.path.append(root_path) + from src.common.database import Database # 使用正确的导入语法 # 加载.env.dev文件 diff --git a/src/plugins/memory_system/memory_manual_build.py b/src/plugins/memory_system/memory_manual_build.py index 3a2961b6..9c1d43ce 100644 --- a/src/plugins/memory_system/memory_manual_build.py +++ b/src/plugins/memory_system/memory_manual_build.py @@ -16,7 +16,10 @@ from loguru import logger import jieba # from chat.config import global_config -sys.path.append("C:/GitHub/MaiMBot") # 添加项目根目录到 Python 路径 +# 添加项目根目录到 Python 路径 +root_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../..")) +sys.path.append(root_path) + from src.common.database import Database from src.plugins.memory_system.offline_llm import LLMModel