초기 커밋 — 협상 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
Whitespace-only changes.
@@ -0,0 +1,13 @@
|
||||
"""공용 Enum 정의."""
|
||||
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class IndicatorRangeEnum(str, Enum):
|
||||
PZ1 = "PZ1"
|
||||
PZ2 = "PZ2"
|
||||
PZ3 = "PZ3"
|
||||
|
||||
|
||||
class IndicatorType(str, Enum):
|
||||
PERCENT_DETAIL = "PERCENT_DETAIL"
|
||||
@@ -0,0 +1,25 @@
|
||||
"""로깅 설정 — KST 타임스탬프, 파일 회전 + 콘솔."""
|
||||
|
||||
import logging
|
||||
from datetime import datetime, timezone, timedelta
|
||||
from logging.handlers import RotatingFileHandler
|
||||
|
||||
from common.paths import LOGS_DIR
|
||||
|
||||
|
||||
def _kst_converter(*args):
|
||||
return datetime.now(timezone(timedelta(hours=9))).timetuple()
|
||||
|
||||
|
||||
def setup_logging(level: int = logging.INFO) -> None:
|
||||
LOGS_DIR.mkdir(parents=True, exist_ok=True)
|
||||
logging.Formatter.converter = _kst_converter
|
||||
logging.basicConfig(
|
||||
level=level,
|
||||
format="[%(asctime)s] [%(levelname)s] %(name)s: %(message)s",
|
||||
handlers=[
|
||||
RotatingFileHandler(LOGS_DIR / "server.log", maxBytes=10 * 1024 * 1024,
|
||||
backupCount=5, encoding="utf-8"),
|
||||
logging.StreamHandler(),
|
||||
],
|
||||
)
|
||||
@@ -0,0 +1,14 @@
|
||||
"""서버 루트 기준 경로 정의."""
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
SERVER_ROOT = Path(__file__).resolve().parents[1]
|
||||
RESOURCES_DIR = SERVER_ROOT / "resources"
|
||||
DATA_DIR = SERVER_ROOT / "data"
|
||||
LOGS_DIR = SERVER_ROOT / "logs"
|
||||
|
||||
|
||||
def resolve_data_path(path_str: str) -> Path:
|
||||
"""config 의 상대경로를 서버 루트 기준 절대경로로 변환한다."""
|
||||
p = Path(path_str)
|
||||
return p if p.is_absolute() else SERVER_ROOT / p
|
||||
@@ -0,0 +1,49 @@
|
||||
"""스크립트 템플릿 치환 유틸.
|
||||
|
||||
기능정의서 규칙: 값이 없는 변수가 포함된 문장은 Hidden 처리(문장 제거)한다.
|
||||
"""
|
||||
|
||||
import logging
|
||||
import re
|
||||
from typing import Any, Dict
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# 미치환 플레이스홀더 탐지: {internet_min_price} 등
|
||||
_PLACEHOLDER_RE = re.compile(r"\{[A-Za-z_][A-Za-z0-9_]*\}")
|
||||
|
||||
|
||||
class _SafeDict(dict):
|
||||
"""format_map용 — 컨텍스트에 없는 키는 {키} 형태로 남긴다 (이후 문장 Hidden 처리)."""
|
||||
|
||||
def __missing__(self, key):
|
||||
return "{" + key + "}"
|
||||
|
||||
|
||||
def safe_format(template: str, context: Dict[str, Any]) -> str:
|
||||
"""플레이스홀더 치환. 알 수 없는 키는 남겨두고 나머지는 정상 치환한다."""
|
||||
try:
|
||||
return template.format_map(_SafeDict(context))
|
||||
except Exception:
|
||||
return template
|
||||
|
||||
|
||||
def hide_unresolved_lines(text: str, source: str = "") -> str:
|
||||
"""미치환 {변수}가 남은 문장을 제거하고 경고를 남긴다."""
|
||||
if "{" not in text:
|
||||
return text
|
||||
kept = []
|
||||
for line in text.split("\n"):
|
||||
unresolved = _PLACEHOLDER_RE.findall(line)
|
||||
if unresolved:
|
||||
logger.warning(
|
||||
f"[textutil] 미치환 변수 {unresolved} — 문장 숨김 ({source}): {line.strip()[:60]}")
|
||||
else:
|
||||
kept.append(line)
|
||||
result = "\n".join(kept)
|
||||
return re.sub(r"\n{3,}", "\n\n", result).strip("\n")
|
||||
|
||||
|
||||
def extract_placeholders(text: str) -> set:
|
||||
"""텍스트에 포함된 {변수} 이름 집합을 반환한다."""
|
||||
return {m[1:-1] for m in _PLACEHOLDER_RE.findall(text)}
|
||||
Reference in new issue
Block a user