mirror of https://github.com/Mai-with-u/MaiBot.git
pull/937/head
parent
5e9177e775
commit
0e4ddc5d67
|
|
@ -142,7 +142,7 @@ class ActionHandler(ABC):
|
|||
)
|
||||
|
||||
# 限制历史记录长度
|
||||
max_history_len = getattr(global_config, "pfc_max_chat_history_for_checker", 50)
|
||||
max_history_len = global_config.pfc.pfc_max_chat_history_for_checker
|
||||
if len(observation_info.chat_history) > max_history_len:
|
||||
observation_info.chat_history = observation_info.chat_history[-max_history_len:]
|
||||
observation_info.chat_history_count = len(observation_info.chat_history)
|
||||
|
|
@ -616,7 +616,7 @@ class DirectReplyHandler(BaseTextReplyHandler):
|
|||
action_successful = False # 整体动作是否成功
|
||||
final_status = "recall" # 默认最终状态
|
||||
final_reason = "直接回复动作未成功执行" # 默认最终原因
|
||||
max_reply_attempts: int = getattr(global_config, "pfc_max_reply_attempts", 3)
|
||||
max_reply_attempts: int = global_config.pfc.pfc_max_reply_attempts
|
||||
|
||||
(
|
||||
sent_text_successfully,
|
||||
|
|
@ -697,7 +697,7 @@ class SendNewMessageHandler(BaseTextReplyHandler):
|
|||
action_successful = False # 整体动作是否成功
|
||||
final_status = "recall" # 默认最终状态
|
||||
final_reason = "发送新消息动作未成功执行" # 默认最终原因
|
||||
max_reply_attempts: int = getattr(global_config, "pfc_max_reply_attempts", 3)
|
||||
max_reply_attempts: int = global_config.pfc.pfc_max_reply_attempts
|
||||
|
||||
(
|
||||
sent_text_successfully,
|
||||
|
|
|
|||
|
|
@ -159,14 +159,10 @@ class ActionPlanner:
|
|||
self.private_name = private_name
|
||||
# 初始化 LLM 请求对象
|
||||
try:
|
||||
llm_config = global_config.model.pfc_action_planner
|
||||
if not isinstance(llm_config, dict):
|
||||
raise TypeError(f"LLM config 'pfc_action_planner' is not a dictionary: {llm_config}")
|
||||
|
||||
self.llm = LLMRequest(
|
||||
model=llm_config,
|
||||
temperature=llm_config.get("temp", 0.7),
|
||||
max_tokens=1500,
|
||||
model=global_config.model.pfc_action_planner,
|
||||
temperature=global_config.model.pfc_action_planner["temp"],
|
||||
max_tokens=global_config.model.pfc_action_planner["max_tokens"],
|
||||
request_type="action_planning",
|
||||
)
|
||||
except TypeError as e:
|
||||
|
|
|
|||
|
|
@ -45,10 +45,9 @@ async def run_conversation_loop(conversation_instance: "Conversation"):
|
|||
try:
|
||||
global TIME_ZONE
|
||||
if TIME_ZONE is None:
|
||||
configured_tz_loop = getattr(global_config, "TIME_ZONE", "Asia/Shanghai")
|
||||
TIME_ZONE = tz.gettz(configured_tz_loop)
|
||||
TIME_ZONE = global_config.schedule.time_zone
|
||||
if TIME_ZONE is None:
|
||||
logger.error(f"循环中: 配置的时区 '{configured_tz_loop}' 无效,将使用 'Asia/Shanghai'")
|
||||
logger.error(f"循环中: 配置的时区 '{global_config.schedule.time_zone}' 无效,将使用 'Asia/Shanghai'")
|
||||
TIME_ZONE = tz.gettz("Asia/Shanghai")
|
||||
|
||||
current_time_dt = datetime.datetime.now(TIME_ZONE)
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class PfcEmotionUpdater:
|
|||
self.mood_mng = mood_manager
|
||||
|
||||
# LLM 实例 (根据 global_config.model.summary 配置)
|
||||
llm_config_summary = getattr(global_config, "llm_summary", None)
|
||||
llm_config_summary = global_config.model.summary
|
||||
if llm_config_summary and isinstance(llm_config_summary, dict):
|
||||
logger.debug(f"[私聊][{self.private_name}] 使用 llm_summary 配置初始化情绪判断LLM。")
|
||||
self.llm = LLMRequest(
|
||||
|
|
@ -37,8 +37,8 @@ class PfcEmotionUpdater:
|
|||
logger.error(f"[私聊][{self.private_name}] 未找到 llm_summary 配置或配置无效!情绪判断功能将受限。")
|
||||
self.llm = None # LLM 未初始化
|
||||
|
||||
self.EMOTION_UPDATE_INTENSITY = getattr(global_config, "pfc_emotion_update_intensity", 0.6)
|
||||
self.EMOTION_HISTORY_COUNT = getattr(global_config, "pfc_emotion_history_count", 5)
|
||||
self.EMOTION_UPDATE_INTENSITY = global_config.pfc.pfc_emotion_update_intensity
|
||||
self.EMOTION_HISTORY_COUNT = global_config.pfc.pfc_emotion_history_count
|
||||
|
||||
async def update_emotion_based_on_context(
|
||||
self,
|
||||
|
|
|
|||
|
|
@ -30,20 +30,20 @@ class PfcRelationshipUpdater:
|
|||
|
||||
# LLM 实例 (为关系评估创建一个新的)
|
||||
# 尝试读取 llm_PFC_relationship_eval 配置,如果不存在则回退
|
||||
llm_config_rel_eval = getattr(global_config, "llm_PFC_relationship_eval", None)
|
||||
llm_config_rel_eval = global_config.model.PFC_relationship_eval
|
||||
if llm_config_rel_eval and isinstance(llm_config_rel_eval, dict):
|
||||
logger.info(f"[私聊][{self.private_name}] 使用 llm_PFC_relationship_eval 配置初始化关系评估LLM。")
|
||||
self.llm = LLMRequest(
|
||||
model=llm_config_rel_eval,
|
||||
temperature=llm_config_rel_eval.get("temp", 0.5), # 判断任务通常用较低温度
|
||||
max_tokens=llm_config_rel_eval.get("max_tokens", 512),
|
||||
model=global_config.model.PFC_relationship_eval,
|
||||
temperature=global_config.model.PFC_relationship_eval["temp"],
|
||||
max_tokens=global_config.model.PFC_relationship_eval["max_tokens"],
|
||||
request_type="pfc_relationship_evaluation",
|
||||
)
|
||||
else:
|
||||
logger.warning(
|
||||
f"[私聊][{self.private_name}] 未找到 llm_PFC_relationship_eval 配置或配置无效,将回退使用 llm_PFC_action_planner 的配置。"
|
||||
)
|
||||
llm_config_action_planner = getattr(global_config, "llm_PFC_action_planner", None)
|
||||
llm_config_action_planner = global_config.model.pfc_action_planner
|
||||
if llm_config_action_planner and isinstance(llm_config_action_planner, dict):
|
||||
self.llm = LLMRequest(
|
||||
model=llm_config_action_planner, # 使用 action_planner 的模型配置
|
||||
|
|
@ -56,14 +56,14 @@ class PfcRelationshipUpdater:
|
|||
self.llm = None # LLM 未初始化
|
||||
|
||||
# 从 global_config 读取参数,若无则使用默认值
|
||||
self.REL_INCREMENTAL_INTERVAL = getattr(global_config, "pfc_relationship_incremental_interval", 10)
|
||||
self.REL_INCREMENTAL_MSG_COUNT = getattr(global_config, "pfc_relationship_incremental_msg_count", 10)
|
||||
self.REL_INCREMENTAL_DEFAULT_CHANGE = getattr(global_config, "pfc_relationship_incremental_default_change", 1.0)
|
||||
self.REL_INCREMENTAL_MAX_CHANGE = getattr(global_config, "pfc_relationship_incremental_max_change", 5.0)
|
||||
self.REL_INCREMENTAL_INTERVAL = global_config.pfc.pfc_relationship_incremental_interval
|
||||
self.REL_INCREMENTAL_MSG_COUNT = global_config.pfc.pfc_relationship_incremental_msg_count
|
||||
self.REL_INCREMENTAL_DEFAULT_CHANGE = global_config.pfc.pfc_relationship_incremental_default_change
|
||||
self.REL_INCREMENTAL_MAX_CHANGE = global_config.pfc.pfc_relationship_incremental_max_change
|
||||
|
||||
self.REL_FINAL_MSG_COUNT = getattr(global_config, "pfc_relationship_final_msg_count", 30)
|
||||
self.REL_FINAL_DEFAULT_CHANGE = getattr(global_config, "pfc_relationship_final_default_change", 5.0)
|
||||
self.REL_FINAL_MAX_CHANGE = getattr(global_config, "pfc_relationship_final_max_change", 50.0)
|
||||
self.REL_FINAL_MSG_COUNT = global_config.pfc.pfc_relationship_final_msg_count
|
||||
self.REL_FINAL_DEFAULT_CHANGE = global_config.pfc.pfc_relationship_final_default_change
|
||||
self.REL_FINAL_MAX_CHANGE = global_config.pfc.pfc_relationship_final_max_change
|
||||
|
||||
async def update_relationship_incremental(
|
||||
self,
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ async def find_most_relevant_historical_message(
|
|||
log_source_of_limit = "传入的绝对时间上限"
|
||||
else:
|
||||
# 如果没有传入绝对时间上限,可以设置一个默认的回退逻辑
|
||||
fallback_exclude_seconds = getattr(global_config, "pfc_historical_fallback_exclude_seconds", 7200) # 默认2小时
|
||||
fallback_exclude_seconds = global_config.pfc.pfc_historical_fallback_exclude_seconds
|
||||
effective_search_upper_limit = time.time() - fallback_exclude_seconds
|
||||
log_source_of_limit = f"回退逻辑 (排除最近 {fallback_exclude_seconds} 秒)"
|
||||
|
||||
|
|
|
|||
|
|
@ -240,7 +240,7 @@ class ReplyGenerator:
|
|||
# 我们先做一个合理的假设: “最近聊天记录” 字符串 chat_history_text 是基于
|
||||
# observation_info.chat_history 的一个有限的尾部片段生成的。
|
||||
# 假设这个片段的长度由 global_config.pfc.pfc_recent_history_display_count 控制,默认为20条。
|
||||
recent_history_display_count = getattr(global_config, "pfc_recent_history_display_count", 20)
|
||||
recent_history_display_count = global_config.pfc.pfc_recent_history_display_count
|
||||
|
||||
if observation_info and observation_info.chat_history and len(observation_info.chat_history) > 0:
|
||||
# 获取用于生成“最近聊天记录”的实际消息片段
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ def select_nicknames_for_prompt(all_nicknames_info: Dict[str, List[Dict[str, int
|
|||
return []
|
||||
|
||||
candidates = [] # 存储 (用户名, 绰号, 次数, 权重)
|
||||
smoothing_factor = getattr(global_config, "nickname_probability_smoothing", 1.0) # 平滑因子,避免权重为0
|
||||
smoothing_factor = global_config.group_nickname.nickname_probability_smoothing
|
||||
|
||||
for user_name, nicknames in all_nicknames_info.items():
|
||||
if nicknames and isinstance(nicknames, list):
|
||||
|
|
@ -48,7 +48,7 @@ def select_nicknames_for_prompt(all_nicknames_info: Dict[str, List[Dict[str, int
|
|||
return []
|
||||
|
||||
# 确定需要选择的数量
|
||||
max_nicknames = getattr(global_config, "max_nicknames_in_prompt", 5)
|
||||
max_nicknames = global_config.group_nickname.max_nicknames_in_prompt
|
||||
num_to_select = min(max_nicknames, len(candidates))
|
||||
|
||||
try:
|
||||
|
|
|
|||
Loading…
Reference in New Issue