feat: add metadata first chatbot responses and optimize rule_book dir… - #103
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough종업식 키워드가 스케줄/행사 인식에 추가되고, 메타데이터 기반 직접 답변(연락처·졸업학점)과 신뢰도 기반 검색 답변이 도입되며, OSS 비동기 호출 경로 및 규칙책/스케줄 파싱·정렬 로직이 개선되었습니다. Changes메타데이터 기반 직접 답변 및 서비스 통합
규칙 책 및 스케줄/패턴 개선
Sequence DiagramsequenceDiagram
participant User
participant Service as chat_with_oss()
participant Meta as query_index\n(metadata_direct_answer)
participant Conf as query_index\n(confident_search_answer)
participant OSS as call_oss_async()
participant Rule as rule_book\n(generate)
User->>Service: 사용자 입력 (압축)
alt metadata_direct_answer 반환
Service->>Meta: metadata_direct_answer(query)
Meta-->>Service: {text, url} 또는 None
Service-->>User: engine: "fast" (metadata 답변)
else confident_search 반환
Service->>Conf: confident_search_answer(query)
Conf-->>Service: {text, url} 또는 None
Service-->>User: engine: "fast" (confident 검색)
else OSS 융합생성
Service->>OSS: call_oss_async(messages, max_tokens=96, timeout=45)
OSS-->>Service: fused 텍스트
alt 규칙책 폴백 필요
Service->>Rule: generate(query)
Rule-->>Service: direct 또는 fallback 텍스트
end
Service-->>User: engine: "oss" 또는 "fast" (fused/폴백)
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
LLM/OSS/service.py (1)
311-314: ⚡ Quick win의식 키워드 목록은 여기서 다시 하드코딩하지 않는 편이 좋습니다.
같은 분기 기준이 이미
LLM/OSS/modes.py에 있는데, 여기서 별도 튜플로 한 번 더 관리하고 있습니다. 이번 PR처럼 둘을 같이 수정해야 하고, 다음에 한쪽만 바뀌면 모드 판별은fast인데 이 shortcut만 안 타는 식으로 금방 어긋납니다.CEREMONY_RE나 공용 헬퍼를 재사용하는 쪽이 안전합니다.♻️ 한 가지 정리 방법
-from LLM.OSS.modes import ( +from LLM.OSS.modes import ( + CEREMONY_RE, COUNCIL_KWS, GOVERNANCE_REMOVE_RE, GOVERNANCE_TARGET_RE, GREETING_RE, RELATIVE_DATE_KEYWORDS, @@ - if any(keyword in user_text for keyword in ("종강", "졸업식", "종업식", "학위수여식")): + if "종강" in user_text or CEREMONY_RE.search(user_text): schedule_only = schedule_search(user_text, top_k=8) if schedule_only: return cache_and_return({"engine": "fast", "text": render_chatty_schedule(schedule_only, user_text)})🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@LLM/OSS/service.py` around lines 311 - 314, Replace the hardcoded ceremony keywords tuple in the conditional with the shared ceremony matcher used in modes (reuse CEREMONY_RE or the public helper from LLM/OSS/modes.py); update the check to use CEREMONY_RE.search(user_text) (or the exported helper function) so the branch that calls schedule_search(top_k=8) and returns via cache_and_return({"engine":"fast","text":render_chatty_schedule(...)}) stays identical but centralizes the keyword list, and add the necessary import for CEREMONY_RE/helper at the top of this module.tests/regression/chatbot_regression_cases.json (1)
14-19: ⚡ Quick win
종업식경로도 회귀 테스트로 묶어두는 편이 좋겠습니다.이번 PR의 핵심 변경 중 하나가
종업식오타 매핑인데, 현재 추가된 케이스는 정상 표기인졸업식만 검증합니다. 그래서LLM/OSS/modes.py,LLM/sub_model/schedule_rules.py,LLM/OSS/service.py중 한 곳에서 다시 빠져도 이 테스트로는 못 잡습니다.🧪 예시 케이스
{ "id": "schedule_commencement_25_calendar_year", "text": "25년도 졸업식 알려줘", "engine_in": ["fast"], "all_of_text_contains": ["2025-02-21"] }, + { + "id": "schedule_commencement_typo_25_calendar_year", + "text": "25년도 종업식 알려줘", + "engine_in": ["fast"], + "all_of_text_contains": ["2025-02-21"] + },🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/regression/chatbot_regression_cases.json` around lines 14 - 19, The current regression case "schedule_commencement_25_calendar_year" only tests the correct phrase "졸업식" but not the typo "종업식"; add a sibling test entry (e.g., id "schedule_commencement_25_calendar_year_typo") that mirrors the existing case but uses "종업식 알려줘" (or include both phrases in one case's inputs) with the same engine_in and all_of_text_contains ["2025-02-21"] so the regression catches the typo mapping change in LLM/OSS/modes.py, LLM/sub_model/schedule_rules.py, and LLM/OSS/service.py.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@LLM/sub_model/query_index.py`:
- Around line 340-344: The confidence gate currently allows low absolute scores
to pass if the score gap is large because it uses a logical AND; change the
logic so both conditions must be satisfied to proceed: ensure the top result's
absolute score (top_score computed from hits.iloc[0]) is at or above
CONFIDENT_SCORE_THRESHOLD AND the gap (top_score - second_score, where
second_score comes from hits.iloc[1]) is at least CONFIDENT_SCORE_GAP before
calling confident_search_answer(); otherwise return None. Update the conditional
that references top_score, second_score, CONFIDENT_SCORE_THRESHOLD, and
CONFIDENT_SCORE_GAP accordingly so both checks are required.
In `@LLM/sub_model/schedule_rules.py`:
- Around line 59-60: The current expansion adds MIDTERM/FINAL whenever "시험"/"고사"
appears even if an explicit period tag like SEMESTER_END is already present;
change the condition so MIDTERM/FINAL are added only when no explicit
academic-period tags exist (e.g., ensure
tags.isdisjoint({"SEMESTER_END","SEMESTER_START","SEMESTER_BREAK","VACATION"})
before adding). Update the check around the tags update (the block using
tags.update({"MIDTERM","FINAL"}) and the existing isdisjoint call) to first
verify absence of those explicit period tags in addition to the current checks.
---
Nitpick comments:
In `@LLM/OSS/service.py`:
- Around line 311-314: Replace the hardcoded ceremony keywords tuple in the
conditional with the shared ceremony matcher used in modes (reuse CEREMONY_RE or
the public helper from LLM/OSS/modes.py); update the check to use
CEREMONY_RE.search(user_text) (or the exported helper function) so the branch
that calls schedule_search(top_k=8) and returns via
cache_and_return({"engine":"fast","text":render_chatty_schedule(...)}) stays
identical but centralizes the keyword list, and add the necessary import for
CEREMONY_RE/helper at the top of this module.
In `@tests/regression/chatbot_regression_cases.json`:
- Around line 14-19: The current regression case
"schedule_commencement_25_calendar_year" only tests the correct phrase "졸업식" but
not the typo "종업식"; add a sibling test entry (e.g., id
"schedule_commencement_25_calendar_year_typo") that mirrors the existing case
but uses "종업식 알려줘" (or include both phrases in one case's inputs) with the same
engine_in and all_of_text_contains ["2025-02-21"] so the regression catches the
typo mapping change in LLM/OSS/modes.py, LLM/sub_model/schedule_rules.py, and
LLM/OSS/service.py.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 4626ea98-9d0e-48df-802b-c41bd84df7be
📒 Files selected for processing (8)
LLM/OSS/modes.pyLLM/OSS/service.pyLLM/patterns.pyLLM/rule_book/graph.pyLLM/sub_model/query_index.pyLLM/sub_model/schedule_index.pyLLM/sub_model/schedule_rules.pytests/regression/chatbot_regression_cases.json
관련 이슈
Close #102
🎯 배경
🔍 주요 내용
변경 요약
챗봇이 메타데이터 기반 응답을 우선하고, 시험/졸업식 관련 스케줄 처리와 OSS 호출 흐름을 개선했습니다. 정규식 버그 수정과 회귀 테스트도 추가되었습니다.
주요 변경점
주의/리스크
다음 액션