feat : chatbot department clarification message add - #75
Conversation
|
Warning Rate limit exceeded
⌛ 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. 📝 WalkthroughWalkthroughOSS 모듈에 부서/학술기관 명확화 흐름과 연락처 의도 감지 및 폰 번호 폴백 추출 로직이 추가되어, 채팅 빠른 모드에서 부서 명확화를 우선 수행하도록 변경되었습니다. (새 헬퍼 5개, 정규식 상수 1개 추가) Changes
코드 리뷰 소요 시간🎯 3 (Moderate) | ⏱️ ~20분 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
LLM/OSS/Open_AI_OSS.py (2)
409-431:_fallback_phone_from_sub_answer의user_text매개변수가 사용되지 않습니다.Ruff(ARG001)에서도 보고된 바와 같이,
user_text가 함수 본문에서 전혀 참조되지 않습니다. 의도적으로 향후 사용할 예정이라면_prefix 컨벤션(_user_text)으로 명시하거나, 불필요하다면 시그니처에서 제거하는 것이 좋습니다.제안: 미사용 매개변수 제거
-def _fallback_phone_from_sub_answer(user_text: str, sub_answer: str, hint: dict | None = None) -> Optional[str]: +def _fallback_phone_from_sub_answer(sub_answer: str, hint: dict | None = None) -> Optional[str]:호출부(Line 594)도 함께 수정해야 합니다:
- phone = _fallback_phone_from_sub_answer(user_text, sub_answer, hint) + phone = _fallback_phone_from_sub_answer(sub_answer, hint)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@LLM/OSS/Open_AI_OSS.py` around lines 409 - 431, The parameter user_text on _fallback_phone_from_sub_answer is unused; either remove it from the function signature or mark it as intentionally unused by renaming to _user_text, and update every call site that passes user_text to match the new signature (the call that currently supplies user_text must be changed accordingly). Ensure you update the function definition for _fallback_phone_from_sub_answer and its invocation(s) consistently so the linter (Ruff ARG001) no longer flags an unused parameter.
83-83:CONTACT_INTENT_RE와CONTACT_WORD_RE(Line 50) 간 중복이 존재합니다.두 정규식이 거의 동일한 패턴(
연락처|전화|전화번호|문의)을 공유하며,CONTACT_INTENT_RE에만상담|담당자가 추가되어 있습니다. 추후 유지보수 시 한쪽만 수정하고 다른 쪽을 놓칠 위험이 있으므로, 하나의 패턴으로 통합하거나CONTACT_WORD_RE를CONTACT_INTENT_RE기반으로 재사용하는 것을 권장합니다.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@LLM/OSS/Open_AI_OSS.py` at line 83, CONTACT_INTENT_RE and CONTACT_WORD_RE duplicate most of the same tokens; refactor to a single source of truth by extracting the shared pattern into one symbol (e.g., CONTACT_BASE_PATTERN or CONTACT_WORD_RE) and build CONTACT_INTENT_RE from that (e.g., re.compile(CONTACT_WORD_RE.pattern + r"|상담|담당자") or equivalent), so both regexes reuse the same base and avoid drift between CONTACT_INTENT_RE and CONTACT_WORD_RE.
🤖 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/OSS/Open_AI_OSS.py`:
- Around line 319-336: In dept_clarification_message the short_like branch
currently treats any short_like as "multiple candidates" even when candidates
has exactly one entry; update the logic so that when short_like is True you
further branch on len(candidates): if len(candidates) >= 2 keep the existing
"후보가 여러 개예요" flow (using picks = ", ".join(candidates[:4])), if len(candidates)
== 1 return a different message tailored to a single match (e.g., suggest the
single candidate and ask for full name or confirmation), and if len(candidates)
== 0 fall back to the existing "풀네임으로 입력해 주세요" message; keep references to
short_like, candidates, picks and the function name dept_clarification_message
to locate the change.
- Around line 401-409: The type-hint syntax using PEP 604 (`dict | None`,
`tuple[str|None, ...]`) breaks compatibility with older Python and is
inconsistent with the codebase; update the function signatures to use
typing.Optional instead: change `_hint_matches_line(label: str, body: str, hint:
dict | None)` to `hint: Optional[dict]`, change
`_fallback_phone_from_sub_answer(user_text: str, sub_answer: str, hint: dict |
None = None)` to `hint: Optional[dict] = None`, and update the later function
that uses `hint: dict | None` and `tuple[str|None, str|None, str|None]` to
`hint: Optional[dict]` and `Optional[tuple[str, str, str]]` respectively; ensure
`Optional` and any required types are imported from typing at the top of the
module.
---
Nitpick comments:
In `@LLM/OSS/Open_AI_OSS.py`:
- Around line 409-431: The parameter user_text on
_fallback_phone_from_sub_answer is unused; either remove it from the function
signature or mark it as intentionally unused by renaming to _user_text, and
update every call site that passes user_text to match the new signature (the
call that currently supplies user_text must be changed accordingly). Ensure you
update the function definition for _fallback_phone_from_sub_answer and its
invocation(s) consistently so the linter (Ruff ARG001) no longer flags an unused
parameter.
- Line 83: CONTACT_INTENT_RE and CONTACT_WORD_RE duplicate most of the same
tokens; refactor to a single source of truth by extracting the shared pattern
into one symbol (e.g., CONTACT_BASE_PATTERN or CONTACT_WORD_RE) and build
CONTACT_INTENT_RE from that (e.g., re.compile(CONTACT_WORD_RE.pattern +
r"|상담|담당자") or equivalent), so both regexes reuse the same base and avoid drift
between CONTACT_INTENT_RE and CONTACT_WORD_RE.
| def _hint_matches_line(label: str, body: str, hint: dict | None) -> bool: | ||
| if not hint: | ||
| return False | ||
| aliases = set(hint.get("aliases") or []) | ||
| if not aliases: | ||
| return False | ||
| return any((a in (label or "")) or (a in (body or "")) for a in aliases) | ||
|
|
||
| def _fallback_phone_from_sub_answer(user_text: str, sub_answer: str, hint: dict | None = None) -> Optional[str]: |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check Python version requirements
echo "=== pyproject.toml ==="
fd -t f "pyproject.toml" -x cat 2>/dev/null | head -50
echo ""
echo "=== setup.py ==="
fd -t f "setup.py" -x cat 2>/dev/null | head -30
echo ""
echo "=== setup.cfg ==="
fd -t f "setup.cfg" -x cat 2>/dev/null | head -30
echo ""
echo "=== .python-version ==="
fd -t f ".python-version" -x cat 2>/dev/null
echo ""
echo "=== Checking dict | None usage ==="
rg -n 'dict\s*\|\s*None' --type=py
echo ""
echo "=== Checking Optional usage patterns ==="
rg -n 'Optional\[dict\]|Optional\[.*\]' --type=py | head -20Repository: dongsooop/AI
Length of output: 2003
타입 힌트 스타일 불일치 및 Python 버전 호환성 문제 수정 필요
dict | None 및 tuple[str|None, ...] 구문(PEP 604)은 Python 3.10+ 런타임에서만 지원됩니다. 프로젝트에 명시적인 Python 버전 요구사항이 정의되지 않았으며, 코드베이스 전체에서 Optional 스타일을 일관되게 사용하고 있어 PEP 604 구문은 호환성 문제를 야기할 수 있습니다.
다음 줄들을 Optional 스타일로 통일하세요:
- 401번:
hint: dict | None→hint: Optional[dict] - 409번:
hint: dict | None = None→hint: Optional[dict] = None - 487번:
hint: dict | None및tuple[str|None, str|None, str|None]→Optional[dict]및Optional[tuple[str, str, str]]
🧰 Tools
🪛 Ruff (0.15.1)
[warning] 409-409: Unused function argument: user_text
(ARG001)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@LLM/OSS/Open_AI_OSS.py` around lines 401 - 409, The type-hint syntax using
PEP 604 (`dict | None`, `tuple[str|None, ...]`) breaks compatibility with older
Python and is inconsistent with the codebase; update the function signatures to
use typing.Optional instead: change `_hint_matches_line(label: str, body: str,
hint: dict | None)` to `hint: Optional[dict]`, change
`_fallback_phone_from_sub_answer(user_text: str, sub_answer: str, hint: dict |
None = None)` to `hint: Optional[dict] = None`, and update the later function
that uses `hint: dict | None` and `tuple[str|None, str|None, str|None]` to
`hint: Optional[dict]` and `Optional[tuple[str, str, str]]` respectively; ensure
`Optional` and any required types are imported from typing at the top of the
module.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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/OSS/Open_AI_OSS.py`:
- Around line 803-810: The dept clarification step can block schedule queries
because decide_mode routes many queries to "fast" and dept_clarification_message
(invoking _find_dept_candidates) may return a clarification even for schedule
questions; ensure schedule-related queries bypass clarification by checking
looks_like_schedule(user_text) before calling dept_clarification_message (or
alternatively, after deciding mode keep the current clarification order but
short-circuit clarification when schedule_search or looks_like_schedule
indicates a schedule query). Update the fast-mode branch around
dept_clarification_message, schedule_search, and looks_like_schedule so that if
looks_like_schedule(user_text) (or schedule_search(user_text, top_k=...) returns
a positive signal) you skip dept_clarification_message and proceed to
schedule_search/render_chatty_schedule.
---
Duplicate comments:
In `@LLM/OSS/Open_AI_OSS.py`:
- Around line 426-457: The two issues: the PEP 604 union syntax "dict | None" in
_hint_matches_line and _fallback_phone_from_sub_answer breaks on <3.10 runtimes,
and the parameter user_text in _fallback_phone_from_sub_answer is unused (Ruff
ARG001). Fix by either adding from __future__ import annotations at the top of
the file to make "dict | None" safe across Python 3.7+ or replace occurrences of
"dict | None" with typing.Optional[dict] (and import Optional) to preserve
compatibility; and remove or rename the unused parameter in
_fallback_phone_from_sub_answer (change user_text to _user_text to silence the
linter, or remove it from the signature) and update its call sites accordingly
(the caller that passes user_text must be adjusted to stop passing that argument
if you remove it).
📌 챗봇 학과 이름 검증 로직 추가
📝 작업 내용
✅ 체크리스트
변경 요약
채팅봇에 학과명 모호성 해소용 명확화 메시지 기능을 추가하고, 연락처 관련 쿼리 처리와 짧은 학과명 예외처리를 보강했습니다.
주요 변경점
공개 함수
dept_clarification_message()추가로 사용자의 학과 질의에 대해 후보 제시 및 명확화 응답 제공핵심 추출 및 후보 검색용 내부 헬퍼
_extract_dept_query_core,_find_dept_candidates등 4개 추가연락처 의도 감지용
CONTACT_INTENT_RE정규식 추가 및 연락처 추출용 폴백_fallback_phone_from_sub_answer구현one_sentence_from_sub_answer()개선: 연락처 의도 감지 시 폴백 전화번호 추출 및 힌트 기반 레이블 정규화 추가OSS 채팅 플로우(빠른 모드)에 학과 명확화 우선 처리 추가로 의도 혼동 시 조기 응답
짧은 학과명 토큰에 대한 예외처리 로직(짧은 단어 특수 처리) 추가
주의/리스크
학과 후보 제시의 정확성(특히 단어가 짧은 경우)과 오탐 여지 검증 필요
명확화 우선 처리로 기존 응답 흐름과 충돌 가능성 — 다른 서브로직 영향 확인 권장
다음 액션
학과 처리 및 연락처 추출의 엣지케이스에 대한 단위/통합 테스트 추가
리뷰어가 있으면 로직 동작 예시(입력→출력 케이스) 제공하여 검증 요청