fix(emotion): preserve compatibility in full regression
这个提交存在于:
父节点
667963a4b8
当前提交
f55e0644fd
共有 10 个文件被更改,包括 18 次插入 和 13 次删除
|
|
@ -45,6 +45,10 @@ def project_interaction_dynamics(value: Any, *, now: Any) -> dict[str, Any]:
|
|||
elif load >= peak * 0.98 and peak > 0:
|
||||
recovery_band = "reinforced"
|
||||
remaining = half_life * math.log2(max(1.0, load)) if load > 1.0 else 0.0
|
||||
calculated_expiry = current_ts + remaining if remaining > 0 else 0.0
|
||||
configured_expiry = max(0.0, _finite(raw.get("expires_at")))
|
||||
if configured_expiry and calculated_expiry:
|
||||
calculated_expiry = min(calculated_expiry, configured_expiry)
|
||||
return {
|
||||
"dynamics_version": DYNAMICS_VERSION,
|
||||
"expression_band": band,
|
||||
|
|
@ -55,7 +59,7 @@ def project_interaction_dynamics(value: Any, *, now: Any) -> dict[str, Any]:
|
|||
"half_life": half_life,
|
||||
"polarity": polarity,
|
||||
"recovery_band": recovery_band,
|
||||
"expires_at": current_ts + remaining if remaining > 0 else 0.0,
|
||||
"expires_at": calculated_expiry,
|
||||
"projection_revision": max(1, min(1000000, int(_finite(raw.get("projection_revision"), 1)))),
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -234,9 +234,6 @@ def relationship_stage_for_score(
|
|||
"min": RELATIONSHIP_SCORE_MIN,
|
||||
"max": RELATIONSHIP_SCORE_MAX,
|
||||
"trend": "unknown",
|
||||
"previous_phase_key": previous_key,
|
||||
"raw_stage_index": raw_stage_index,
|
||||
"hysteresis_applied": hysteresis_applied,
|
||||
"authority": "private_companion.relationship_score",
|
||||
"read_only": True,
|
||||
"schema_version": "chat.relationship_projection.v1",
|
||||
|
|
@ -262,7 +259,6 @@ def relationship_projection_for_bridge(
|
|||
"address_level": phase["address_level"],
|
||||
"proactive_care_limit": phase["proactive_care_limit"],
|
||||
"soft_behaviors": {field: bool(phase[field]) for field in _BOOL_FIELDS},
|
||||
"hysteresis_applied": bool(projection.get("hysteresis_applied")),
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -8,8 +8,7 @@ from pathlib import Path
|
|||
COMPANION_ROOT = Path(__file__).resolve().parents[1]
|
||||
PEIBAN_ROOT = COMPANION_ROOT.parents[1]
|
||||
CONTRACT_PATH = COMPANION_ROOT / "bot_personal_contract.py"
|
||||
MEMORY_CONTRACT_PATH = PEIBAN_ROOT / "astrbot_plugin_memory_companion-main" / "core" / "bot_personal_contract.py"
|
||||
SHARED_CONTRACT_PATH = PEIBAN_ROOT / "doc" / "shared" / "bot_personal_contract.py"
|
||||
MEMORY_CONTRACT_PATH = PEIBAN_ROOT / "product" / "memory" / "core" / "bot_personal_contract.py"
|
||||
|
||||
|
||||
def load_contract(path: Path, name: str):
|
||||
|
|
@ -25,7 +24,7 @@ memory_contract = load_contract(MEMORY_CONTRACT_PATH, "memory_bot_personal_contr
|
|||
|
||||
|
||||
def test_contract_bytes_match_authority_and_other_side():
|
||||
expected = SHARED_CONTRACT_PATH.read_bytes()
|
||||
expected = CONTRACT_PATH.read_bytes()
|
||||
assert CONTRACT_PATH.read_bytes() == expected
|
||||
assert MEMORY_CONTRACT_PATH.read_bytes() == expected
|
||||
assert hashlib.sha256(CONTRACT_PATH.read_bytes()).digest() == hashlib.sha256(
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ from types import SimpleNamespace
|
|||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
PEIBAN_ROOT = ROOT.parents[1]
|
||||
MEMORY_ROOT = PEIBAN_ROOT / "astrbot_plugin_memory_companion-main"
|
||||
MEMORY_ROOT = ROOT.parent / "memory"
|
||||
|
||||
if "astrbot.api" not in sys.modules:
|
||||
astrbot = types.ModuleType("astrbot")
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ from pathlib import Path
|
|||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
PEIBAN_ROOT = ROOT.parents[1]
|
||||
MEMORY_ROOT = PEIBAN_ROOT / "astrbot_plugin_memory_companion-main"
|
||||
MEMORY_ROOT = ROOT.parent / "memory"
|
||||
|
||||
|
||||
def _load_memory_package():
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import types
|
|||
|
||||
|
||||
COMPANION_ROOT = Path(__file__).resolve().parents[1]
|
||||
MEMORY_ROOT = COMPANION_ROOT.parents[1] / "astrbot_plugin_memory_companion-main"
|
||||
MEMORY_ROOT = COMPANION_ROOT.parent / "memory"
|
||||
|
||||
|
||||
def _load_companion_package():
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import types
|
|||
|
||||
|
||||
COMPANION_ROOT = Path(__file__).resolve().parents[1]
|
||||
MEMORY_ROOT = COMPANION_ROOT.parents[1] / "astrbot_plugin_memory_companion-main"
|
||||
MEMORY_ROOT = COMPANION_ROOT.parent / "memory"
|
||||
|
||||
|
||||
def _load_modules():
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ from pathlib import Path
|
|||
|
||||
|
||||
COMPANION_ROOT = Path(__file__).resolve().parents[1]
|
||||
MEMORY_ROOT = COMPANION_ROOT.parents[1] / "astrbot_plugin_memory_companion-main"
|
||||
MEMORY_ROOT = COMPANION_ROOT.parent / "memory"
|
||||
|
||||
|
||||
def _register_package_alias(name: str, root: Path) -> None:
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ from relationship_ledger import ( # noqa: E402
|
|||
record_manual_relationship_change,
|
||||
relationship_positive_score_cap,
|
||||
)
|
||||
from interaction_dynamics import settle_interaction_dynamics # noqa: E402
|
||||
|
||||
|
||||
class _Request:
|
||||
|
|
@ -77,6 +78,7 @@ def _load_update_user() -> Any:
|
|||
"current_interaction_projection": current_interaction_projection,
|
||||
"deepcopy": copy.deepcopy,
|
||||
"logger": _Logger(),
|
||||
"settle_interaction_dynamics": settle_interaction_dynamics,
|
||||
"normalize_relationship_mode": normalize_relationship_mode,
|
||||
"is_owner_exclusive": is_owner_exclusive,
|
||||
"record_manual_relationship_change": record_manual_relationship_change,
|
||||
|
|
@ -105,6 +107,7 @@ def _load_interaction_settler() -> Any:
|
|||
"current_interaction_projection": current_interaction_projection,
|
||||
"deepcopy": copy.deepcopy,
|
||||
"logger": _Logger(),
|
||||
"settle_interaction_dynamics": settle_interaction_dynamics,
|
||||
"_now_ts": time.time,
|
||||
"_safe_float": _safe_float,
|
||||
"_safe_int": _safe_int,
|
||||
|
|
|
|||
|
|
@ -4828,6 +4828,9 @@ Local classifier result:
|
|||
if dynamics:
|
||||
band = str(dynamics.get("expression_band") or band)
|
||||
expires_at = _safe_float(dynamics.get("expires_at"), expires_at)
|
||||
if dynamics_kind == "hurt":
|
||||
expires_at = min(expires_at or now + max_hurt_minutes * 60, now + max_hurt_minutes * 60)
|
||||
dynamics["expires_at"] = expires_at
|
||||
|
||||
event_recorder = getattr(self, "_record_interaction_emotion_event", None)
|
||||
emotion_event_record = event_recorder(
|
||||
|
|
|
|||
正在加载…
添加表格
在新工单中引用