From d9a66ee7cb415efbab54651720f1fe94326c2b45 Mon Sep 17 00:00:00 2001 From: infinitycat Date: Wed, 30 Apr 2025 11:13:23 +0800 Subject: [PATCH 1/9] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9Elpmm=E7=9A=84Linu?= =?UTF-8?q?x=E5=BF=AB=E6=8D=B7=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/run_lpmm.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 scripts/run_lpmm.sh diff --git a/scripts/run_lpmm.sh b/scripts/run_lpmm.sh new file mode 100644 index 00000000..05435365 --- /dev/null +++ b/scripts/run_lpmm.sh @@ -0,0 +1,43 @@ +#!/bin/sh + +# Step 1: 自动定位项目根目录(即 scripts 目录的上级目录) +SCRIPTS_DIR="scripts" +SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd) +PROJECT_ROOT=$(cd "$SCRIPT_DIR/.." && pwd) + +# Step 2: 检查 scripts 目录是否存在 +if [ ! -d "$PROJECT_ROOT/$SCRIPTS_DIR" ]; then + echo "❌ 错误:项目根目录中找不到 scripts 目录" >&2 + echo "当前路径: $SCRIPT_DIR" >&2 + exit 1 +fi + +# Step 3: 切换到项目根目录 +cd "$PROJECT_ROOT" || { + echo "❌ 无法切换到项目根目录: $PROJECT_ROOT" >&2 + exit 1 +} + +# Step 4: 运行每个 Python 脚本并检查退出状态 +echo "🔄 正在运行 text_pre_process.py" +python3 scripts/text_pre_process.py +if [ $? -ne 0 ]; then + echo "❌ text_pre_process.py 执行失败" >&2 + exit 1 +fi + +echo "🔄 正在运行 info_extraction.py" +python3 scripts/info_extraction.py +if [ $? -ne 0 ]; then + echo "❌ info_extraction.py 执行失败" >&2 + exit 1 +fi + +echo "🔄 正在运行 import_openie.py" +python3 scripts/import_openie.py +if [ $? -ne 0 ]; then + echo "❌ import_openie.py 执行失败" >&2 + exit 1 +fi + +echo "✅ 所有脚本执行完成" \ No newline at end of file From 2dac54c30692ba5dd3c5f74863a3614112bf1264 Mon Sep 17 00:00:00 2001 From: infinitycat Date: Wed, 30 Apr 2025 15:09:34 +0800 Subject: [PATCH 2/9] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/run_lpmm.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/run_lpmm.sh b/scripts/run_lpmm.sh index 05435365..15df0d7b 100644 --- a/scripts/run_lpmm.sh +++ b/scripts/run_lpmm.sh @@ -19,10 +19,10 @@ cd "$PROJECT_ROOT" || { } # Step 4: 运行每个 Python 脚本并检查退出状态 -echo "🔄 正在运行 text_pre_process.py" -python3 scripts/text_pre_process.py +echo "🔄 正在运行 raw_data_preprocessor.py" +python3 scripts/raw_data_preprocessor.py if [ $? -ne 0 ]; then - echo "❌ text_pre_process.py 执行失败" >&2 + echo "❌ raw_data_preprocessor.py 执行失败" >&2 exit 1 fi From 6f41d39d7220a8152b0473abee3c06898e8686b2 Mon Sep 17 00:00:00 2001 From: infinitycat Date: Wed, 30 Apr 2025 16:09:00 +0800 Subject: [PATCH 3/9] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96lpmm=E8=84=9A?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/run_lpmm.sh | 51 ++++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/scripts/run_lpmm.sh b/scripts/run_lpmm.sh index 15df0d7b..33eb7284 100644 --- a/scripts/run_lpmm.sh +++ b/scripts/run_lpmm.sh @@ -1,5 +1,9 @@ #!/bin/sh +# ============================================== +# 环境初始化:确保Python脚本在正确的目录下运行 +# ============================================== + # Step 1: 自动定位项目根目录(即 scripts 目录的上级目录) SCRIPTS_DIR="scripts" SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd) @@ -8,36 +12,41 @@ PROJECT_ROOT=$(cd "$SCRIPT_DIR/.." && pwd) # Step 2: 检查 scripts 目录是否存在 if [ ! -d "$PROJECT_ROOT/$SCRIPTS_DIR" ]; then echo "❌ 错误:项目根目录中找不到 scripts 目录" >&2 - echo "当前路径: $SCRIPT_DIR" >&2 + echo "当前路径: $PROJECT_ROOT" >&2 exit 1 fi -# Step 3: 切换到项目根目录 +# Step 3: 设置Python运行环境 +export PYTHONPATH="$PROJECT_ROOT:$PYTHONPATH" # 将项目根目录加入Python路径 cd "$PROJECT_ROOT" || { echo "❌ 无法切换到项目根目录: $PROJECT_ROOT" >&2 exit 1 } -# Step 4: 运行每个 Python 脚本并检查退出状态 -echo "🔄 正在运行 raw_data_preprocessor.py" -python3 scripts/raw_data_preprocessor.py -if [ $? -ne 0 ]; then - echo "❌ raw_data_preprocessor.py 执行失败" >&2 - exit 1 -fi +# Step 4: 打印关键路径信息(调试用) +echo "============================" +echo "项目根目录: $PROJECT_ROOT" +echo "Python路径: $PYTHONPATH" +echo "当前工作目录: $(pwd)" +echo "============================" -echo "🔄 正在运行 info_extraction.py" -python3 scripts/info_extraction.py -if [ $? -ne 0 ]; then - echo "❌ info_extraction.py 执行失败" >&2 - exit 1 -fi +# ============================================== +# 执行Python脚本 +# ============================================== -echo "🔄 正在运行 import_openie.py" -python3 scripts/import_openie.py -if [ $? -ne 0 ]; then - echo "❌ import_openie.py 执行失败" >&2 - exit 1 -fi +run_python_script() { + local script_name=$1 + echo "🔄 正在运行 $script_name" + python3 "scripts/$script_name" + if [ $? -ne 0 ]; then + echo "❌ $script_name 执行失败" >&2 + exit 1 + fi +} + +# 按顺序运行脚本 +run_python_script "raw_data_preprocessor.py" +run_python_script "info_extraction.py" +run_python_script "import_openie.py" echo "✅ 所有脚本执行完成" \ No newline at end of file From 16f765d86b64934415d319c41c3751fa1a304efd Mon Sep 17 00:00:00 2001 From: infinitycat Date: Wed, 30 Apr 2025 16:10:16 +0800 Subject: [PATCH 4/9] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96lpmm=E8=84=9A?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/run_lpmm.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/run_lpmm.sh b/scripts/run_lpmm.sh index 33eb7284..1671f011 100644 --- a/scripts/run_lpmm.sh +++ b/scripts/run_lpmm.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # ============================================== # 环境初始化:确保Python脚本在正确的目录下运行 From 850db4b3e76e01c11a07bc6165207736afd91717 Mon Sep 17 00:00:00 2001 From: infinitycat Date: Wed, 30 Apr 2025 16:12:27 +0800 Subject: [PATCH 5/9] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96lpmm=E8=84=9A?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/run_lpmm.sh | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/scripts/run_lpmm.sh b/scripts/run_lpmm.sh index 1671f011..23436388 100644 --- a/scripts/run_lpmm.sh +++ b/scripts/run_lpmm.sh @@ -1,52 +1,51 @@ #!/bin/bash # ============================================== -# 环境初始化:确保Python脚本在正确的目录下运行 +# Environment Initialization # ============================================== -# Step 1: 自动定位项目根目录(即 scripts 目录的上级目录) +# Step 1: Locate project root directory SCRIPTS_DIR="scripts" SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd) PROJECT_ROOT=$(cd "$SCRIPT_DIR/.." && pwd) -# Step 2: 检查 scripts 目录是否存在 +# Step 2: Verify scripts directory exists if [ ! -d "$PROJECT_ROOT/$SCRIPTS_DIR" ]; then - echo "❌ 错误:项目根目录中找不到 scripts 目录" >&2 - echo "当前路径: $PROJECT_ROOT" >&2 + echo "❌ Error: scripts directory not found in project root" >&2 + echo "Current path: $PROJECT_ROOT" >&2 exit 1 fi -# Step 3: 设置Python运行环境 -export PYTHONPATH="$PROJECT_ROOT:$PYTHONPATH" # 将项目根目录加入Python路径 +# Step 3: Set up Python environment +export PYTHONPATH="$PROJECT_ROOT:$PYTHONPATH" cd "$PROJECT_ROOT" || { - echo "❌ 无法切换到项目根目录: $PROJECT_ROOT" >&2 + echo "❌ Failed to cd to project root: $PROJECT_ROOT" >&2 exit 1 } -# Step 4: 打印关键路径信息(调试用) +# Debug info echo "============================" -echo "项目根目录: $PROJECT_ROOT" -echo "Python路径: $PYTHONPATH" -echo "当前工作目录: $(pwd)" +echo "Project Root: $PROJECT_ROOT" +echo "Python Path: $PYTHONPATH" +echo "Working Dir: $(pwd)" echo "============================" # ============================================== -# 执行Python脚本 +# Python Script Execution # ============================================== run_python_script() { local script_name=$1 - echo "🔄 正在运行 $script_name" - python3 "scripts/$script_name" - if [ $? -ne 0 ]; then - echo "❌ $script_name 执行失败" >&2 + echo "🔄 Running $script_name" + if ! python3 "scripts/$script_name"; then + echo "❌ $script_name failed" >&2 exit 1 fi } -# 按顺序运行脚本 +# Execute scripts in order run_python_script "raw_data_preprocessor.py" run_python_script "info_extraction.py" run_python_script "import_openie.py" -echo "✅ 所有脚本执行完成" \ No newline at end of file +echo "✅ All scripts completed successfully" \ No newline at end of file From 5141862cf326db44ff33a7699ca226c89b47303c Mon Sep 17 00:00:00 2001 From: infinitycat Date: Thu, 1 May 2025 01:18:00 +0800 Subject: [PATCH 6/9] =?UTF-8?q?fix:=20=E4=B8=80=E4=B8=AA=E5=B0=8F=E8=A1=A5?= =?UTF-8?q?=E4=B8=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/run_lpmm.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/run_lpmm.sh b/scripts/run_lpmm.sh index 23436388..f3f54610 100644 --- a/scripts/run_lpmm.sh +++ b/scripts/run_lpmm.sh @@ -37,7 +37,7 @@ echo "============================" run_python_script() { local script_name=$1 echo "🔄 Running $script_name" - if ! python3 "scripts/$script_name"; then + if ! python3 "$SCRIPTS_DIR/$script_name"; then echo "❌ $script_name failed" >&2 exit 1 fi From de68a6a8ee52e1757572177a6b5375dd0fb276ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=B4=E7=8C=AB?= Date: Thu, 1 May 2025 14:34:59 +0900 Subject: [PATCH 7/9] =?UTF-8?q?fix:=20=E6=9B=B4=E6=94=B9=20MessageManager?= =?UTF-8?q?=20=E7=9A=84=E5=B1=9E=E6=80=A7=E6=A3=80=E6=9F=A5=E6=96=B9?= =?UTF-8?q?=E5=BC=8F=E4=BB=A5=E9=98=B2=E6=AD=A2=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- src/plugins/chat/message_sender.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/plugins/chat/message_sender.py b/src/plugins/chat/message_sender.py index fdeec346..0f860551 100644 --- a/src/plugins/chat/message_sender.py +++ b/src/plugins/chat/message_sender.py @@ -146,6 +146,7 @@ class MessageManager: """管理所有聊天流的消息容器 (不再是单例)""" def __init__(self): + self._processor_task = None self.containers: dict[str, MessageContainer] = {} self.storage = MessageStorage() # 添加 storage 实例 self._running = True # 处理器运行状态 @@ -155,7 +156,7 @@ class MessageManager: async def start(self): """启动后台处理器任务。""" # 检查是否已有任务在运行,避免重复启动 - if hasattr(self, "_processor_task") and not self._processor_task.done(): + if self._processor_task is not None and not self._processor_task.done(): logger.warning("Processor task already running.") return self._processor_task = asyncio.create_task(self._start_processor_loop()) @@ -164,7 +165,7 @@ class MessageManager: def stop(self): """停止后台处理器任务。""" self._running = False - if hasattr(self, "_processor_task") and not self._processor_task.done(): + if self._processor_task is not None and not self._processor_task.done(): self._processor_task.cancel() logger.debug("MessageManager processor task stopping.") else: From 95a025b69949e4b3d9c9dca12266e97980f7936e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=B4=E7=8C=AB?= Date: Thu, 1 May 2025 14:36:17 +0900 Subject: [PATCH 8/9] add typing --- src/plugins/chat/message_sender.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/chat/message_sender.py b/src/plugins/chat/message_sender.py index 0f860551..ed8c5405 100644 --- a/src/plugins/chat/message_sender.py +++ b/src/plugins/chat/message_sender.py @@ -1,6 +1,7 @@ # src/plugins/chat/message_sender.py import asyncio import time +from asyncio import Task from typing import Union # from ...common.database import db # 数据库依赖似乎不需要了,注释掉 @@ -146,7 +147,7 @@ class MessageManager: """管理所有聊天流的消息容器 (不再是单例)""" def __init__(self): - self._processor_task = None + self._processor_task: Task | None = None self.containers: dict[str, MessageContainer] = {} self.storage = MessageStorage() # 添加 storage 实例 self._running = True # 处理器运行状态 From 6ff552d9210202538bc244e4af5071ed68555a9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=B4=E7=8C=AB?= Date: Thu, 1 May 2025 17:56:33 +0900 Subject: [PATCH 9/9] fix: update message sending to use global API --- src/plugins/heartFC_chat/heartFC_sender.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/heartFC_chat/heartFC_sender.py b/src/plugins/heartFC_chat/heartFC_sender.py index fc96207d..2681dcfa 100644 --- a/src/plugins/heartFC_chat/heartFC_sender.py +++ b/src/plugins/heartFC_chat/heartFC_sender.py @@ -2,6 +2,7 @@ import asyncio # 重新导入 asyncio from typing import Dict, Optional # 重新导入类型 from ..chat.message import MessageSending, MessageThinking # 只保留 MessageSending 和 MessageThinking +from ..message import global_api from ..storage.storage import MessageStorage from ..chat.utils import truncate_message from src.common.logger_manager import get_logger @@ -17,7 +18,7 @@ async def send_message(message: MessageSending) -> None: try: # 直接调用API发送消息 - await send_message(message) + await global_api.send_message(message) logger.success(f"发送消息 '{message_preview}' 成功") except Exception as e: