Files
windpacer 302183c97e feat: P&ID 연결 분석, LLM 에이전트 모드, KB 확장, MCP 서버 리팩토링
- P&ID: 연결 분석 API, Prefix 규칙 관리, 카테고리 분류, DXF 그래프 빌드
- LLM: 대화 요약, tool card 영구 보존, 시계열 차트(uPlot), 에이전트 모드
- KB: 청크 미리보기, Field Instrument Inference, 인증/Qdrant 클라이언트
- MCP: 서버 기능 확장, 파이프라인 수정, timeout 개선
- Frontend: P&ID UI, LLM UI, KB UI, OPC UA Write 탭 추가
- 설정: AGENTS.md, plant_context, README, opencode.json 업데이트
- 정리: 진단 체크리스트 문서 삭제
2026-05-21 23:36:57 +09:00

48 lines
1.4 KiB
Python

"""YAML 룰 로더 — prompts/instrument_inference.yaml을 읽고 캐싱."""
from __future__ import annotations
import os
import yaml
from functools import lru_cache
_RULES_PATH = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
"..", "..", "prompts", "instrument_inference.yaml",
)
@lru_cache(maxsize=1)
def load_rules() -> dict:
"""YAML 룰 파일 로드 (lru_cache로 1회만 로드)."""
with open(_RULES_PATH, "r", encoding="utf-8") as f:
return yaml.safe_load(f)
def get_measurement(letter: str) -> str | None:
"""첫 글자 → 측정량 반환."""
return load_rules().get("measurement", {}).get(letter)
def get_modifier(letter: str) -> dict | None:
"""수식어 글자 → role 정보 반환."""
return load_rules().get("modifiers", {}).get(letter)
def get_special_prefix(head: str) -> dict | None:
"""특수 prefix → role 정보 반환."""
return load_rules().get("special_prefixes", {}).get(head)
def get_all_measurements() -> dict:
"""측정량 전체 표 반환 (naming_convention 시트용)."""
return load_rules().get("measurement", {})
def get_all_modifiers() -> dict:
"""수식어 전체 표 반환 (naming_convention 시트용)."""
return load_rules().get("modifiers", {})
def get_all_special_prefixes() -> dict:
"""특수 prefix 전체 표 반환 (naming_convention 시트용)."""
return load_rules().get("special_prefixes", {})