- 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
46 lines
1.5 KiB
Python
46 lines
1.5 KiB
Python
"""협상 카드 스크립트 Repository — JSON 파일 기반 (DB 없음)."""
|
|
|
|
import json
|
|
from pathlib import Path
|
|
from typing import Dict, List, Optional
|
|
|
|
from common.paths import RESOURCES_DIR
|
|
|
|
|
|
class CardScriptRepository:
|
|
"""협상 카드 스크립트를 resources/cards/nego_card.json 에서 관리한다."""
|
|
|
|
def __init__(self, json_file_path: Optional[str] = None):
|
|
if json_file_path is None:
|
|
json_file_path = RESOURCES_DIR / "cards" / "nego_card.json"
|
|
self.json_file_path = Path(json_file_path)
|
|
self._ensure_file_exists()
|
|
|
|
def _ensure_file_exists(self):
|
|
if not self.json_file_path.exists():
|
|
self.json_file_path.parent.mkdir(parents=True, exist_ok=True)
|
|
self._save_to_file({"cards": []})
|
|
|
|
def _load_from_file(self) -> Dict:
|
|
with open(self.json_file_path, "r", encoding="utf-8") as f:
|
|
return json.load(f)
|
|
|
|
def _save_to_file(self, data: Dict):
|
|
with open(self.json_file_path, "w", encoding="utf-8") as f:
|
|
json.dump(data, f, ensure_ascii=False, indent=2)
|
|
|
|
def find_all(self) -> List[Dict]:
|
|
return self._load_from_file().get("cards", [])
|
|
|
|
def find_by_id(self, card_id: str) -> Optional[Dict]:
|
|
for card in self.find_all():
|
|
if card.get("card_id") == card_id:
|
|
return card
|
|
return None
|
|
|
|
def exists(self, card_id: str) -> bool:
|
|
return self.find_by_id(card_id) is not None
|
|
|
|
def count(self) -> int:
|
|
return len(self.find_all())
|