From 502f509630e4f073ff6b8d3db582d34cc2cd3ba3 Mon Sep 17 00:00:00 2001 From: SengokuCola <1026294844@qq.com> Date: Fri, 2 May 2025 19:15:15 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E5=A4=8Drelationship?= =?UTF-8?q?=E5=8A=A0=E9=94=99=E4=BA=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/chat/message_sender.py | 6 +++--- src/plugins/heartFC_chat/normal_chat.py | 5 ++++- src/plugins/person_info/relationship_manager.py | 15 +++++++-------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/plugins/chat/message_sender.py b/src/plugins/chat/message_sender.py index 61e2dd49c..c50c7aad3 100644 --- a/src/plugins/chat/message_sender.py +++ b/src/plugins/chat/message_sender.py @@ -216,9 +216,9 @@ class MessageManager: # print(f"message.reply:{message.reply}") # --- 条件应用 set_reply 逻辑 --- - logger.debug( - f"[message.apply_set_reply_logic:{message.apply_set_reply_logic},message.is_head:{message.is_head},thinking_messages_count:{thinking_messages_count},thinking_messages_length:{thinking_messages_length},message.is_private_message():{message.is_private_message()}]" - ) + # logger.debug( + # f"[message.apply_set_reply_logic:{message.apply_set_reply_logic},message.is_head:{message.is_head},thinking_messages_count:{thinking_messages_count},thinking_messages_length:{thinking_messages_length},message.is_private_message():{message.is_private_message()}]" + # ) if ( message.apply_set_reply_logic # 检查标记 and message.is_head diff --git a/src/plugins/heartFC_chat/normal_chat.py b/src/plugins/heartFC_chat/normal_chat.py index 70568f835..1c1372c52 100644 --- a/src/plugins/heartFC_chat/normal_chat.py +++ b/src/plugins/heartFC_chat/normal_chat.py @@ -178,8 +178,11 @@ class NormalChat: """更新关系情绪""" ori_response = ",".join(response_set) stance, emotion = await self.gpt._get_emotion_tags(ori_response, message.processed_plain_text) + user_info = message.message_info.user_info + platform = user_info.platform await relationship_manager.calculate_update_relationship_value( - chat_stream=self.chat_stream, + user_info, + platform, label=emotion, stance=stance, # 使用 self.chat_stream ) diff --git a/src/plugins/person_info/relationship_manager.py b/src/plugins/person_info/relationship_manager.py index fc8cf548e..3c264b054 100644 --- a/src/plugins/person_info/relationship_manager.py +++ b/src/plugins/person_info/relationship_manager.py @@ -5,6 +5,7 @@ from bson.decimal128 import Decimal128 from .person_info import person_info_manager import time import random +from maim_message import UserInfo, Seg # import re # import traceback @@ -102,7 +103,7 @@ class RelationshipManager: # await person_info_manager.update_one_field(person_id, "user_avatar", user_avatar) await person_info_manager.qv_person_name(person_id, user_nickname, user_cardname, user_avatar) - async def calculate_update_relationship_value(self, chat_stream: ChatStream, label: str, stance: str) -> tuple: + async def calculate_update_relationship_value(self, user_info: UserInfo, platform: str, label: str, stance: str): """计算并变更关系值 新的关系值变更计算方式: 将关系值限定在-1000到1000 @@ -134,11 +135,11 @@ class RelationshipManager: "困惑": 0.5, } - person_id = person_info_manager.get_person_id(chat_stream.user_info.platform, chat_stream.user_info.user_id) + person_id = person_info_manager.get_person_id(platform, user_info.user_id) data = { - "platform": chat_stream.user_info.platform, - "user_id": chat_stream.user_info.user_id, - "nickname": chat_stream.user_info.user_nickname, + "platform": platform, + "user_id": user_info.user_id, + "nickname": user_info.user_nickname, "konw_time": int(time.time()), } old_value = await person_info_manager.get_value(person_id, "relationship_value") @@ -178,7 +179,7 @@ class RelationshipManager: level_num = self.calculate_level_num(old_value + value) relationship_level = ["厌恶", "冷漠", "一般", "友好", "喜欢", "暧昧"] logger.info( - f"用户: {chat_stream.user_info.user_nickname}" + f"用户: {user_info.user_nickname}" f"当前关系: {relationship_level[level_num]}, " f"关系值: {old_value:.2f}, " f"当前立场情感: {stance}-{label}, " @@ -187,8 +188,6 @@ class RelationshipManager: await person_info_manager.update_one_field(person_id, "relationship_value", old_value + value, data) - return chat_stream.user_info.user_nickname, value, relationship_level[level_num] - async def calculate_update_relationship_value_with_reason( self, chat_stream: ChatStream, label: str, stance: str, reason: str ) -> tuple: From a859f9238fa0df18023317276dcce3c1f0d1da23 Mon Sep 17 00:00:00 2001 From: SengokuCola <1026294844@qq.com> Date: Fri, 2 May 2025 19:17:59 +0800 Subject: [PATCH 2/3] =?UTF-8?q?better=EF=BC=9A=E4=BC=98=E5=8C=96=E5=8F=AF?= =?UTF-8?q?=E8=AF=BB=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ![新版麦麦开始学习.bat | 65 +++++++++++++++++++++++--------- scripts/info_extraction.py | 4 +- scripts/raw_data_preprocessor.py | 2 +- 3 files changed, 51 insertions(+), 20 deletions(-) diff --git a/![新版麦麦开始学习.bat b/![新版麦麦开始学习.bat index 41fc98368..b95bad004 100644 --- a/![新版麦麦开始学习.bat +++ b/![新版麦麦开始学习.bat @@ -2,26 +2,57 @@ CHCP 65001 > nul setlocal enabledelayedexpansion -REM 查找venv虚拟环境 -set "venv_path=%~dp0venv\Scripts\activate.bat" -if not exist "%venv_path%" ( - echo 错误: 未找到虚拟环境,请确保venv目录存在 - pause - exit /b 1 +echo 你需要选择启动方式,输入字母来选择: +echo V = 不知道什么意思就输入 V +echo C = 输入 C 使用 Conda 环境 +echo. +choice /C CV /N /M "在下方输入字母并回车 (C/V)?" /T 10 /D V + +set "ENV_TYPE=" +if %ERRORLEVEL% == 1 set "ENV_TYPE=CONDA" +if %ERRORLEVEL% == 2 set "ENV_TYPE=VENV" + +if "%ENV_TYPE%" == "CONDA" ( + set /p CONDA_ENV_NAME="请输入要使用的 Conda 环境名称: " + if not defined CONDA_ENV_NAME ( + echo 错误: 未输入 Conda 环境名称. + pause + exit /b 1 + ) + echo 选择: Conda '%CONDA_ENV_NAME%' + REM 激活Conda环境 + call conda activate %CONDA_ENV_NAME% + if %ERRORLEVEL% neq 0 ( + echo 错误: Conda环境 '%CONDA_ENV_NAME%' 激活失败. 请确保Conda已安装并正确配置, 且 '%CONDA_ENV_NAME%' 环境存在. + pause + exit /b 1 + ) +) else ( + echo Selected: venv (default) + REM 查找venv虚拟环境 + set "venv_path=%~dp0venv\Scripts\activate.bat" + if not exist "%venv_path%" ( + echo Error: venv not found. Ensure the venv directory exists alongside the script. + pause + exit /b 1 + ) + REM 激活虚拟环境 + call "%venv_path%" + if %ERRORLEVEL% neq 0 ( + echo Error: Failed to activate venv virtual environment. + pause + exit /b 1 + ) ) -REM 激活虚拟环境 -call "%venv_path%" -if %ERRORLEVEL% neq 0 ( - echo 错误: 虚拟环境激活失败 - pause - exit /b 1 -) +echo Environment activated successfully! + +REM --- 后续脚本执行 --- REM 运行预处理脚本 python "%~dp0scripts\raw_data_preprocessor.py" if %ERRORLEVEL% neq 0 ( - echo 错误: raw_data_preprocessor.py 执行失败 + echo Error: raw_data_preprocessor.py execution failed. pause exit /b 1 ) @@ -29,7 +60,7 @@ if %ERRORLEVEL% neq 0 ( REM 运行信息提取脚本 python "%~dp0scripts\info_extraction.py" if %ERRORLEVEL% neq 0 ( - echo 错误: info_extraction.py 执行失败 + echo Error: info_extraction.py execution failed. pause exit /b 1 ) @@ -37,10 +68,10 @@ if %ERRORLEVEL% neq 0 ( REM 运行OpenIE导入脚本 python "%~dp0scripts\import_openie.py" if %ERRORLEVEL% neq 0 ( - echo 错误: import_openie.py 执行失败 + echo Error: import_openie.py execution failed. pause exit /b 1 ) -echo 所有处理步骤完成! +echo All processing steps completed! pause \ No newline at end of file diff --git a/scripts/info_extraction.py b/scripts/info_extraction.py index 65c4082b6..9e079070b 100644 --- a/scripts/info_extraction.py +++ b/scripts/info_extraction.py @@ -87,8 +87,8 @@ def main(): signal.signal(signal.SIGINT, signal_handler) # 新增用户确认提示 - print("=== 重要操作确认 ===") - print("实体提取操作将会花费较多资金和时间,建议在空闲时段执行。") + print("=== 重要操作确认,请认真阅读以下内容哦 ===") + print("实体提取操作将会花费较多api余额和时间,建议在空闲时段执行。") print("举例:600万字全剧情,提取选用deepseek v3 0324,消耗约40元,约3小时。") print("建议使用硅基流动的非Pro模型") print("或者使用可以用赠金抵扣的Pro模型") diff --git a/scripts/raw_data_preprocessor.py b/scripts/raw_data_preprocessor.py index 2fc30352e..33d51153f 100644 --- a/scripts/raw_data_preprocessor.py +++ b/scripts/raw_data_preprocessor.py @@ -44,7 +44,7 @@ def process_text_file(file_path): def main(): # 新增用户确认提示 - print("=== 重要操作确认 ===") + print("=== 重要操作确认,请认真阅读以下内容哦 ===") print("如果你并非第一次导入知识") print("请先删除data/import.json文件,备份data/openie.json文件") print("在进行知识库导入之前") From 021ac90ead332195eb69d2cf98e556a6bcc7c3a3 Mon Sep 17 00:00:00 2001 From: SengokuCola <1026294844@qq.com> Date: Fri, 2 May 2025 19:46:04 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E6=94=B9bat=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ![新版麦麦开始学习.bat | 29 ++++++++++++++++++++--------- scripts/raw_data_preprocessor.py | 9 ++++----- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/![新版麦麦开始学习.bat b/![新版麦麦开始学习.bat index b95bad004..eacaa2eb1 100644 --- a/![新版麦麦开始学习.bat +++ b/![新版麦麦开始学习.bat @@ -6,29 +6,39 @@ echo 你需要选择启动方式,输入字母来选择: echo V = 不知道什么意思就输入 V echo C = 输入 C 使用 Conda 环境 echo. -choice /C CV /N /M "在下方输入字母并回车 (C/V)?" /T 10 /D V +choice /C CV /N /M "不知道什么意思就输入 V (C/V)?" /T 10 /D V set "ENV_TYPE=" if %ERRORLEVEL% == 1 set "ENV_TYPE=CONDA" if %ERRORLEVEL% == 2 set "ENV_TYPE=VENV" -if "%ENV_TYPE%" == "CONDA" ( +if "%ENV_TYPE%" == "CONDA" goto activate_conda +if "%ENV_TYPE%" == "VENV" goto activate_venv + +REM 如果 choice 超时或返回意外值,默认使用 venv +echo WARN: Invalid selection or timeout from choice. Defaulting to VENV. +set "ENV_TYPE=VENV" +goto activate_venv + +:activate_conda set /p CONDA_ENV_NAME="请输入要使用的 Conda 环境名称: " if not defined CONDA_ENV_NAME ( echo 错误: 未输入 Conda 环境名称. pause exit /b 1 ) - echo 选择: Conda '%CONDA_ENV_NAME%' + echo 选择: Conda '!CONDA_ENV_NAME!' REM 激活Conda环境 - call conda activate %CONDA_ENV_NAME% - if %ERRORLEVEL% neq 0 ( - echo 错误: Conda环境 '%CONDA_ENV_NAME%' 激活失败. 请确保Conda已安装并正确配置, 且 '%CONDA_ENV_NAME%' 环境存在. + call conda activate !CONDA_ENV_NAME! + if !ERRORLEVEL! neq 0 ( + echo 错误: Conda环境 '!CONDA_ENV_NAME!' 激活失败. 请确保Conda已安装并正确配置, 且 '!CONDA_ENV_NAME!' 环境存在. pause exit /b 1 ) -) else ( - echo Selected: venv (default) + goto env_activated + +:activate_venv + echo Selected: venv (default or selected) REM 查找venv虚拟环境 set "venv_path=%~dp0venv\Scripts\activate.bat" if not exist "%venv_path%" ( @@ -43,8 +53,9 @@ if "%ENV_TYPE%" == "CONDA" ( pause exit /b 1 ) -) + goto env_activated +:env_activated echo Environment activated successfully! REM --- 后续脚本执行 --- diff --git a/scripts/raw_data_preprocessor.py b/scripts/raw_data_preprocessor.py index 056cf5725..c87c30ca8 100644 --- a/scripts/raw_data_preprocessor.py +++ b/scripts/raw_data_preprocessor.py @@ -48,11 +48,10 @@ def process_text_file(file_path): def main(): # 新增用户确认提示 - print("=== 重要操作确认,请认真阅读以下内容哦 ===") - print("如果你并非第一次导入知识") - print("请先删除data/import.json文件,备份data/openie.json文件") - print("在进行知识库导入之前") - print("请修改config/lpmm_config.toml中的配置项") + print("=== 数据预处理脚本 ===") + print(f"本脚本将处理 '{RAW_DATA_PATH}' 目录下的所有 .txt 文件。") + print(f"处理后的段落数据将合并,并以 MM-DD-HH-SS-imported-data.json 的格式保存在 '{IMPORTED_DATA_PATH}' 目录中。") + print("请确保原始数据已放置在正确的目录中。") confirm = input("确认继续执行?(y/n): ").strip().lower() if confirm != "y": logger.error("操作已取消")