초기 커밋 — 협상 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:
commit
dfb9ad6e66
268 files changed
+164241
No files matched your search
@@ -0,0 +1,82 @@
|
||||
#!/usr/bin/env python3
|
||||
"""⑦ 협상 데이터 수집 — 서버 계약 데이터화(contracts.jsonl) 집계기.
|
||||
|
||||
계획서: "협상 챗봇으로 이루어진 계약 데이터화" — 목표 10,000건/년.
|
||||
|
||||
집계 관점 2가지를 병기한다:
|
||||
1. 누적 수집: 측정 구간의 계약 레코드 건수 + 구간 일수 기준 연환산
|
||||
2. 처리량(capacity): 실측 처리 속도 기준 연간 처리 가능 건수
|
||||
(데모 환경은 운용 트래픽이 없으므로, 파이프라인의 수집 능력을 실증하는 관점)
|
||||
|
||||
사용:
|
||||
python aggregate.py # 전체 로그
|
||||
python aggregate.py --since 2026-08-29 # 특정 시점 이후
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import json
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
|
||||
HERE = Path(__file__).parent
|
||||
DEFAULT_LOG = HERE.parent.parent / "server" / "data" / "contracts.jsonl"
|
||||
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--log", default=str(DEFAULT_LOG))
|
||||
ap.add_argument("--since", default=None)
|
||||
ap.add_argument("--until", default=None)
|
||||
ap.add_argument("--target", type=float, default=10000.0, help="목표 건/년")
|
||||
args = ap.parse_args()
|
||||
|
||||
rows = []
|
||||
for line in Path(args.log).read_text(encoding="utf-8").splitlines():
|
||||
if not line.strip():
|
||||
continue
|
||||
r = json.loads(line)
|
||||
if args.since and r["ts"] < args.since:
|
||||
continue
|
||||
if args.until and r["ts"] > args.until:
|
||||
continue
|
||||
rows.append(r)
|
||||
|
||||
n = len(rows)
|
||||
out = {"측정대상": "협상 챗봇 계약 데이터화 레코드 (서버 contracts.jsonl)",
|
||||
"표본": {"log": args.log, "since": args.since, "until": args.until, "n": n}}
|
||||
|
||||
if n >= 2:
|
||||
ts = sorted(datetime.fromisoformat(r["ts"]) for r in rows)
|
||||
span_sec = max((ts[-1] - ts[0]).total_seconds(), 1.0)
|
||||
span_days = span_sec / 86400
|
||||
# 1) 누적 관점: 구간 연환산
|
||||
out["누적수집"] = {
|
||||
"건수": n, "구간_일수": round(span_days, 4),
|
||||
"연환산_건": round(n / span_days * 365) if span_days > 0 else None,
|
||||
}
|
||||
# 2) 처리량 관점: 계약 1건당 평균 간격 → 연간 처리 가능량
|
||||
out["처리량"] = {
|
||||
"건당_평균간격_초": round(span_sec / (n - 1), 3),
|
||||
"연간_처리가능_건": round((n - 1) / span_sec * 86400 * 365),
|
||||
}
|
||||
rq = {}
|
||||
red = [r["reduction_pct"] for r in rows if r.get("reduction_pct") is not None]
|
||||
for r in rows:
|
||||
rq[r.get("rq_type")] = rq.get(r.get("rq_type"), 0) + 1
|
||||
out["구성"] = {"rq_type": rq,
|
||||
"평균_감액률_pct": round(sum(red) / len(red), 3) if red else None}
|
||||
|
||||
out["target_per_year"] = args.target
|
||||
out["판정기준"] = "연간 수집(또는 처리 가능) 건수 ≥ 목표 — 표본 100건 미만은 판정 보류"
|
||||
yearly = (out.get("누적수집") or {}).get("연환산_건")
|
||||
if n < 100:
|
||||
out["verdict"] = "판정보류(표본 부족)"
|
||||
else:
|
||||
out["verdict"] = "PASS" if (yearly is not None and yearly >= args.target) else "FAIL"
|
||||
(HERE / "result.json").write_text(json.dumps(out, ensure_ascii=False, indent=2),
|
||||
encoding="utf-8")
|
||||
print(json.dumps(out, ensure_ascii=False, indent=1))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in new issue
Block a user