Merge branch 'PFC-test' of https://github.com/Dax233/MaiMBot into PFC-test

pull/937/head
Bakadax 2025-05-08 12:36:13 +08:00
commit 5aede24af9
2 changed files with 7 additions and 3 deletions

View File

@ -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))

View File

@ -310,6 +310,7 @@ async def get_person_id(private_name: str, chat_stream: ChatStream):
)
return None # 返回 None 表示失败
async def adjust_relationship_value_nonlinear(old_value: float, raw_adjustment: float) -> float:
# 限制 old_value 范围
old_value = max(-1000, min(1000, old_value))