From 6b4130efcd16da9f2be472f36825c8392c092eb6 Mon Sep 17 00:00:00 2001 From: Rikki Date: Mon, 10 Mar 2025 04:09:44 +0800 Subject: [PATCH 1/6] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0stable-dev?= =?UTF-8?q?=E5=88=86=E6=94=AF=E7=9A=84=E6=89=93=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/docker-image.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 2a5f497fd..b729a14ef 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -5,6 +5,7 @@ on: branches: - main - debug # 新增 debug 分支触发 + - stable-dev tags: - 'v*' workflow_dispatch: From 8b7876c14f8031070faec023935a6a02fb92a97e Mon Sep 17 00:00:00 2001 From: Rikki Date: Mon, 10 Mar 2025 04:20:07 +0800 Subject: [PATCH 2/6] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0tag=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/docker-image.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index b729a14ef..5b09b8cda 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -35,6 +35,8 @@ jobs: echo "tags=${{ secrets.DOCKERHUB_USERNAME }}/maimbot:main,${{ secrets.DOCKERHUB_USERNAME }}/maimbot:latest" >> $GITHUB_OUTPUT elif [ "${{ github.ref }}" == "refs/heads/debug" ]; then echo "tags=${{ secrets.DOCKERHUB_USERNAME }}/maimbot:debug" >> $GITHUB_OUTPUT + elif [ "${{ github.ref }}" == "refs/heads/stable-dev" ]; then + echo "tags=${{ secrets.DOCKERHUB_USERNAME }}/maimbot:stable-dev" >> $GITHUB_OUTPUT fi - name: Build and Push Docker Image From fddb64151ea456843a655032dd2117e810fad98e Mon Sep 17 00:00:00 2001 From: Rikki Date: Mon, 10 Mar 2025 04:56:40 +0800 Subject: [PATCH 3/6] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E7=9A=84=E7=A9=BA=E5=80=BC=E6=A3=80=E6=B5=8B=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/chat/emoji_manager.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/chat/emoji_manager.py b/src/plugins/chat/emoji_manager.py index 614bfe025..708454a1e 100644 --- a/src/plugins/chat/emoji_manager.py +++ b/src/plugins/chat/emoji_manager.py @@ -241,8 +241,9 @@ class EmojiManager: logger.info(f"其不满足过滤规则,被剔除 {check}") continue logger.info(f"check通过 {check}") - embedding = await get_embedding(discription) + if discription is not None: + embedding = await get_embedding(discription) # 准备数据库记录 emoji_record = { 'filename': filename, From 8a32d184605ec256541fc8d9b3bcee2dae2967ff Mon Sep 17 00:00:00 2001 From: AL76 <735756072@qq.com> Date: Mon, 10 Mar 2025 13:09:01 +0800 Subject: [PATCH 4/6] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96willing=5Fmanager?= =?UTF-8?q?=E9=80=BB=E8=BE=91=EF=BC=8C=E5=A2=9E=E5=8A=A0=E5=9B=9E=E5=A4=8D?= =?UTF-8?q?=E4=BF=9D=E5=BA=95=E6=A6=82=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/chat/willing_manager.py | 111 +++++++++++++++++----------- 1 file changed, 69 insertions(+), 42 deletions(-) diff --git a/src/plugins/chat/willing_manager.py b/src/plugins/chat/willing_manager.py index 4f8bec7dc..116ee3f87 100644 --- a/src/plugins/chat/willing_manager.py +++ b/src/plugins/chat/willing_manager.py @@ -1,6 +1,6 @@ import asyncio -from .config import global_config from loguru import logger +from .config import global_config class WillingManager: @@ -8,74 +8,100 @@ class WillingManager: self.group_reply_willing = {} # 存储每个群的回复意愿 self._decay_task = None self._started = False - + self.min_reply_willing = 0.01 + self.attenuation_coefficient = 0.75 + async def _decay_reply_willing(self): """定期衰减回复意愿""" while True: await asyncio.sleep(5) for group_id in self.group_reply_willing: - self.group_reply_willing[group_id] = max(0, self.group_reply_willing[group_id] * 0.6) - + self.group_reply_willing[group_id] = max( + self.min_reply_willing, + self.group_reply_willing[group_id] * self.attenuation_coefficient + ) + def get_willing(self, group_id: int) -> float: """获取指定群组的回复意愿""" return self.group_reply_willing.get(group_id, 0) - + def set_willing(self, group_id: int, willing: float): """设置指定群组的回复意愿""" self.group_reply_willing[group_id] = willing - - def change_reply_willing_received(self, group_id: int, topic: str, is_mentioned_bot: bool, config, user_id: int = None, is_emoji: bool = False, interested_rate: float = 0) -> float: - """改变指定群组的回复意愿并返回回复概率""" + + def change_reply_willing_received(self, group_id: int, topic: str, is_mentioned_bot: bool, config, + user_id: int = None, is_emoji: bool = False, interested_rate: float = 0) -> float: + + # 若非目标回复群组,则直接return + if group_id not in config.talk_allowed_groups: + reply_probability = 0 + return reply_probability + current_willing = self.group_reply_willing.get(group_id, 0) - - # print(f"初始意愿: {current_willing}") - if is_mentioned_bot and current_willing < 1.0: - current_willing += 0.9 - logger.info(f"被提及, 当前意愿: {current_willing}") - elif is_mentioned_bot: - current_willing += 0.05 - logger.info(f"被重复提及, 当前意愿: {current_willing}") - + + logger.debug(f"[{group_id}]的初始回复意愿: {current_willing}") + + # 根据消息类型(被cue/表情包)调控 + if is_mentioned_bot: + current_willing = min( + 3.0, + current_willing + 0.9 + ) + logger.debug(f"被提及, 当前意愿: {current_willing}") + if is_emoji: current_willing *= 0.1 - logger.info(f"表情包, 当前意愿: {current_willing}") - - logger.debug(f"放大系数_interested_rate: {global_config.response_interested_rate_amplifier}") - interested_rate *= global_config.response_interested_rate_amplifier #放大回复兴趣度 - if interested_rate > 0.4: - # print(f"兴趣度: {interested_rate}, 当前意愿: {current_willing}") - current_willing += interested_rate-0.4 - - current_willing *= global_config.response_willing_amplifier #放大回复意愿 - # print(f"放大系数_willing: {global_config.response_willing_amplifier}, 当前意愿: {current_willing}") - - reply_probability = max((current_willing - 0.45) * 2, 0) - if group_id not in config.talk_allowed_groups: - current_willing = 0 - reply_probability = 0 - + logger.debug(f"表情包, 当前意愿: {current_willing}") + + # 兴趣放大系数,若兴趣 > 0.4则增加回复概率 + interested_rate_amplifier = global_config.response_interested_rate_amplifier + logger.debug(f"放大系数_interested_rate: {interested_rate_amplifier}") + interested_rate *= interested_rate_amplifier + + current_willing += max( + 0.0, + interested_rate - 0.4 + ) + + # 回复意愿系数调控,独立乘区 + willing_amplifier = max( + global_config.response_willing_amplifier, + self.min_reply_willing + ) + current_willing *= willing_amplifier + logger.debug(f"放大系数_willing: {global_config.response_willing_amplifier}, 当前意愿: {current_willing}") + + # 回复概率迭代,保底0.01回复概率 + reply_probability = max( + (current_willing - 0.45) * 2, + self.min_reply_willing + ) + + # 降低目标低频群组回复概率 + down_frequency_rate = max( + 1.0, + global_config.down_frequency_rate + ) if group_id in config.talk_frequency_down_groups: - reply_probability = reply_probability / global_config.down_frequency_rate + reply_probability = reply_probability / down_frequency_rate reply_probability = min(reply_probability, 1) - if reply_probability < 0: - reply_probability = 0 - - + self.group_reply_willing[group_id] = min(current_willing, 3.0) + logger.debug(f"当前群组{group_id}回复概率:{reply_probability}") return reply_probability - + def change_reply_willing_sent(self, group_id: int): """开始思考后降低群组的回复意愿""" current_willing = self.group_reply_willing.get(group_id, 0) self.group_reply_willing[group_id] = max(0, current_willing - 2) - + def change_reply_willing_after_sent(self, group_id: int): """发送消息后提高群组的回复意愿""" current_willing = self.group_reply_willing.get(group_id, 0) if current_willing < 1: self.group_reply_willing[group_id] = min(1, current_willing + 0.2) - + async def ensure_started(self): """确保衰减任务已启动""" if not self._started: @@ -83,5 +109,6 @@ class WillingManager: self._decay_task = asyncio.create_task(self._decay_reply_willing()) self._started = True + # 创建全局实例 -willing_manager = WillingManager() +willing_manager = WillingManager() From 68b3f578c4331298e69c43e5840b87689dad75c2 Mon Sep 17 00:00:00 2001 From: UnCLAS-Prommer Date: Mon, 10 Mar 2025 20:36:15 +0800 Subject: [PATCH 5/6] Minor Doc Update --- README.md | 15 +++++++-------- docs/installation_cute.md | 4 ++-- docs/installation_standard.md | 2 +- run.bat | 2 +- run.py | 2 ++ 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 0c02d1cba..29e25b2b9 100644 --- a/README.md +++ b/README.md @@ -51,18 +51,17 @@ ### 部署方式 -如果你不知道Docker是什么,建议寻找相关教程或使用手动部署(现在不建议使用docker,更新慢,可能不适配) +- 📦 **Windows 一键傻瓜式部署**:请运行项目根目录中的 ```run.bat```,部署完成后请参照后续配置指南进行配置 + +- [📦 Windows 手动部署指南 ](docs/manual_deploy_windows.md) + +- [📦 Linux 手动部署指南 ](docs/manual_deploy_linux.md) + +如果你不知道Docker是什么,建议寻找相关教程或使用手动部署 **(现在不建议使用docker,更新慢,可能不适配)** - [🐳 Docker部署指南](docs/docker_deploy.md) -- [📦 手动部署指南 Windows](docs/manual_deploy_windows.md) - - -- [📦 手动部署指南 Linux](docs/manual_deploy_linux.md) - -- 📦 Windows 一键傻瓜式部署,请运行项目根目录中的 ```run.bat```,部署完成后请参照后续配置指南进行配置 - ### 配置说明 - [🎀 新手配置指南](docs/installation_cute.md) - 通俗易懂的配置教程,适合初次使用的猫娘 - [⚙️ 标准配置指南](docs/installation_standard.md) - 简明专业的配置说明,适合有经验的用户 diff --git a/docs/installation_cute.md b/docs/installation_cute.md index e7541f7d3..3a63988f1 100644 --- a/docs/installation_cute.md +++ b/docs/installation_cute.md @@ -52,12 +52,12 @@ key = "SILICONFLOW_KEY" # 用同一张门票就可以啦 如果你想用DeepSeek官方的服务,就要这样改: ```toml [model.llm_reasoning] -name = "Pro/deepseek-ai/DeepSeek-R1" +name = "deepseek-reasoner" # 改成对应的模型名称,这里为DeepseekR1 base_url = "DEEP_SEEK_BASE_URL" # 改成去DeepSeek游乐园 key = "DEEP_SEEK_KEY" # 用DeepSeek的门票 [model.llm_normal] -name = "Pro/deepseek-ai/DeepSeek-V3" +name = "deepseek-chat" # 改成对应的模型名称,这里为DeepseekV3 base_url = "DEEP_SEEK_BASE_URL" # 也去DeepSeek游乐园 key = "DEEP_SEEK_KEY" # 用同一张DeepSeek门票 ``` diff --git a/docs/installation_standard.md b/docs/installation_standard.md index 5f52676d1..71bfbac77 100644 --- a/docs/installation_standard.md +++ b/docs/installation_standard.md @@ -34,7 +34,7 @@ key = "SILICONFLOW_KEY" # 引用.env.prod中定义的密钥 如需切换到其他API服务,只需修改引用: ```toml [model.llm_reasoning] -name = "Pro/deepseek-ai/DeepSeek-R1" +name = "deepseek-reasoner" # 改成对应的模型名称,这里为DeepseekR1 base_url = "DEEP_SEEK_BASE_URL" # 切换为DeepSeek服务 key = "DEEP_SEEK_KEY" # 使用DeepSeek密钥 ``` diff --git a/run.bat b/run.bat index 659a7545a..91904bc34 100644 --- a/run.bat +++ b/run.bat @@ -3,7 +3,7 @@ chcp 65001 if not exist "venv" ( python -m venv venv call venv\Scripts\activate.bat - pip install -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple --upgrade -r requirements.txt + pip install -i https://mirrors.aliyun.com/pypi/simple --upgrade -r requirements.txt ) else ( call venv\Scripts\activate.bat ) diff --git a/run.py b/run.py index baea4d13c..50e312c37 100644 --- a/run.py +++ b/run.py @@ -107,6 +107,8 @@ def install_napcat(): napcat_filename = input( "下载完成后请把文件复制到此文件夹,并将**不包含后缀的文件名**输入至此窗口,如 NapCat.32793.Shell:" ) + if(napcat_filename[-4:] == ".zip"): + napcat_filename = napcat_filename[:-4] extract_files(napcat_filename + ".zip", "napcat") print("NapCat 安装完成") os.remove(napcat_filename + ".zip") From 2ffdfef02e7e87357b472c1b9c080316f9e44607 Mon Sep 17 00:00:00 2001 From: UnCLAS-Prommer Date: Mon, 10 Mar 2025 20:45:12 +0800 Subject: [PATCH 6/6] More --- docs/installation_standard.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/installation_standard.md b/docs/installation_standard.md index 71bfbac77..cf8e7eb9b 100644 --- a/docs/installation_standard.md +++ b/docs/installation_standard.md @@ -53,11 +53,11 @@ CHAT_ANY_WHERE_BASE_URL=https://api.chatanywhere.tech/v1 # 服务配置 HOST=127.0.0.1 # 如果使用Docker部署,需要改成0.0.0.0,否则QQ消息无法传入 -PORT=8080 +PORT=8080 # 与反向端口相同 # 数据库配置 MONGODB_HOST=127.0.0.1 # 如果使用Docker部署,需要改成数据库容器的名字,默认是mongodb -MONGODB_PORT=27017 +MONGODB_PORT=27017 # MongoDB端口 DATABASE_NAME=MegBot MONGODB_USERNAME = "" # 数据库用户名 MONGODB_PASSWORD = "" # 数据库密码