From 0c08151f92955600835f7ce409ebee7945d0fa86 Mon Sep 17 00:00:00 2001 From: SengokuCola <1026294844@qq.com> Date: Thu, 20 Mar 2025 21:32:05 +0800 Subject: [PATCH 1/5] Delete results directory --- results/personality_result.json | 46 --------------------------------- 1 file changed, 46 deletions(-) delete mode 100644 results/personality_result.json diff --git a/results/personality_result.json b/results/personality_result.json deleted file mode 100644 index 6424598b9..000000000 --- a/results/personality_result.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "final_scores": { - "开放性": 5.5, - "尽责性": 5.0, - "外向性": 6.0, - "宜人性": 1.5, - "神经质": 6.0 - }, - "scenarios": [ - { - "场景": "在团队项目中,你发现一个同事的工作质量明显低于预期,这可能会影响整个项目的进度。", - "评估维度": [ - "尽责性", - "宜人性" - ] - }, - { - "场景": "你被邀请参加一个完全陌生的社交活动,现场都是不认识的人。", - "评估维度": [ - "外向性", - "神经质" - ] - }, - { - "场景": "你的朋友向你推荐了一个新的艺术展览,但风格与你平时接触的完全不同。", - "评估维度": [ - "开放性", - "外向性" - ] - }, - { - "场景": "在工作中,你遇到了一个技术难题,需要学习全新的技术栈。", - "评估维度": [ - "开放性", - "尽责性" - ] - }, - { - "场景": "你的朋友因为个人原因情绪低落,向你寻求帮助。", - "评估维度": [ - "宜人性", - "神经质" - ] - } - ] -} \ No newline at end of file From 3b2c97b7bc1802a95024e9a59ce219266b883062 Mon Sep 17 00:00:00 2001 From: Charlie Wang Date: Thu, 20 Mar 2025 22:29:19 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86bot=E7=AD=89?= =?UTF-8?q?=E5=BE=85=E4=B8=80=E4=B8=AA=E4=BA=BA=E8=AF=B4=E5=AE=8C=E6=89=80?= =?UTF-8?q?=E6=9C=89=E8=AF=9D=E7=9A=84=E5=8A=9F=E8=83=BD=E5=92=8C=E9=80=9A?= =?UTF-8?q?=E8=BF=87at=E5=BF=AB=E9=80=9F=E5=A2=9E=E5=8A=A0=E5=A5=BD?= =?UTF-8?q?=E6=84=9F=E5=BA=A6=E7=9A=84=E5=8A=9F=E8=83=BD(sec/plugins/chat/?= =?UTF-8?q?bot.py)=20=E7=BB=99=E5=8F=AF=E8=A7=86=E5=8C=96=E6=8E=A8?= =?UTF-8?q?=E7=90=86/=E8=AE=B0=E5=BF=86=E5=8A=A0=E4=BA=86sys.path.insert?= =?UTF-8?q?=E9=98=B2=E6=AD=A2=E6=89=BE=E4=B8=8D=E5=88=B0src=20requirements?= =?UTF-8?q?=E5=8A=A0=E4=BA=86scipy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- requirements.txt | Bin 658 -> 672 bytes src/gui/reasoning_gui.py | 2 + src/plugins/chat/bot.py | 49 ++++++++++++++++-- .../memory_system/memory_manual_build.py | 6 +++ 4 files changed, 52 insertions(+), 5 deletions(-) diff --git a/requirements.txt b/requirements.txt index 1e9e5ff25b8c4ccae9904607247966efcd269ab7..0dfd751484930ec11fed6da3b69ff72e6f5be121 100644 GIT binary patch delta 22 dcmbQlx`1`VBqlyy1}=tThGd3Jh60941^_ None: + groupinfo = message.message_info.group_info + userinfo = message.message_info.user_info + messageinfo = message.message_info + # 过滤词 for word in global_config.ban_words: if word in message.processed_plain_text: @@ -120,7 +137,15 @@ class ChatBot: await self.storage.store_message(message, chat, topic[0] if topic else None) - is_mentioned = is_mentioned_bot_in_message(message) + is_mentioned = is_mentioned_bot_in_message(message) or groupID == -1 + if is_mentioned: + relationship_value = relationship_manager.get_relationship(chat).relationship_value if relationship_manager.get_relationship(chat) else 0.0 + await relationship_manager.update_relationship( + chat_stream=chat, + ) + await relationship_manager.update_relationship_value( + chat_stream=chat, relationship_value = min(max(40 - relationship_value, 2)/2, 10000) + ) reply_probability = await willing_manager.change_reply_willing_received( chat_stream=chat, is_mentioned_bot=is_mentioned, @@ -130,15 +155,27 @@ class ChatBot: sender_id=str(message.message_info.user_info.user_id), ) current_willing = willing_manager.get_willing(chat_stream=chat) - + actual_prob = random() logger.info( f"[{current_time}][{chat.group_info.group_name if chat.group_info else '私聊'}]{chat.user_info.user_nickname}:" f"{message.processed_plain_text}[回复意愿:{current_willing:.2f}][概率:{reply_probability * 100:.1f}%]" ) - + reply_probability = 1 if is_mentioned else reply_probability + logger.info("!!!决定回复!!!" if actual_prob < reply_probability else "===不理===") + response = None # 开始组织语言 - if random() < reply_probability: + if groupID not in self.group_message_dict: + self.group_message_dict[groupID] = {} + this_msg_time = time.time() + if userinfo.user_id not in self.group_message_dict[groupID].keys(): + self.group_message_dict[groupID][userinfo.user_id] = -1 + + if (actual_prob < reply_probability) or (self.group_message_dict[groupID][userinfo.user_id] != -1): + self.group_message_dict[groupID][userinfo.user_id] = this_msg_time + await asyncio.sleep(30) + if this_msg_time != self.group_message_dict[groupID][userinfo.user_id]: + return bot_user_info = UserInfo( user_id=global_config.BOT_QQ, user_nickname=global_config.BOT_NICKNAME, @@ -168,6 +205,8 @@ class ChatBot: # print(f"response: {response}") if response: # print(f"有response: {response}") + if this_msg_time == self.group_message_dict[groupID][userinfo.user_id]: + self.group_message_dict[groupID][userinfo.user_id] = -1 container = message_manager.get_container(chat.stream_id) thinking_message = None # 找到message,删除 diff --git a/src/plugins/memory_system/memory_manual_build.py b/src/plugins/memory_system/memory_manual_build.py index 9b01640a9..3b4b2af82 100644 --- a/src/plugins/memory_system/memory_manual_build.py +++ b/src/plugins/memory_system/memory_manual_build.py @@ -11,6 +11,12 @@ from pathlib import Path import matplotlib.pyplot as plt import networkx as nx from dotenv import load_dotenv +sys.path.insert(0, sys.path[0]+"/../") +sys.path.insert(0, sys.path[0]+"/../") +sys.path.insert(0, sys.path[0]+"/../") +sys.path.insert(0, sys.path[0]+"/../") +sys.path.insert(0, sys.path[0]+"/../") +print(sys.path) from src.common.logger import get_module_logger import jieba From dcf2b7c1ff5074a0ec41d279feb4305fd5f6be18 Mon Sep 17 00:00:00 2001 From: Charlie Wang Date: Fri, 21 Mar 2025 16:17:48 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E6=80=9D?= =?UTF-8?q?=E8=80=83=E8=BF=87=E7=A8=8B=E6=9C=AA=E8=83=BD=E5=A6=A5=E5=BD=93?= =?UTF-8?q?=E5=A4=84=E7=90=86(=E8=87=B3=E5=B0=91=E5=9C=A8=E7=81=AB?= =?UTF-8?q?=E5=B1=B1=E4=B8=8A=E6=98=AF=E8=BF=99=E6=A0=B7)=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/models/utils_model.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/models/utils_model.py b/src/plugins/models/utils_model.py index d915b3759..c8b358a4f 100644 --- a/src/plugins/models/utils_model.py +++ b/src/plugins/models/utils_model.py @@ -274,6 +274,7 @@ class LLM_request: raise RuntimeError(f"请求被拒绝: {error_code_mapping.get(response.status)}") response.raise_for_status() + reasoning_content = "" # 将流式输出转化为非流式输出 if stream_mode: @@ -303,6 +304,8 @@ class LLM_request: accumulated_content += delta_content # 检测流式输出文本是否结束 finish_reason = chunk["choices"][0].get("finish_reason") + if delta.get("reasoning_content", None): + reasoning_content += delta["reasoning_content"] if finish_reason == "stop": chunk_usage = chunk.get("usage", None) if chunk_usage: @@ -314,7 +317,6 @@ class LLM_request: except Exception as e: logger.exception(f"解析流式输出错误: {str(e)}") content = accumulated_content - reasoning_content = "" think_match = re.search(r"(.*?)", content, re.DOTALL) if think_match: reasoning_content = think_match.group(1).strip() From 842da395ea115b09f5def8a558b43f66c700e9d4 Mon Sep 17 00:00:00 2001 From: Charlie Wang Date: Fri, 21 Mar 2025 16:23:08 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E4=B8=8D=E4=BD=BF=E7=94=A8conda=E8=80=8C?= =?UTF-8?q?=E6=98=AF=E4=BD=BF=E7=94=A8venv=E5=90=AF=E5=8A=A8=E9=BA=A6?= =?UTF-8?q?=E9=BA=A6=E8=84=91=E5=86=85=E6=89=80=E6=83=B3gui?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/run_thingking.bat | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/script/run_thingking.bat b/script/run_thingking.bat index a134da6fe..0806e46ed 100644 --- a/script/run_thingking.bat +++ b/script/run_thingking.bat @@ -1,5 +1,5 @@ -call conda activate niuniu -cd src\gui -start /b python reasoning_gui.py +@REM call conda activate niuniu +cd ../src\gui +start /b ../../venv/scripts/python.exe reasoning_gui.py exit From cafa5340085d04010260ac4bbae1c6fafff4ec6f Mon Sep 17 00:00:00 2001 From: Charlie Wang Date: Fri, 21 Mar 2025 17:42:03 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E6=9A=82=E6=97=B6=E6=92=A4=E9=94=80?= =?UTF-8?q?=E5=AF=B9bot.py=E7=9A=84=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/chat/bot.py | 49 +++++------------------------------------ 1 file changed, 5 insertions(+), 44 deletions(-) diff --git a/src/plugins/chat/bot.py b/src/plugins/chat/bot.py index 29cafdd61..d30940f97 100644 --- a/src/plugins/chat/bot.py +++ b/src/plugins/chat/bot.py @@ -1,6 +1,5 @@ import re import time -import asyncio from random import random from nonebot.adapters.onebot.v11 import ( Bot, @@ -54,9 +53,7 @@ class ChatBot: self._started = False self.mood_manager = MoodManager.get_instance() # 获取情绪管理器单例 self.mood_manager.start_mood_update() # 启动情绪更新 - - self.group_message_dict = {} - + self.emoji_chance = 0.2 # 发送表情包的基础概率 # self.message_streams = MessageStreamContainer() @@ -99,20 +96,6 @@ class ChatBot: await relationship_manager.update_relationship_value(chat_stream=chat, relationship_value=0) await message.process() - - await relationship_manager.update_relationship( - chat_stream=chat, - ) - await relationship_manager.update_relationship_value( - chat_stream=chat, relationship_value=0 - ) - groupid = groupinfo.group_id if groupinfo is not None else -1 - await self.message_process_onto_group(message, chat, groupid) - - async def message_process_onto_group(self, message: MessageRecvCQ, chat, groupID: int) -> None: - groupinfo = message.message_info.group_info - userinfo = message.message_info.user_info - messageinfo = message.message_info # 过滤词 for word in global_config.ban_words: @@ -144,15 +127,7 @@ class ChatBot: await self.storage.store_message(message, chat, topic[0] if topic else None) - is_mentioned = is_mentioned_bot_in_message(message) or groupID == -1 - if is_mentioned: - relationship_value = relationship_manager.get_relationship(chat).relationship_value if relationship_manager.get_relationship(chat) else 0.0 - await relationship_manager.update_relationship( - chat_stream=chat, - ) - await relationship_manager.update_relationship_value( - chat_stream=chat, relationship_value = min(max(40 - relationship_value, 2)/2, 10000) - ) + is_mentioned = is_mentioned_bot_in_message(message) reply_probability = await willing_manager.change_reply_willing_received( chat_stream=chat, is_mentioned_bot=is_mentioned, @@ -162,28 +137,16 @@ class ChatBot: sender_id=str(message.message_info.user_info.user_id), ) current_willing = willing_manager.get_willing(chat_stream=chat) - actual_prob = random() + logger.info( f"[{current_time}][{chat.group_info.group_name if chat.group_info else '私聊'}]" f"{chat.user_info.user_nickname}:" f"{message.processed_plain_text}[回复意愿:{current_willing:.2f}][概率:{reply_probability * 100:.1f}%]" ) - reply_probability = 1 if is_mentioned else reply_probability - logger.info("!!!决定回复!!!" if actual_prob < reply_probability else "===不理===") - + response = None # 开始组织语言 - if groupID not in self.group_message_dict: - self.group_message_dict[groupID] = {} - this_msg_time = time.time() - if userinfo.user_id not in self.group_message_dict[groupID].keys(): - self.group_message_dict[groupID][userinfo.user_id] = -1 - - if (actual_prob < reply_probability) or (self.group_message_dict[groupID][userinfo.user_id] != -1): - self.group_message_dict[groupID][userinfo.user_id] = this_msg_time - await asyncio.sleep(30) - if this_msg_time != self.group_message_dict[groupID][userinfo.user_id]: - return + if random() < reply_probability: bot_user_info = UserInfo( user_id=global_config.BOT_QQ, user_nickname=global_config.BOT_NICKNAME, @@ -213,8 +176,6 @@ class ChatBot: # print(f"response: {response}") if response: # print(f"有response: {response}") - if this_msg_time == self.group_message_dict[groupID][userinfo.user_id]: - self.group_message_dict[groupID][userinfo.user_id] = -1 container = message_manager.get_container(chat.stream_id) thinking_message = None # 找到message,删除