초기 커밋 — 협상 AI 에이전트 정본: 엔진·데모 콘솔·측정 인프라·증빙

- server/: FastAPI 협상 엔진 (5라운드, Q-Table/UCB, 페르소나 계측, :53117)
- frontend/: 데모 콘솔 (React+Tailwind → nginx, /api 프록시)
- eval/·testdata/: 지표 8종 측정 하네스 + 재현 가능 테스트셋
- results/: 측정 증빙 (지표별 result+provenance, raw 원본 동결+SHA256)
  ① 86.0 · ② 76.0 · ③ 5.99% · ⑥ p95 3.61ms · ⑦ 611만/년 · ⑧ 91/100 · ⑨ 99.71 · ⑩ 97.99
- docker-compose.yml + run.sh: backend+frontend 일괄 기동

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0112XUWF4bc3gGrEt8vsYCzy
This commit is contained in:
민헌andClaude Fable 5 committed 2026-08-31 13:09:52 +09:00
commit dfb9ad6e66
268 files changed
+164241

No files matched your search

+64
View File
@@ -0,0 +1,64 @@
"""협상 긴장도(Tension) 추정 + 페르소나 선택 (지표 ⑩).
계획서 정의:
- 협상 단계마다 0~1 백분위 환산 가능한 수치를 협상 긴장도로 정의하여 활용
- 단계별 변수를 수치화 후 수치에 따라 페르소나를 적용 — 적용된 페르소나의 정확도 측정
설계 (2026-08-28 확정):
- 실제 긴장도(사후 정의) = clip((제안가 − 목표가) / (초기제안가 − 목표가), 0, 1)
- 예측 긴장도(서버 실시간) = 단계 변수인 지표점수(ThreeSegIndicator, 정수 1~99)로부터
역산한 추정치 — 정수 양자화·스케일 의존 손실이 있어 실제값과 독립적으로 검증 가능
- 페르소나 = 예측 긴장도 3구간(저/중/고)으로 선택, profiling 활성 시 스크립트 톤에 적용
"""
import math
def clip01(v: float) -> float:
return max(0.0, min(1.0, v))
def actual_tension(initial: float, target: float, price: float) -> float:
"""실제 긴장도 정의 (사후 산출용 — 하네스/집계기가 사용하는 기준 정의)."""
if initial <= target:
raise ValueError("initial must exceed target")
return clip01((price - target) / (initial - target))
def estimate_tension(indicator_value: int, target: float, initial: float) -> float:
"""지표점수(1~99) → 긴장도 추정 (모델 변수 경유 역산).
PZ1/PZ2(80~99, 제안가 ≤ 목표가 구간) → 긴장도 0.
PZ3(1~79)는 지표 산식 79·exp(−k(P−T))의 역함수로 (P−T)를 복원해 정규화한다.
지표가 정수로 절사되어 있어 실제 긴장도와 양자화 오차가 존재한다 (독립 검증 근거).
"""
if initial <= target:
return 0.0
if indicator_value >= 80:
return 0.0
k = math.pow(10, -int(math.floor(math.log10(target))))
p_minus_t = -math.log(indicator_value / 79) / k
return clip01(p_minus_t / (initial - target))
# 페르소나 프리셋 — 예측 긴장도 3구간
PERSONAS = [
# (하한, 이름, profiling 톤 지시문)
(2 / 3, "단호한 압박형",
"Firm and assertive negotiation stance. Emphasize competition, alternatives, "
"and deadlines. Keep it professional but apply clear pressure in Korean."),
(1 / 3, "균형 협상형",
"Balanced, data-driven negotiation stance. Emphasize mutual benefit and "
"objective grounds. Professional and persuasive in Korean."),
(0.0, "우호적 마무리형",
"Warm, appreciative closing stance. The deal is close — emphasize partnership "
"and a smooth finish. Polite and collaborative in Korean."),
]
def select_persona(tension: float) -> dict:
"""예측 긴장도 → 페르소나 (저/중/고 3구간)."""
for lower_bound, name, tone in PERSONAS:
if tension >= lower_bound:
return {"name": name, "tone": tone}
return {"name": PERSONAS[-1][1], "tone": PERSONAS[-1][2]}