Merge branch 'dev' of https://github.com/MaiM-with-u/MaiBot into dev
This commit is contained in:
@@ -2,26 +2,68 @@
|
|||||||
CHCP 65001 > nul
|
CHCP 65001 > nul
|
||||||
setlocal enabledelayedexpansion
|
setlocal enabledelayedexpansion
|
||||||
|
|
||||||
REM 查找venv虚拟环境
|
echo 你需要选择启动方式,输入字母来选择:
|
||||||
set "venv_path=%~dp0venv\Scripts\activate.bat"
|
echo V = 不知道什么意思就输入 V
|
||||||
if not exist "%venv_path%" (
|
echo C = 输入 C 使用 Conda 环境
|
||||||
echo 错误: 未找到虚拟环境,请确保venv目录存在
|
echo.
|
||||||
pause
|
choice /C CV /N /M "不知道什么意思就输入 V (C/V)?" /T 10 /D V
|
||||||
exit /b 1
|
|
||||||
)
|
|
||||||
|
|
||||||
REM 激活虚拟环境
|
set "ENV_TYPE="
|
||||||
call "%venv_path%"
|
if %ERRORLEVEL% == 1 set "ENV_TYPE=CONDA"
|
||||||
if %ERRORLEVEL% neq 0 (
|
if %ERRORLEVEL% == 2 set "ENV_TYPE=VENV"
|
||||||
echo 错误: 虚拟环境激活失败
|
|
||||||
pause
|
if "%ENV_TYPE%" == "CONDA" goto activate_conda
|
||||||
exit /b 1
|
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!'
|
||||||
|
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
|
||||||
|
)
|
||||||
|
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%" (
|
||||||
|
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
|
||||||
|
)
|
||||||
|
goto env_activated
|
||||||
|
|
||||||
|
:env_activated
|
||||||
|
echo Environment activated successfully!
|
||||||
|
|
||||||
|
REM --- 后续脚本执行 ---
|
||||||
|
|
||||||
REM 运行预处理脚本
|
REM 运行预处理脚本
|
||||||
python "%~dp0scripts\raw_data_preprocessor.py"
|
python "%~dp0scripts\raw_data_preprocessor.py"
|
||||||
if %ERRORLEVEL% neq 0 (
|
if %ERRORLEVEL% neq 0 (
|
||||||
echo 错误: raw_data_preprocessor.py 执行失败
|
echo Error: raw_data_preprocessor.py execution failed.
|
||||||
pause
|
pause
|
||||||
exit /b 1
|
exit /b 1
|
||||||
)
|
)
|
||||||
@@ -29,7 +71,7 @@ if %ERRORLEVEL% neq 0 (
|
|||||||
REM 运行信息提取脚本
|
REM 运行信息提取脚本
|
||||||
python "%~dp0scripts\info_extraction.py"
|
python "%~dp0scripts\info_extraction.py"
|
||||||
if %ERRORLEVEL% neq 0 (
|
if %ERRORLEVEL% neq 0 (
|
||||||
echo 错误: info_extraction.py 执行失败
|
echo Error: info_extraction.py execution failed.
|
||||||
pause
|
pause
|
||||||
exit /b 1
|
exit /b 1
|
||||||
)
|
)
|
||||||
@@ -37,10 +79,10 @@ if %ERRORLEVEL% neq 0 (
|
|||||||
REM 运行OpenIE导入脚本
|
REM 运行OpenIE导入脚本
|
||||||
python "%~dp0scripts\import_openie.py"
|
python "%~dp0scripts\import_openie.py"
|
||||||
if %ERRORLEVEL% neq 0 (
|
if %ERRORLEVEL% neq 0 (
|
||||||
echo 错误: import_openie.py 执行失败
|
echo Error: import_openie.py execution failed.
|
||||||
pause
|
pause
|
||||||
exit /b 1
|
exit /b 1
|
||||||
)
|
)
|
||||||
|
|
||||||
echo 所有处理步骤完成!
|
echo All processing steps completed!
|
||||||
pause
|
pause
|
||||||
@@ -109,8 +109,8 @@ def main():
|
|||||||
signal.signal(signal.SIGINT, signal_handler)
|
signal.signal(signal.SIGINT, signal_handler)
|
||||||
|
|
||||||
# 新增用户确认提示
|
# 新增用户确认提示
|
||||||
print("=== 重要操作确认 ===")
|
print("=== 重要操作确认,请认真阅读以下内容哦 ===")
|
||||||
print("实体提取操作将会花费较多资金和时间,建议在空闲时段执行。")
|
print("实体提取操作将会花费较多api余额和时间,建议在空闲时段执行。")
|
||||||
print("举例:600万字全剧情,提取选用deepseek v3 0324,消耗约40元,约3小时。")
|
print("举例:600万字全剧情,提取选用deepseek v3 0324,消耗约40元,约3小时。")
|
||||||
print("建议使用硅基流动的非Pro模型")
|
print("建议使用硅基流动的非Pro模型")
|
||||||
print("或者使用可以用赠金抵扣的Pro模型")
|
print("或者使用可以用赠金抵扣的Pro模型")
|
||||||
|
|||||||
@@ -48,11 +48,10 @@ def process_text_file(file_path):
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
# 新增用户确认提示
|
# 新增用户确认提示
|
||||||
print("=== 重要操作确认 ===")
|
print("=== 数据预处理脚本 ===")
|
||||||
print("如果你并非第一次导入知识")
|
print(f"本脚本将处理 '{RAW_DATA_PATH}' 目录下的所有 .txt 文件。")
|
||||||
print("请先删除data/import.json文件,备份data/openie.json文件")
|
print(f"处理后的段落数据将合并,并以 MM-DD-HH-SS-imported-data.json 的格式保存在 '{IMPORTED_DATA_PATH}' 目录中。")
|
||||||
print("在进行知识库导入之前")
|
print("请确保原始数据已放置在正确的目录中。")
|
||||||
print("请修改config/lpmm_config.toml中的配置项")
|
|
||||||
confirm = input("确认继续执行?(y/n): ").strip().lower()
|
confirm = input("确认继续执行?(y/n): ").strip().lower()
|
||||||
if confirm != "y":
|
if confirm != "y":
|
||||||
logger.error("操作已取消")
|
logger.error("操作已取消")
|
||||||
|
|||||||
@@ -219,9 +219,9 @@ class MessageManager:
|
|||||||
# print(f"message.reply:{message.reply}")
|
# print(f"message.reply:{message.reply}")
|
||||||
|
|
||||||
# --- 条件应用 set_reply 逻辑 ---
|
# --- 条件应用 set_reply 逻辑 ---
|
||||||
logger.debug(
|
# 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()}]"
|
# 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 (
|
if (
|
||||||
message.apply_set_reply_logic # 检查标记
|
message.apply_set_reply_logic # 检查标记
|
||||||
and message.is_head
|
and message.is_head
|
||||||
|
|||||||
@@ -178,8 +178,11 @@ class NormalChat:
|
|||||||
"""更新关系情绪"""
|
"""更新关系情绪"""
|
||||||
ori_response = ",".join(response_set)
|
ori_response = ",".join(response_set)
|
||||||
stance, emotion = await self.gpt._get_emotion_tags(ori_response, message.processed_plain_text)
|
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(
|
await relationship_manager.calculate_update_relationship_value(
|
||||||
chat_stream=self.chat_stream,
|
user_info,
|
||||||
|
platform,
|
||||||
label=emotion,
|
label=emotion,
|
||||||
stance=stance, # 使用 self.chat_stream
|
stance=stance, # 使用 self.chat_stream
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ from bson.decimal128 import Decimal128
|
|||||||
from .person_info import person_info_manager
|
from .person_info import person_info_manager
|
||||||
import time
|
import time
|
||||||
import random
|
import random
|
||||||
|
from maim_message import UserInfo, Seg
|
||||||
# import re
|
# import re
|
||||||
# import traceback
|
# 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.update_one_field(person_id, "user_avatar", user_avatar)
|
||||||
await person_info_manager.qv_person_name(person_id, user_nickname, user_cardname, 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
|
将关系值限定在-1000到1000
|
||||||
@@ -134,11 +135,11 @@ class RelationshipManager:
|
|||||||
"困惑": 0.5,
|
"困惑": 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 = {
|
data = {
|
||||||
"platform": chat_stream.user_info.platform,
|
"platform": platform,
|
||||||
"user_id": chat_stream.user_info.user_id,
|
"user_id": user_info.user_id,
|
||||||
"nickname": chat_stream.user_info.user_nickname,
|
"nickname": user_info.user_nickname,
|
||||||
"konw_time": int(time.time()),
|
"konw_time": int(time.time()),
|
||||||
}
|
}
|
||||||
old_value = await person_info_manager.get_value(person_id, "relationship_value")
|
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)
|
level_num = self.calculate_level_num(old_value + value)
|
||||||
relationship_level = ["厌恶", "冷漠", "一般", "友好", "喜欢", "暧昧"]
|
relationship_level = ["厌恶", "冷漠", "一般", "友好", "喜欢", "暧昧"]
|
||||||
logger.info(
|
logger.info(
|
||||||
f"用户: {chat_stream.user_info.user_nickname}"
|
f"用户: {user_info.user_nickname}"
|
||||||
f"当前关系: {relationship_level[level_num]}, "
|
f"当前关系: {relationship_level[level_num]}, "
|
||||||
f"关系值: {old_value:.2f}, "
|
f"关系值: {old_value:.2f}, "
|
||||||
f"当前立场情感: {stance}-{label}, "
|
f"当前立场情感: {stance}-{label}, "
|
||||||
@@ -187,8 +188,6 @@ class RelationshipManager:
|
|||||||
|
|
||||||
await person_info_manager.update_one_field(person_id, "relationship_value", old_value + value, data)
|
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(
|
async def calculate_update_relationship_value_with_reason(
|
||||||
self, chat_stream: ChatStream, label: str, stance: str, reason: str
|
self, chat_stream: ChatStream, label: str, stance: str, reason: str
|
||||||
) -> tuple:
|
) -> tuple:
|
||||||
|
|||||||
Reference in New Issue
Block a user