diff --git a/src/plugins/PFC/pfc_relationship.py b/src/plugins/PFC/pfc_relationship.py index fb6e96aa..3ebc0c1b 100644 --- a/src/plugins/PFC/pfc_relationship.py +++ b/src/plugins/PFC/pfc_relationship.py @@ -139,7 +139,9 @@ class PfcRelationshipUpdater: raw_adjustment_val = self.REL_INCREMENTAL_DEFAULT_CHANGE else: raw_adjustment_val = float(raw_adjustment) - raw_adjustment_val = max(-self.REL_INCREMENTAL_MAX_CHANGE, min(self.REL_INCREMENTAL_MAX_CHANGE, raw_adjustment_val)) + raw_adjustment_val = max( + -self.REL_INCREMENTAL_MAX_CHANGE, min(self.REL_INCREMENTAL_MAX_CHANGE, raw_adjustment_val) + ) except Exception as e: logger.error(f"[私聊][{self.private_name}] 增量关系评估LLM调用或解析失败: {e}") @@ -222,11 +224,12 @@ class PfcRelationshipUpdater: raw_adjustment_val = self.REL_FINAL_DEFAULT_CHANGE else: raw_adjustment_val = float(raw_adjustment) - raw_adjustment_val = max(-self.REL_INCREMENTAL_MAX_CHANGE, min(self.REL_INCREMENTAL_MAX_CHANGE, raw_adjustment_val)) + raw_adjustment_val = max( + -self.REL_INCREMENTAL_MAX_CHANGE, min(self.REL_INCREMENTAL_MAX_CHANGE, raw_adjustment_val) + ) except Exception as e: logger.error(f"[私聊][{self.private_name}] 最终关系评估LLM调用或解析失败: {e}") - adjustment_val = await adjust_relationship_value_nonlinear(current_relationship_value, raw_adjustment_val) new_relationship_value = max(-1000.0, min(1000.0, current_relationship_value + adjustment_val)) diff --git a/src/plugins/PFC/pfc_utils.py b/src/plugins/PFC/pfc_utils.py index 7d0f6695..e4cc39e2 100644 --- a/src/plugins/PFC/pfc_utils.py +++ b/src/plugins/PFC/pfc_utils.py @@ -310,6 +310,7 @@ async def get_person_id(private_name: str, chat_stream: ChatStream): ) return None # 返回 None 表示失败 + async def adjust_relationship_value_nonlinear(self, old_value: float, raw_adjustment: float) -> float: # 限制 old_value 范围 old_value = max(-1000, min(1000, old_value))