개선관리 요구사항과 Google 로그인을 완료
This commit is contained in:
parent
cc0a15b7c6
commit
2a39636163
112 changed files with 10166 additions and 527 deletions
|
|
@ -8,7 +8,7 @@ from __future__ import annotations
|
|||
|
||||
from enum import Enum
|
||||
import logging
|
||||
from typing import Optional
|
||||
from typing import Any, Optional
|
||||
|
||||
from . import db, session_persistence
|
||||
from .deps import Principal
|
||||
|
|
@ -27,6 +27,28 @@ _LIVE_COACH_RECHARGE_MIN_OPENNESS_GAIN = 0.01
|
|||
_LIVE_COACH_PACING_RECHARGE_EVERY_TURNS = 6
|
||||
|
||||
|
||||
def _role_mask_evaluation_value(value: Any, sess: InProcSession) -> Any:
|
||||
"""Role-tokenize evaluator text before normalized rows or cache can persist it."""
|
||||
|
||||
if isinstance(value, str):
|
||||
return guardrail.mask_role_identities(
|
||||
value,
|
||||
counselor_identity=sess.learner_label,
|
||||
client_identity=sess.persona.display_name,
|
||||
synthetic_generated=True,
|
||||
).text_masked
|
||||
if isinstance(value, dict):
|
||||
return {
|
||||
key: _role_mask_evaluation_value(child, sess)
|
||||
for key, child in value.items()
|
||||
}
|
||||
if isinstance(value, list):
|
||||
return [_role_mask_evaluation_value(child, sess) for child in value]
|
||||
if isinstance(value, tuple):
|
||||
return [_role_mask_evaluation_value(child, sess) for child in value]
|
||||
return value
|
||||
|
||||
|
||||
class SessionAccessError(str, Enum):
|
||||
NOT_FOUND = "not_found"
|
||||
FORBIDDEN = "forbidden"
|
||||
|
|
@ -114,8 +136,13 @@ async def record_completed_turn(
|
|||
stage=stage_label(ctx.state_after.stage),
|
||||
text=ctx.learner_text_raw,
|
||||
text_masked=ctx.learner_text_masked,
|
||||
evaluation=result.evaluation,
|
||||
evaluation=_role_mask_evaluation_value(result.evaluation, sess),
|
||||
)
|
||||
if counselor_turn is not None:
|
||||
learner_turn.evaluation = _role_mask_evaluation_value(
|
||||
learner_turn.evaluation,
|
||||
sess,
|
||||
)
|
||||
await append_completed_turn(
|
||||
sess,
|
||||
learner_turn,
|
||||
|
|
@ -125,7 +152,12 @@ async def record_completed_turn(
|
|||
# result.client_reply는 출력 가드레일을 통과한 합성 내담자 발화다.
|
||||
# 입력용의 광범위한 성씨 휴리스틱을 다시 적용하면 "모르겠는데요" 같은
|
||||
# 일반 용언이 [NAME]으로 오탐되어 저장·재개 화면에 누출된다.
|
||||
client_mask = guardrail.mask_synthetic_generated_pii(result.client_reply)
|
||||
client_mask = guardrail.mask_role_identities(
|
||||
result.client_reply,
|
||||
counselor_identity=sess.learner_label,
|
||||
client_identity=sess.persona.display_name,
|
||||
synthetic_generated=True,
|
||||
)
|
||||
await append_completed_turn(
|
||||
sess,
|
||||
TurnRecord(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue