o2o-site-AEO/backend/services/prompts/copy.py
Mina Choi 6784e59ca5 최초 커밋 — 기존 코드 전체 + 문서 체계 신설
git 저장소가 없어 히스토리·협업 기반이 아예 없던 상태를 연다.
함께 문서를 재편했다. 그동안 문서가 있어도 "이 제품이 뭘 푸는가"와
"어떻게 도는가"를 담은 문서가 없어서, 목표 문장이 backend/frontend
README 두 곳에 복붙돼 있었다 — 상위 문서가 없어 아래로 샌 것이다.

신설
  README.md               레포 진입점 + 문서 지도 + 문서 규칙 4가지
  AGENTS.md               에이전트·신규 합류자용 함정 목록과 규약
                          (CLAUDE.md 는 여기로 걸린 심볼릭 링크)
  docs/PRODUCT.md         제품 정의 — 문제·사용자·원칙·**non-goals**·성공 기준
  docs/ARCHITECTURE.md    payload 경계·발행 파이프라인·서빙 결정·앱 분리 설계

이동
  backend/docs/DECISIONS.md → docs/DECISIONS.md
    백엔드만의 결정이 아니다. 게다가 코드 주석 ~25곳이 이미
    `docs/DECISIONS.md` 로 적고 있어 레포 루트 기준으로는 그게 맞다.

갱신
  docs/DEPLOY.md          서빙 결정 반영 — nginx 정적 서빙이 지금 경로(3절),
                          Azure 는 나중에 켤 때(4절)로 분리
  docs/ARCHITECTURE.md    사이트 = 한 장(2026-08-31) 구조 반영
  docs/COLLECTION_SEO_AEO_FLOW.md
                          robots.txt·sitemap.xml 은 오리진 루트에만 굽는다는 점 명시
  frontend/site/scripts/prerender.ts
                          헤더 주석의 렌더 보고서 경로가 실제(422줄)와 달라 수정

.gitignore
  ★ CLAUDE.md 를 더 이상 무시하지 않는다. 에이전트 지침은 팀과 모든
    에이전트가 공유하는 규약이라 커밋해야 한다 — 무시하면 클론한 사람이
    "배포 후 republish_all.py 필수" 같은 함정을 전달받지 못한다.
    개인용 오버라이드는 ~/.claude/CLAUDE.md 에 둔다.
2026-08-31 13:57:59 +09:00

83 lines
2.5 KiB
Python

"""Prompt contract for grounded homepage copy."""
from typing import Optional, Protocol, Sequence
from common.enums import PlaceCategory
class FactLike(Protocol):
key: str
label: str
value: str
unit: Optional[str]
RESPONSE_SCHEMA = {
"type": "object",
"properties": {
"intro": {"type": "string"},
"intro_fact_keys": {"type": "array", "items": {"type": "string"}},
"meta_description": {"type": "string"},
"faqs": {
"type": "array",
"items": {
"type": "object",
"properties": {
"question": {"type": "string"},
"answer": {"type": "string"},
"fact_keys": {"type": "array", "items": {"type": "string"}},
},
"required": ["question", "answer", "fact_keys"],
},
},
},
"required": ["intro", "intro_fact_keys", "meta_description", "faqs"],
}
_CATEGORY_LABEL = {
PlaceCategory.LODGING: "숙박업소",
PlaceCategory.CAFE: "카페",
PlaceCategory.RESTAURANT: "음식점",
PlaceCategory.TOUR_ACTIVITY: "관광·체험 시설",
}
def _fact_lines(facts: Sequence[FactLike]) -> str:
return "\n".join(
f"- {fact.key} ({fact.label}) = {fact.value}" + (f" {fact.unit}" if fact.unit else "")
for fact in facts
)
def build_prompt(
place_name: str,
category: PlaceCategory,
facts: Sequence[FactLike],
max_faqs: int,
unit_facts: Optional[Sequence[FactLike]] = None,
) -> str:
sections = [
f"'{place_name}'({_CATEGORY_LABEL.get(category, '사업장')})의 공식 홈페이지 문구를 작성한다.",
"",
"확인된 사업장 사실:",
_fact_lines(facts) if facts else "- 없음",
]
if unit_facts:
sections.extend(["", "확인된 객실·메뉴 사실:", _fact_lines(unit_facts)])
sections.extend([
"",
"출력:",
"- intro: 소개문 100~250자",
"- intro_fact_keys: 소개문의 근거 key",
"- meta_description: 검색 요약 50~120자",
f"- faqs: 최대 {max_faqs}개, 각 항목에 근거 fact_keys 포함",
"",
"규칙:",
"- 위 사실에 없는 숫자·시설·지역 정보를 지어내지 마라.",
"- false·불가·없음 값을 가능하다고 표현하지 않는다.",
"- 홍보성·평가성 표현을 쓰지 않는다.",
"- 근거 없는 FAQ는 만들지 않는다.",
"- 한국어 존댓말을 사용한다.",
])
return "\n".join(sections)