From cad9b40bb3eeac68baf865b4326f8bca7405b13c Mon Sep 17 00:00:00 2001 From: SengokuCola <1026294844@qq.com> Date: Tue, 27 May 2025 18:35:33 +0800 Subject: [PATCH] =?UTF-8?q?better=EF=BC=9A=E8=BF=9B=E4=B8=80=E6=AD=A5?= =?UTF-8?q?=E6=8B=86=E5=88=86=E6=A8=A1=E5=9E=8B=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/chat/emoji_system/emoji_manager.py | 2 +- .../expressors/default_expressor.py | 6 +- .../info_processors/chattinginfo_processor.py | 2 +- src/chat/normal_chat/normal_chat_generator.py | 8 +-- src/config/official_configs.py | 20 ++++--- src/experimental/PFC/pfc.py | 2 +- src/experimental/PFC/pfc_KnowledgeFetcher.py | 4 +- src/llm_models/utils_model.py | 4 +- src/person_info/person_info.py | 2 +- template/bot_config_template.toml | 60 +++++++++++-------- 10 files changed, 61 insertions(+), 49 deletions(-) diff --git a/src/chat/emoji_system/emoji_manager.py b/src/chat/emoji_system/emoji_manager.py index 376e6b8fe..964721e42 100644 --- a/src/chat/emoji_system/emoji_manager.py +++ b/src/chat/emoji_system/emoji_manager.py @@ -374,7 +374,7 @@ class EmojiManager: self.vlm = LLMRequest(model=global_config.model.vlm, temperature=0.3, max_tokens=1000, request_type="emoji") self.llm_emotion_judge = LLMRequest( - model=global_config.model.normal, max_tokens=600, request_type="emoji" + model=global_config.model.utils, max_tokens=600, request_type="emoji" ) # 更高的温度,更少的token(后续可以根据情绪来调整温度) self.emoji_num = 0 diff --git a/src/chat/focus_chat/expressors/default_expressor.py b/src/chat/focus_chat/expressors/default_expressor.py index be3e827f8..4e46acaa2 100644 --- a/src/chat/focus_chat/expressors/default_expressor.py +++ b/src/chat/focus_chat/expressors/default_expressor.py @@ -192,9 +192,9 @@ class DefaultExpressor: """ try: # 1. 获取情绪影响因子并调整模型温度 - arousal_multiplier = mood_manager.get_arousal_multiplier() - current_temp = float(global_config.model.normal["temp"]) * arousal_multiplier - self.express_model.params["temperature"] = current_temp # 动态调整温度 + # arousal_multiplier = mood_manager.get_arousal_multiplier() + # current_temp = float(global_config.model.normal["temp"]) * arousal_multiplier + # self.express_model.params["temperature"] = current_temp # 动态调整温度 # 2. 获取信息捕捉器 info_catcher = info_catcher_manager.get_info_catcher(thinking_id) diff --git a/src/chat/focus_chat/info_processors/chattinginfo_processor.py b/src/chat/focus_chat/info_processors/chattinginfo_processor.py index 1fcab5e44..d0b6df5f4 100644 --- a/src/chat/focus_chat/info_processors/chattinginfo_processor.py +++ b/src/chat/focus_chat/info_processors/chattinginfo_processor.py @@ -28,7 +28,7 @@ class ChattingInfoProcessor(BaseProcessor): super().__init__() # TODO: API-Adapter修改标记 self.model_summary = LLMRequest( - model=global_config.model.observation, temperature=0.7, max_tokens=300, request_type="chat_observation" + model=global_config.model.utils_small, temperature=0.7, max_tokens=300, request_type="chat_observation" ) async def process_info( diff --git a/src/chat/normal_chat/normal_chat_generator.py b/src/chat/normal_chat/normal_chat_generator.py index 7fa6b0321..0a34ffc8c 100644 --- a/src/chat/normal_chat/normal_chat_generator.py +++ b/src/chat/normal_chat/normal_chat_generator.py @@ -20,13 +20,13 @@ class NormalChatGenerator: model=global_config.model.normal_chat_1, temperature=0.7, max_tokens=3000, - request_type="response_reasoning", + request_type="normal_chat_1", ) self.model_normal = LLMRequest( - model=global_config.model.normal, - temperature=global_config.model.normal["temp"], + model=global_config.model.normal_chat_2, + temperature=global_config.model.normal_chat_2["temp"], max_tokens=256, - request_type="response_reasoning", + request_type="normal_chat_2", ) self.model_sum = LLMRequest( diff --git a/src/config/official_configs.py b/src/config/official_configs.py index a35026e53..731c847fc 100644 --- a/src/config/official_configs.py +++ b/src/config/official_configs.py @@ -377,12 +377,19 @@ class ModelConfig(ConfigBase): """模型配置类""" model_max_output_length: int = 800 # 最大回复长度 + + + utils: dict[str, Any] = field(default_factory=lambda: {}) + """组件模型配置""" + + utils_small: dict[str, Any] = field(default_factory=lambda: {}) + """组件小模型配置""" - reasoning: dict[str, Any] = field(default_factory=lambda: {}) - """推理模型配置""" - - normal: dict[str, Any] = field(default_factory=lambda: {}) - """普通模型配置""" + normal_chat_1: dict[str, Any] = field(default_factory=lambda: {}) + """normal_chat首要回复模型模型配置""" + + normal_chat_2: dict[str, Any] = field(default_factory=lambda: {}) + """normal_chat次要回复模型配置""" memory_summary: dict[str, Any] = field(default_factory=lambda: {}) """记忆的概括模型配置""" @@ -390,9 +397,6 @@ class ModelConfig(ConfigBase): vlm: dict[str, Any] = field(default_factory=lambda: {}) """视觉语言模型配置""" - observation: dict[str, Any] = field(default_factory=lambda: {}) - """观察模型配置""" - focus_working_memory: dict[str, Any] = field(default_factory=lambda: {}) """专注工作记忆模型配置""" diff --git a/src/experimental/PFC/pfc.py b/src/experimental/PFC/pfc.py index d487a1aad..78397780d 100644 --- a/src/experimental/PFC/pfc.py +++ b/src/experimental/PFC/pfc.py @@ -44,7 +44,7 @@ class GoalAnalyzer: def __init__(self, stream_id: str, private_name: str): # TODO: API-Adapter修改标记 self.llm = LLMRequest( - model=global_config.model.normal, temperature=0.7, max_tokens=1000, request_type="conversation_goal" + model=global_config.model.utils, temperature=0.7, max_tokens=1000, request_type="conversation_goal" ) self.personality_info = individuality.get_prompt(x_person=2, level=3) diff --git a/src/experimental/PFC/pfc_KnowledgeFetcher.py b/src/experimental/PFC/pfc_KnowledgeFetcher.py index 769d54da8..b94cd5b1f 100644 --- a/src/experimental/PFC/pfc_KnowledgeFetcher.py +++ b/src/experimental/PFC/pfc_KnowledgeFetcher.py @@ -16,8 +16,8 @@ class KnowledgeFetcher: def __init__(self, private_name: str): # TODO: API-Adapter修改标记 self.llm = LLMRequest( - model=global_config.model.normal, - temperature=global_config.model.normal["temp"], + model=global_config.model.utils, + temperature=global_config.model.utils["temp"], max_tokens=1000, request_type="knowledge_fetch", ) diff --git a/src/llm_models/utils_model.py b/src/llm_models/utils_model.py index 2a45c5c94..f24761925 100644 --- a/src/llm_models/utils_model.py +++ b/src/llm_models/utils_model.py @@ -497,8 +497,8 @@ class LLMRequest: logger.warning(f"检测到403错误,模型从 {old_model_name} 降级为 {self.model_name}") # 对全局配置进行更新 - if global_config.model.normal.get("name") == old_model_name: - global_config.model.normal["name"] = self.model_name + if global_config.model.normal_chat_2.get("name") == old_model_name: + global_config.model.normal_chat_2["name"] = self.model_name logger.warning(f"将全局配置中的 llm_normal 模型临时降级至{self.model_name}") if global_config.model.normal_chat_1.get("name") == old_model_name: global_config.model.normal_chat_1["name"] = self.model_name diff --git a/src/person_info/person_info.py b/src/person_info/person_info.py index f4e14df72..9a85d1716 100644 --- a/src/person_info/person_info.py +++ b/src/person_info/person_info.py @@ -58,7 +58,7 @@ class PersonInfoManager: self.person_name_list = {} # TODO: API-Adapter修改标记 self.qv_name_llm = LLMRequest( - model=global_config.model.normal, + model=global_config.model.utils, max_tokens=256, request_type="qv_name", ) diff --git a/template/bot_config_template.toml b/template/bot_config_template.toml index 094399ead..5721f8f95 100644 --- a/template/bot_config_template.toml +++ b/template/bot_config_template.toml @@ -133,7 +133,7 @@ mood_update_interval = 1.0 # 情绪更新间隔 单位秒 mood_decay_rate = 0.95 # 情绪衰减率 mood_intensity_factor = 1.0 # 情绪强度因子 -[keyword_reaction] # 针对某个关键词作出反应 +[keyword_reaction] # 针对某个关键词作出反应,仅在 普通聊天 有效 enable = true # 关键词反应功能的总开关 [[keyword_reaction.rules]] # 如果想要新增多个关键词,直接复制本条,修改keywords和reaction即可 @@ -181,10 +181,9 @@ enable = true [experimental] #实验性功能 enable_friend_chat = false # 是否启用好友聊天 -pfc_chatting = false # 是否启用PFC聊天,该功能仅作用于私聊,与回复模式独立 +pfc_chatting = false # 是否启用PFC聊天,该功能仅作用于私聊,与回复模式独立,在0.7.0暂时无效 #下面的模型若使用硅基流动则不需要更改,使用ds官方则改成.env自定义的宏,使用自定义模型则选择定位相似的模型自己填写 -#推理模型 # 额外字段 # 下面的模型有以下额外字段可以添加: @@ -195,14 +194,9 @@ pfc_chatting = false # 是否启用PFC聊天,该功能仅作用于私聊,与 [model] model_max_output_length = 800 # 模型单次返回的最大token数 -#这个模型必须是推理模型 -[model.normal_chat_1] # 一般聊天模式的首要回复模型,推荐使用 推理模型 -name = "Pro/deepseek-ai/DeepSeek-R1" -provider = "SILICONFLOW" -pri_in = 1.0 #模型的输入价格(非必填,可以记录消耗) -pri_out = 4.0 #模型的输出价格(非必填,可以记录消耗) +#------------必填:组件模型------------ -[model.normal] #V3 回复模型 专注和一般聊天模式共用的回复模型 +[model.utils] # 在麦麦的一些组件中使用的模型,例如表情包模块,取名模块,消耗量不大 name = "Pro/deepseek-ai/DeepSeek-V3" provider = "SILICONFLOW" pri_in = 2 #模型的输入价格(非必填,可以记录消耗) @@ -210,6 +204,13 @@ pri_out = 8 #模型的输出价格(非必填,可以记录消耗) #默认temp 0.2 如果你使用的是老V3或者其他模型,请自己修改temp参数 temp = 0.2 #模型的温度,新V3建议0.1-0.3 +[model.utils_small] # 在麦麦的一些组件中使用的小模型,消耗量较大 +# 强烈建议使用免费的小模型 +name = "Qwen/Qwen2.5-7B-Instruct" +provider = "SILICONFLOW" +pri_in = 0 +pri_out = 0 + [model.memory_summary] # 记忆的概括模型,建议使用qwen2.5 32b 及以上 name = "Qwen/Qwen2.5-32B-Instruct" provider = "SILICONFLOW" @@ -222,15 +223,32 @@ provider = "SILICONFLOW" pri_in = 0.35 pri_out = 0.35 -[model.observation] #观察模型,压缩聊天内容,建议用免费的 -# name = "Pro/Qwen/Qwen2.5-7B-Instruct" -name = "Qwen/Qwen2.5-7B-Instruct" +#嵌入模型 +[model.embedding] +name = "BAAI/bge-m3" provider = "SILICONFLOW" pri_in = 0 pri_out = 0 -[model.focus_working_memory] #工作记忆模型,建议使用qwen2.5 32b -# name = "Pro/Qwen/Qwen2.5-7B-Instruct" +#------------普通聊天必填模型------------ + +[model.normal_chat_1] # 一般聊天模式的首要回复模型,推荐使用 推理模型 +name = "Pro/deepseek-ai/DeepSeek-R1" +provider = "SILICONFLOW" +pri_in = 1.0 #模型的输入价格(非必填,可以记录消耗) +pri_out = 4.0 #模型的输出价格(非必填,可以记录消耗) + +[model.normal_chat_2] # 一般聊天模式的次要回复模型,推荐使用 非推理模型 +name = "Pro/deepseek-ai/DeepSeek-V3" +provider = "SILICONFLOW" +pri_in = 2 #模型的输入价格(非必填,可以记录消耗) +pri_out = 8 #模型的输出价格(非必填,可以记录消耗) +#默认temp 0.2 如果你使用的是老V3或者其他模型,请自己修改temp参数 +temp = 0.2 #模型的温度,新V3建议0.1-0.3 + +#------------专注聊天必填模型------------ + +[model.focus_working_memory] #工作记忆模型 name = "Qwen/Qwen2.5-32B-Instruct" provider = "SILICONFLOW" pri_in = 1.26 @@ -243,7 +261,7 @@ pri_in = 2 pri_out = 8 temp = 0.3 #模型的温度,新V3建议0.1-0.3 -[model.focus_tool_use] #工具调用模型,需要使用支持工具调用的模型,建议使用qwen2.5 32b +[model.focus_tool_use] #工具调用模型,需要使用支持工具调用的模型 name = "Qwen/Qwen2.5-32B-Instruct" provider = "SILICONFLOW" pri_in = 1.26 @@ -272,16 +290,6 @@ pri_in = 2 pri_out = 8 temp = 0.3 -#嵌入模型 - -[model.embedding] #嵌入 -name = "BAAI/bge-m3" -provider = "SILICONFLOW" -pri_in = 0 -pri_out = 0 - - - #私聊PFC:需要开启PFC功能,默认三个模型均为硅基流动v3,如果需要支持多人同时私聊或频繁调用,建议把其中的一个或两个换成官方v3或其它模型,以免撞到429