Phase P~S 전체 작업물: 검증 스크립트, 블록 템플릿, 설계 문서, 코드 수정
포함 내용: - Phase P/Q/R/S 설계 문서 (IMPROVEMENT-PHASE-*.md) - 영역별 검증 스크립트 (scripts/verify_*.py, test_*.py) - 블록 템플릿 추가 (cards, emphasis 변형) - 코드 수정: block_search, content_editor, design_director, slide_measurer - catalog.yaml 블록 목록 업데이트 - CLAUDE.md, PROGRESS.md, README.md 업데이트 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -175,6 +175,38 @@ def search_blocks_for_topics(
|
||||
return _format_for_prompt(sorted_blocks)
|
||||
|
||||
|
||||
def search_candidates_per_topic(
|
||||
topics: list[dict],
|
||||
top_k: int = 2,
|
||||
) -> dict[int, list[dict]]:
|
||||
"""Phase P: 각 topic별 FAISS 상위 후보를 반환한다.
|
||||
|
||||
Args:
|
||||
topics: 1단계 꼭지 분석 결과
|
||||
top_k: topic당 반환할 후보 수
|
||||
|
||||
Returns:
|
||||
{topic_id: [블록 메타데이터 목록]} — 각 topic별 상위 top_k개
|
||||
"""
|
||||
if not _ensure_loaded():
|
||||
return {}
|
||||
|
||||
result: dict[int, list[dict]] = {}
|
||||
for topic in topics:
|
||||
tid = topic.get("id")
|
||||
if tid is None:
|
||||
continue
|
||||
query = _build_query(topic)
|
||||
candidates = search_blocks(query, top_k=top_k + 2) # 여유분 확보 (중복 제거용)
|
||||
result[tid] = candidates[:top_k]
|
||||
|
||||
logger.info(
|
||||
f"[Phase P] topic별 FAISS 후보: "
|
||||
+ ", ".join(f"t{tid}={[c['id'] for c in cs]}" for tid, cs in result.items())
|
||||
)
|
||||
return result
|
||||
|
||||
|
||||
def _build_query(topic: dict) -> str:
|
||||
"""꼭지 정보에서 검색 쿼리를 생성한다. (Phase M: 역할+관계+표현 추가)"""
|
||||
parts = [
|
||||
|
||||
Reference in New Issue
Block a user