refactor: chatbot const values commom logic change - #98
Conversation
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough정규식 패턴 정의를 중앙 집중식 Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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 38 minutes and 17 seconds.Comment |
|
@coderabbitai 해당 pr에 대한 리뷰 부탁합니다. |
|
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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/patterns.py`:
- Around line 28-29: The environment-driven regex in STAFF_URL_PATTERN uses
settings.staff_url_pattern directly and can raise re.error at import time;
update initialization to validate and compile settings.staff_url_pattern inside
a try/except (or use re.compile with fallback) and fall back to
STAFF_DEFAULT_URL_PATTERN if compilation fails, logging or warning the bad
pattern; apply the same safe-compile+fallback approach to the other occurrence
referenced at line 64 so imports never raise on invalid env regexes and
STAFF_URL_PATTERN remains a safe string/compiled pattern.
- Line 45: DEPT_CONTACT_INTENT_PATTERN currently allows the single token "과",
causing false positives; update the regex to disallow a bare "과" by replacing it
with more specific tokens or require a Korean-word prefix (e.g. use a pattern
that matches '[가-힣]+과' or explicit tokens like '학과|학부|전공' instead of plain '과')
so only department-like forms trigger the intent; modify the constant
DEPT_CONTACT_INTENT_PATTERN accordingly to include these stricter alternatives
and keep the existing '담당자\s*연락처' branch.
In `@LLM/sub_model/schedule_index.py`:
- Around line 134-135: 정규화가 빠져 동일 매칭에 실패하는 문제이므로 입력 q를 한 번 정규화한 변수로 재사용하도록
변경하세요: _looks_like_schedule_query에서 q를 (q or "")로 받지 말고, q_normalized = (q or
"").strip().lower() 및 내부 연속 공백을 단일 공백으로 축약하고 불필요한 구두점/특수문자를 제거하는 등 노말라이즈를 수행한 뒤
any(k in q_normalized for k in SCHEDULE_INTENT_HINTS)을 사용해 검사하도록 수정하고, 동일한 정규화
로직을 195번의 유사 검사(해당 함수/조건 표현식)에도 적용해 중복 정규화와 None 안전성을 확보하세요.
🪄 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: 9b3d7fc3-f25a-4650-9dc6-f5fe4ead27b2
📒 Files selected for processing (5)
LLM/OSS/formatter.pyLLM/patterns.pyLLM/sub_model/query_index.pyLLM/sub_model/schedule_index.pyLLM/sub_model/schedule_rules.py
| def _looks_like_schedule_query(q): | ||
| return any(k in (q or "") for k in INTENT_HINTS) | ||
| return any(k in (q or "") for k in SCHEDULE_INTENT_HINTS) |
There was a problem hiding this comment.
질의 공백 변형에서 의도/태그 탐지가 누락될 수 있습니다.
Line 134, Line 195은 원문 문자열 그대로 포함 매칭을 수행합니다. "이번 주", "다음 달", "수강 정정" 같은 입력에서 탐지 실패 가능성이 있습니다. 질의를 한 번 정규화해서 재사용하는 쪽이 안전합니다.
수정 예시
def _looks_like_schedule_query(q):
- return any(k in (q or "") for k in SCHEDULE_INTENT_HINTS)
+ source = re.sub(r"\s+", "", (q or ""))
+ return any(k in source for k in SCHEDULE_INTENT_HINTS)
@@
- tag_need = tags_for_query(query)
+ tag_need = tags_for_query(re.sub(r"\s+", "", (query or "")))Also applies to: 195-195
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@LLM/sub_model/schedule_index.py` around lines 134 - 135, 정규화가 빠져 동일 매칭에 실패하는
문제이므로 입력 q를 한 번 정규화한 변수로 재사용하도록 변경하세요: _looks_like_schedule_query에서 q를 (q or
"")로 받지 말고, q_normalized = (q or "").strip().lower() 및 내부 연속 공백을 단일 공백으로 축약하고
불필요한 구두점/특수문자를 제거하는 등 노말라이즈를 수행한 뒤 any(k in q_normalized for k in
SCHEDULE_INTENT_HINTS)을 사용해 검사하도록 수정하고, 동일한 정규화 로직을 195번의 유사 검사(해당 함수/조건 표현식)에도
적용해 중복 정규화와 None 안전성을 확보하세요.
관련 이슈
Close #91
🎯 배경
🔍 주요 내용