Jev 기반 내담자 감정 상태와 응답 일관성 개선
This commit is contained in:
parent
77f8421818
commit
8344bc2ad2
23 changed files with 3384 additions and 25 deletions
|
|
@ -15,6 +15,7 @@ MASTERPLAN §0/§2.2 + MEMORY_KNOWLEDGE_PERSONA_DESIGN §1.1·P2:
|
|||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass, field, replace
|
||||
import math
|
||||
from typing import Optional
|
||||
|
||||
from ..taxonomy import Stage # 단계 라벨 단일 정의 = taxonomy.Stage; 이 모듈은 전이 로직만 소유.
|
||||
|
|
@ -134,6 +135,22 @@ def _clamp01(x: float) -> float:
|
|||
return max(0.0, min(1.0, x))
|
||||
|
||||
|
||||
def _finite_affect_state(value: object) -> dict[str, float]:
|
||||
"""이전 snapshot의 유한 정서 수치만 회기 시작 상태로 복원한다."""
|
||||
if not isinstance(value, dict):
|
||||
return {}
|
||||
restored: dict[str, float] = {}
|
||||
for key, raw in value.items():
|
||||
if (
|
||||
isinstance(key, str)
|
||||
and not isinstance(raw, bool)
|
||||
and isinstance(raw, (int, float))
|
||||
and math.isfinite(raw)
|
||||
):
|
||||
restored[key] = float(raw)
|
||||
return restored
|
||||
|
||||
|
||||
def compute_effective_openness(
|
||||
*,
|
||||
stage: Stage,
|
||||
|
|
@ -267,6 +284,7 @@ def init_state(
|
|||
rapport_credit = 0.0
|
||||
ideation_baseline = clamp_ideation_stage(params.ideation_baseline)
|
||||
ideation_stage = ideation_baseline
|
||||
affect_state: dict[str, float] = {}
|
||||
|
||||
if carry:
|
||||
rapport_credit = float(carry.get("rapport_credit", 0.0)) * 0.7 # P2 이월
|
||||
|
|
@ -277,6 +295,7 @@ def init_state(
|
|||
int(carry.get("ideation_stage", ideation_baseline))
|
||||
)
|
||||
ideation_stage = max(carried_ideation, ideation_baseline)
|
||||
affect_state = _finite_affect_state(carry.get("affect"))
|
||||
|
||||
eff = compute_effective_openness(
|
||||
stage=stage,
|
||||
|
|
@ -293,7 +312,7 @@ def init_state(
|
|||
resistance=resistance,
|
||||
ideation_stage=ideation_stage,
|
||||
turns_in_stage=0,
|
||||
affect_state={},
|
||||
affect_state=affect_state,
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue